torproject / stem

Python controller library for Tor
https://stem.torproject.org/
GNU Lesser General Public License v3.0
257 stars 75 forks source link

When parsing documents, use "aware" (UTC) rather than "naive" dates/times #107

Closed stevenengler closed 2 years ago

stevenengler commented 2 years ago

Although not explicitly specified in the dir-spec, it should be safe to assume all times given in directory documents, server descriptors, etc are in UTC. When stem parses dates/times from these documents it would be helpful to make them "aware" datetimes.

For example in _parse_timestamp() which stem uses to parse dates from the consensus documents into datetime objects, it would be useful to set the timezone as UTC. Otherwise code using these datetime objects without handling the timezone properly will assume that they're in the user's local time.

atagar commented 2 years ago

Great point! Thanks Steven. Merged.