c - 如何在 Linux 中实现不同时区的夏令时?

标签 c linux

我正在获取时区

time_String = GetTimeZoneDisplayName(enum_timezone);

time_String 是一个特定的时区。为了将日光添加到特定时区,下面函数中的最后一个参数应该是正数。如何确定哪个时区有夏令时?

setenv( "TZ", time_String, 0(No Daylight)/+ve (Daylight is there );    

最佳答案

(从评论中移出)

除非我误解了这个问题,否则这通常是使用 tzset() 完成的. glibc docs cover this ,包括为什么通常不需要自己调用它:

Function: void tzset (void)

Preliminary: | MT-Safe env locale | AS-Unsafe heap lock | AC-Unsafe lock mem fd | See POSIX Safety Concepts.

The tzset function initializes the tzname variable from the value of the TZ environment variable. It is not usually necessary for your program to call this function, because it is called automatically when you use the other time conversion functions that depend on the time zone.

它以您想要的方式设置环境变量以及填充 tzname 和设置 DST(如果时区有)。

关于c - 如何在 Linux 中实现不同时区的夏令时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32560857/

相关文章:

c++ - 寻找代码 stub 生成器(来自头文件)

c++ - 有没有办法在 Eclipse 中找到匹配的#if、#else、#elif 和#endif?

c++ - 如何解决 linux 定时器信号处理程序

php - UTF-8贯穿始终

linux - Linux阻塞与非阻塞串行读取

c - 执行 malloc() 期间的 EXC_BAD_ACCESS (KERN_INVALID_ADDRESS)

c - C : "(void)ptr;" 这个语句是什么意思

c# - 在 C# 中的 C/C++ DLL 中使用嵌套结构指针

java - RHEL 5/RHEL 6 上的 libfaketime 和 java

linux - Bourne Shell (bin/sh) 中的嵌套变量