sbg / sevenbridges-python

SevenBridges Python Api bindings
Apache License 2.0
46 stars 27 forks source link

Filemodification times contain no timezone information #95

Closed bjoernpollex closed 7 years ago

bjoernpollex commented 7 years ago

The attributes created_on and modified_on of sevenbridges.models.file.File don't have associated timezone information (and f.modified_on.tzinfo is None is True), and they are not UTC timestamps either.

Specifically, given a file f on the platform, the following is not true:

f.modified_on == datetime.fromtimestamp(timegm(f.modified_on.timetuple()))

In my case the difference is exactly one hour. Ideally these timestamps would always be UTC, but if they are not, they should at least have timezone information.

SenadI commented 7 years ago

Hi @bjoernpollex .fromtimestamp returns local date and time. As you can see now the date is correct.

In [22]: datetime.fromtimestamp(timegm(f.modified_on.timetuple()), pytz.UTC)
Out[22]: datetime.datetime(2017, 9, 20, 8, 2, 43, tzinfo=<UTC>)

In [23]: f.modified_on
Out[23]: datetime.datetime(2017, 9, 20, 8, 2, 43)

To add all times are in UTC. Timezone information is not present. UTC is used always. The information is returned in ISO8601 format.

bjoernpollex commented 7 years ago

Ha, timezones! - I should have expected that I'd screw this up. Thanks for the clarification!