0

I'm having a (django) db that wants datetime objects, and I'd like to feed it data from git commits.

Now git commits have that "not really a timezone" offset thingie.

What's the correct way to get a python datetime? Any luck with getting timezones right?

I'm thinking about

datetime.datetime.utcfromtimestamp(commit.commit_time)

I'm using dulwich right now, but that seems to be a side note.

Pike
  • 166
  • 1
  • 6

1 Answers1

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.

jelmer
  • 2,405
  • 14
  • 27