例子:
os.environ['TZ'] = "CST+06CDT,M4.1.0,M10.5.0"
I can understand CST, 06 (offset from UTC ?? or GMT) , CDT == Central Daylight Saving Time but
What do M4.1.0 and M10.5.0 mean ?
Here is what i found:
export TZ=EST05EDT
EST was taken from the chart below. Five hours has to be added to get UTC, hence the 05. And currently EDT, Eastern Daylight, is in effect.
TZ=.
DST timezones
0 BST for British Summer.
+400 ADT for Atlantic Daylight.
+500 EDT for Eastern Daylight.
+600 CDT for Central Daylight.
+700 MDT for Mountain Daylight.
+800 PDT for Pacific Daylight.
+900 YDT for Yukon Daylight.
+1000 HDT for Hawaii Daylight.
-100 MEST for Middle European Summer,
MESZ for Middle European Summer,
SST for Swedish Summer and FST for French Summer.
-700 WADT for West Australian Daylight.
-1000 EADT for Eastern Australian Daylight.
-1200 NZDT for New Zealand Daylight.
有没有更简单的方法来回到我正确的时间?是的,只需取消设置 TZ 环境变量。
$ unset TZ
$ date
Sun Aug 22 10:17:35 EDT 2004
请注意,即使 TZ 已针对夏令时进行了调整,您会在 5 个月后得到正确的时间吗?夏令时何时生效?下面显示的 TZ 值仅在正确的日期期间针对夏令时进行调整。例如,此条目从 4 月第一周凌晨 2 点开始生效,到 10 月第 5 周凌晨 2 点结束。注意 10.5.0 代表十月的第 5 周,而不是第 5 天。
$ export TZ=EST+5EDT,M4.1.0/2,M10.5.0/2
最佳答案
来自python manual :
The standard format of the TZ environment variable is (whitespace added for clarity):
std offset [dst [offset [,start[/time], end[/time]]]]
Mm.n.d The d‘th day (0 <= d <= 6) or week n of month m of the year (1 <= n <= 5, 1 <= m <= 12, where week 5 means “the last d day in month m” which may occur in either the fourth or the fifth week). Week 1 is the first week in which the d‘th day occurs. Day zero is Sunday.
https://stackoverflow.com/questions/5873857/
相关文章:
api - ElementCollection 与 JPQL 方法上的 CriteriaBuilde
ruby-on-rails - rails : using helper methods from
python - 使用另一个 python 文件修改/替换 python 文件中的一行
security - SaferCreateLevel SAFER_LEVELID_UNTRUSTE
ruby-on-rails - 运行请求规范时显示服务器输出
macos - 在 MAC OS X 上的 MONO 中调用命令行