Linux, timezone and dst
I'm using RHEL 5.3 (linux 2.6.18)
I have a legacy code that relies on timezone and dst returned by ftime(3).
开发者_运维百科Now from ftime(3) man pages I see that timezone and dstflag are not supported. Also in gettimeofday(3) those fields are not supported.
How I can retrieve timezone and dst?
Thanks
You can use tzset(3)
:
#define _XOPEN_SOURCE
#include <time.h>
#include <stdio.h>
int main(void)
{
tzset();
printf("%ld, %d\n", timezone, daylight);
}
Which on my system prints "-3600, 1".
tzset
also fills the array char *tzname[2]
with the names of the standard and daylight saving time timezone names.
精彩评论