Python夏令时 [英] Python daylight savings time

查看:110
本文介绍了Python夏令时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查夏令时是否有效?

How do I check if daylight saving time is in effect?

推荐答案

您可以使用 time.localtime 并查看<$返回值中的c $ c> tm_isdst 标志。

>>> import time
>>> time.localtime()
(2010, 5, 21, 21, 48, 51, 4, 141, 0)
>>> _.tm_isdst
0

使用 time.localtime(),您可以在任意时间问相同的问题,以了解DST在当前时区是否有效。

Using time.localtime(), you can ask the same question for any arbitrary time to see whether DST would be (or was) in effect for your current time zone.

这篇关于Python夏令时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆