我有一个在跨平台上运行的C应用程序。在此程序中,我需要编写一个函数来确定给定日期是否为夏令时。
实际上,我尝试在纯C中找到DST开始-DST结束日期。是否有任何简单且标准的方法来做到这一点?
time.h
提供tm
带有tm_isdst
标志的结构。使用time
以获取当前时间,localtime
以获得tm
与调整到当前区域设置的时间结构和阅读的tm_isdst
标志。
从联机帮助页:
tm_isdst A flag that indicates whether daylight saving time is in effect at the
time described. The value is positive if daylight saving time is in effect, zero
if it is not, and negative if the information is not available.
Run Code Online (Sandbox Code Playgroud)