0

我有一个需要日期时间对象的(django)数据库,我想从 git 提交中提供数据。

现在 git 提交具有“不是真正的时区”偏移量。

获取python日期时间的正确方法是什么?获得正确的时区有什么运气吗?

我在考虑

datetime.datetime.utcfromtimestamp(commit.commit_time)

我现在正在使用德威,但这似乎是一个旁注。

4

1 回答 1

0

You probably want to use a "FixedOffset" timezone as suggested in the datetime documentation. Unfortunately it looks like datetime doesn't include this class itself, so you'll have to copy it into your code.

See https://docs.python.org/2/library/datetime.html . Specifically, look for FixedOffset.

于 2015-03-21T23:53:45.373 回答