mozilla / http-observatory-cli

The command line tool for the HTTP Observatory
Mozilla Public License 2.0
90 stars 11 forks source link

Fix #9 Timezone error when calculating age of scan #10

Closed taladar closed 3 years ago

taladar commented 8 years ago

Adds pytz as a dependency, this was necessary since datetime apparently does not contain any tzinfo instances and it is better than reinventing the wheel.

The problem was that apparently datetime.strptime does not create timezone-aware datetime objects even when %Z (timezone name) is used as part of the format string. datetime.now() without tzinfo parameter creates a timezone-naive datetime object as well but defaults to local time for the actual values instead of the more sensible UTC.

As a further suggestion for latter improvements I would suggest formatting the dates in the API as ISO8601 dates instead of the current ones which contain localized weekday and month names. I did not do this for now since i did not want to modify multiple components for this PR.