Thor77 / TeamspeakStats

A simple Teamspeak stats-generator - based on server-logs
MIT License
19 stars 2 forks source link

Default datetime format does not include timezone, depsite including %Z #9

Closed djmattyg007 closed 7 years ago

djmattyg007 commented 7 years ago

According to this, it's probably because the datetime object being formatted is naive (does not include timezone information):

https://docs.python.org/3/library/datetime.html?highlight=datetime#strftime-strptime-behavior

Thor77 commented 7 years ago

This is harder than I expected it to be (especially if I want to continue support for py2, which I definitely want to). I have a working protoype in the timezone-aware branch but it currently requires py3, because py2 doesn't support datetime.timezone.

djmattyg007 commented 7 years ago

Given all timestamps in the teamspeak logs appear to be in UTC, and the difficulty of attempting to support this at all in python2 (I had no idea that python2 didn't have sensible timezone handling built in), perhaps it might be easier to just put the string 'UTC' into the default date format and be done with it?

Thor77 commented 7 years ago

It would work, yeah. But I don't really want to use such hacks, it wouldn't really solve the problem. I'll see if I can find out how pytz is implementing those things or just add it as a dependency and use it's implementation.

Thor77 commented 7 years ago

Fixed by reimplementing py3's timezone.utc.