_daylight、_dstbias、_timezone 和 _tzname_daylight, _dstbias, _timezone, and _tzname

_daylight_dstbias_timezone_tzname 在某些时间和日期例程中用来调整本地时间。_daylight, _dstbias, _timezone, and _tzname are used in some time and date routines to make local-time adjustments. 这些全局变量因安全性更高的函数版本(它们取代了全局变量)而被弃用。These global variables have been deprecated for the more secure functional versions, which should be used in place of the global variables.

全局变量Global variable 等效函数Functional equivalent
_daylight _get_daylight_get_daylight
_dstbias _get_dstbias_get_dstbias
_timezone _get_timezone_get_timezone
_tzname _get_tzname_get_tzname

在 Time.h 中按如下方式声明它们。They are declared in Time.h as follows.

语法Syntax

extern int _daylight;   
extern int _dstbias;   
extern long _timezone;   
extern char *_tzname[2];  

备注Remarks

在调用 _ftimelocaltime_tzset 时,_daylight_dstbias_timezone_tzname 的值由 TZ 环境变量的值确定。On a call to _ftime, localtime, or _tzset, the values of _daylight, _dstbias, _timezone, and _tzname are determined from the value of the TZ environment variable. 如果您未显式设置 TZ 的值,则 _tzname[0]_tzname[1] 将分别包含“PST”和“PDT”的默认设置。If you do not explicitly set the value of TZ, _tzname[0] and _tzname[1] contain the default settings of "PST" and "PDT" respectively. 时间操作函数(_tzset_ftime,和 localtime)尝试通过在操作系统中查询每个变量的默认值来设置 _daylight_dstbias_timezone 的值。The time-manipulation functions (_tzset, _ftime, and localtime) attempt to set the values of _daylight, _dstbias and _timezone by querying the operating system for the default value of each variable. 下表显示了时区全局变量的值。The time-zone global variable values are shown in the following table.

变量Variable Value
_daylight 如果在 TZ 中指定或从操作系统确定夏令时 (DST) 时区,则为非零值;否则为 0。Nonzero if daylight saving time (DST) zone is specified in TZ or determined from the operating system; otherwise, 0. 默认值为 1。The default value is 1.
_dstbias 夏令时的偏移量。Offset for daylight saving time.
_timezone 协调世界时和本地时间之间的差异(以秒为单位)。Difference in seconds between coordinated universal time and local time. 默认值为 28,800。The default value is 28,800.
_tzname[0] 派生自 TZ 环境变量的时区名称。Time-zone name derived from the TZ environment variable. 默认值是“PST”。The default value is "PST".
_tzname[1] 派生自 TZ 环境变量的 DST 时区名称。DST zone name derived from the TZ environment variable. 默认值为“PDT”(太平洋夏令时)。The default value is "PDT" (Pacific daylight time).

另请参阅See Also

全局变量 Global Variables
_get_daylight _get_daylight
_get_dstbias _get_dstbias
_get_timezone _get_timezone
_get_tzname_get_tzname