diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-06-16 17:51:35 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-06-16 17:51:35 +0300 |
commit | 95c8a0ca221e157660e7d8b1278299809c1d19fa (patch) | |
tree | 34cd88d942e592c9fb49f85682a17541e1c17b6f /vk/utils/tracking/db/record.py | |
parent | log user's "last seen" time if they're online (diff) | |
download | vk-scripts-95c8a0ca221e157660e7d8b1278299809c1d19fa.tar.gz vk-scripts-95c8a0ca221e157660e7d8b1278299809c1d19fa.zip |
make "last seen" timestamps timezone-aware
Diffstat (limited to 'vk/utils/tracking/db/record.py')
-rw-r--r-- | vk/utils/tracking/db/record.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/vk/utils/tracking/db/record.py b/vk/utils/tracking/db/record.py index e126442..7cb054f 100644 --- a/vk/utils/tracking/db/record.py +++ b/vk/utils/tracking/db/record.py @@ -3,12 +3,12 @@ # See LICENSE.txt for details. from collections import OrderedDict -from datetime import datetime +from datetime import datetime, timezone from vk.user import Field as UserField def _gen_timestamp(): - return datetime.utcnow().replace(microsecond=0) + return datetime.now(timezone.utc).replace(microsecond=0) class Record: _USER_FIELDS = ( @@ -51,6 +51,8 @@ class Record: fields = OrderedDict() for field in Record._USER_FIELDS: fields[field] = user[field] + if UserField.LAST_SEEN in Record._USER_FIELDS: + fields[UserField.LAST_SEEN] = fields[UserField.LAST_SEEN].isoformat() return Record(fields) @staticmethod |