Make LiveLocationAttachment.expires_at a datetime object

Renamed from .expiration_time
This commit is contained in:
Mads Marquart
2019-09-08 13:03:46 +02:00
parent 61842b199f
commit 2e53963398

View File

@@ -59,14 +59,14 @@ class LiveLocationAttachment(LocationAttachment):
#: Name of the location #: Name of the location
name = attr.ib(None) name = attr.ib(None)
#: Timestamp when live location expires #: Datetime when live location expires
expiration_time = attr.ib(None) expires_at = attr.ib(None)
#: True if live location is expired #: True if live location is expired
is_expired = attr.ib(None) is_expired = attr.ib(None)
def __init__(self, name=None, expiration_time=None, is_expired=None, **kwargs): def __init__(self, name=None, expires_at=None, is_expired=None, **kwargs):
super(LiveLocationAttachment, self).__init__(**kwargs) super(LiveLocationAttachment, self).__init__(**kwargs)
self.expiration_time = expiration_time self.expires_at = expires_at
self.is_expired = is_expired self.is_expired = is_expired
@classmethod @classmethod
@@ -80,7 +80,7 @@ class LiveLocationAttachment(LocationAttachment):
if not data.get("stopReason") if not data.get("stopReason")
else None, else None,
name=data.get("locationTitle"), name=data.get("locationTitle"),
expiration_time=data["expirationTime"], expires_at=_util.millis_to_datetime(data["expirationTime"]),
is_expired=bool(data.get("stopReason")), is_expired=bool(data.get("stopReason")),
) )
@@ -96,7 +96,7 @@ class LiveLocationAttachment(LocationAttachment):
if target.get("coordinate") if target.get("coordinate")
else None, else None,
name=data["title_with_entities"]["text"], name=data["title_with_entities"]["text"],
expiration_time=target.get("expiration_time"), expires_at=_util.millis_to_datetime(target.get("expiration_time")),
is_expired=target.get("is_expired"), is_expired=target.get("is_expired"),
) )
media = data.get("media") media = data.get("media")