【发布时间】:2015-02-06 18:07:33
【问题描述】:
我在 python django 中使用 delorean 进行日期时间计算。
http://delorean.readthedocs.org/en/latest/quickstart.html
这是我正在使用的:
now = Delorean(timezone=settings.TIME_ZONE).datetime
todayDate = now.date()
但我收到此警告:
RuntimeWarning: DateTimeField start_time received a naive datetime (2014-12-09 00:00:00) while time zone support is active.
我想知道如何让它知道。
我也试过了:
todayDate = timezone.make_aware(now.date(), timezone=settings.TIME_ZONE)
然后我明白了:
AttributeError: 'datetime.date' object has no attribute 'tzinfo'
【问题讨论】:
-
不确定它在
Delorean中是如何工作的,但日期时间可以是时区感知的,因为日期的概念不太有意义。
标签: python django datetime timezone