获取世界上任何位置的时区。
whenareyou的Python项目详细描述
获取世界上任何位置的时区。
它使用google并缓存结果,这样您就可以希望留在外面 自由利率限制(我不知道有多高)。
使用方法如下:
$ pip install whenareyou $ ipython In [1]: from whenareyou import whenareyou In [2]: tz = whenareyou('Hamburg') In [3]: tz Out[3]: <DstTzInfo 'Europe/Berlin' LMT+0:53:00 STD> In [4]: from datetime import datetime In [5]: tz.localize(datetime(2002, 10, 27, 6, 0, 0)) Out[5]: datetime.datetime(2002, 10, 27, 6, 0, tzinfo=<DstTzInfo 'Europe/Berlin' CET+1:00:00 STD>) In [6]: tz.localize(datetime(2002, 10, 27, 6, 0, 0)).isoformat() Out[6]: '2002-10-27T06:00:00+01:00'