要挂接到OS时区库的DateTime Tzinfo类
PosixTimeZone的Python项目详细描述
- posixTimeZone是Python2.3的Tzinfo实现,使用
许多操作系统提供的处理时区的posix调用 计算:
>>> from datetime import timedelta,datetime >>> from PosixTimeZone import PosixTimeZone >>> UTC = PosixTimeZone('UTC') >>> Amsterdam = PosixTimeZone('Europe/Amsterdam') >>> now = datetime.now(UTC) >>> str(now) '2003-01-30 07:01:07.885573+00:00' >>> now.tzname() 'UTC' >>> str(now.astimezone(Amsterdam)) '2003-01-30 08:01:07.885573+01:00' >>> now.astimezone(Amsterdam).tzname() 'CET'