从python中取消时区的时区忽略了DST
从Python的时区获得UTC偏移的正确方法是什么? 我需要一个函数来发送PYTZ时区,并获得时区偏移,而忽略了节目的节省时间。
import pytz
tz = pytz.timezone('Europe/Madrid')
getOffset(tz) #datetime.timedelta(0, 3600)
What is the correct way to get an UTC offset from a timezone in python?
I need a function to send a pytz timezone and get the timezone offset ignoring the Daylight Saving Time.
import pytz
tz = pytz.timezone('Europe/Madrid')
getOffset(tz) #datetime.timedelta(0, 3600)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
pytz
时区对象obeytzinfo
API规范在dateTime
模块中定义。因此,您可以使用他们的.utcoffset()
和.dst()
方法:pytz
timezone objects obeytzinfo
API specification defined in thedatetime
module. Therefore you can use their.utcoffset()
and.dst()
methods:还可以很好地与Python 3.9's directInInfo.ZoneInfo.ZoneInfo :
also works nicely with Python 3.9 's zoneinfo.ZoneInfo: