Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 RHEL 5.3 (linux 2.6.18)
我有一个依赖于ftime (3) 返回的时区和 dst 的遗留代码。
现在从ftime (3) 手册页中,我看到不支持时区和dstflag 。在gettimeofday (3) 中也不支持这些字段。
如何检索时区和 dst?
谢谢
您可以使用tzset(3):
tzset(3)
#define _XOPEN_SOURCE #include <time.h> #include <stdio.h> int main(void) { tzset(); printf("%ld, %d\n", timezone, daylight); }
在我的系统上打印“-3600, 1”。
tzsetchar *tzname[2]还使用标准和夏令时时区名称的名称填充数组。
tzset
char *tzname[2]