inside localtime() - wondering how to easily extract timezone difference
I quote from man localtime:
Quote:
The ctime(), gmtime() and localtime() functions all take an argument of data type time_t which represents calendar time. When interpreted as an absolute time value, it represents the number of seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC).
Now I get this time_t value using time(NULL), and pass a pointer to that value to localtime() to get the local time as a struct tm. I wonder how localtime finds out the time zone value which is not a part of the time_t value (as far as I can make out from the man page.
Any hints as to this would be appreciated. Otherwise I have to do some circus with finding out the difference between the values returned by localtime and gmtime.
Re: inside localtime() - wondering how to easily extract timezone difference
Quoting from man 3p localtime
Quote:
The localtime() function shall convert the time in seconds since the Epoch pointed to by timer into a broken-down time, expressed as a local time. The function corrects for the timezone and any seasonal time adjustments. Local timezone information is used as though localtime() calls tzset().
So man tzset has the answers ;) (if I understood your question right)
Re: inside localtime() - wondering how to easily extract timezone difference
Quote:
Originally Posted by yop
Quoting from man 3p localtime
So man tzset has the answers ;) (if I understood your question right)
Well ya I forgot to mention that I have read through tzset - but it appears to be a UNIX-specific thing. How would then the localtime() function compile/work on DOS/Windows?
Re: inside localtime() - wondering how to easily extract timezone difference
Quote:
Originally Posted by jamadagni
Well ya I forgot to mention that I have read through tzset - but it appears to be a UNIX-specific thing. How would then the localtime() function compile/work on DOS/Windows?
Does it matter? The most important part is that it works (if it works, because localtime() is not an ANSI C function, so I guess non-posix Windows may not have it), right? Let's leave libc programming to libc programmers.
Re: inside localtime() - wondering how to easily extract timezone difference
http://cygwin.com/cygwin-api/cygwin-api.html (but be warned the water is getting deeper ;))
Re: inside localtime() - wondering how to easily extract timezone difference
Quote:
Originally Posted by wysota
localtime() is not an ANSI C function
Of course it's an ANSI C function - it is listed and described by K&R in their ANSI C book.
Re: inside localtime() - wondering how to easily extract timezone difference
"man localtime" gives this as compliance standards:
Quote:
SVID 3, POSIX, BSD 4.3, ISO 9899