Regarding __date__ __time__ and localtime in Z/OS
Select messages from
# through # FAQ
[/[Print]\]

MVSFORUMS.com -> Application Programming

#1: Regarding __date__ __time__ and localtime in Z/OS Author: deepthijLocation: Bangalore PostPosted: Fri Jun 05, 2009 1:39 am
    —
Hi All,

In my application I need to display localtime of the client and I used the below code snippet

void getCurrentDateTime(char *dateTimeString, int dateTimeStringLen) {

time_t temp;
struct tm *timeptr;

temp = time(NULL);
timeptr = localtime(&temp);
strftime(dateTimeString,dateTimeStringLen,"%Om/%Od/%EY %T",timeptr);

}

Its displaying time always in GMT .
Instead of that is that ok to use __DATE__ and __TIME__ ?
What is the difference btw localtime and the above macro( __DATE__ and __TIME__ ) ?

Shocked

Thanks in Advance.

#2:  Author: DaveyCLocation: Perth, Western Australia PostPosted: Fri Jun 05, 2009 4:43 am
    —
__DATE__ and __TIME__ are compiler generated timestamps. That's a terrible idea and you should abandon it right now. They're constants!

If this is to do with POSIX(ON) it's probably displaying GMT because your systems programmers haven't setup the TZ environment variable in /etc/profile correctly. Give them a prod.

If you want to be consistent in both posix and non-posix environments you will have to chase control blocks and get the system time zone offset from the CVT extension block.



MVSFORUMS.com -> Application Programming


output generated using printer-friendly topic mod. All times are GMT - 5 Hours

Page 1 of 1

Powered by phpBB © 2001, 2005 phpBB Group