Fix parsing date in Deserializable objects.

This commit is contained in:
Alex Root Junior 2017-08-05 04:15:16 +03:00
parent b2798e39a8
commit 33f7f0018e
4 changed files with 5 additions and 13 deletions

View file

@ -59,6 +59,11 @@ class Deserializable:
result[name] = attr
return result
@classmethod
def _parse_date(cls, unix_time):
if unix_time is not None:
return datetime.datetime.fromtimestamp(unix_time)
@property
def bot(self) -> 'Bot':
"""

View file

@ -35,11 +35,6 @@ class ChatMember(Deserializable):
self.can_send_other_messages: bool = can_send_other_messages
self.can_add_web_page_previews: bool = can_add_web_page_previews
@classmethod
def _parse_date(cls, unix_time):
if unix_time is not None:
return datetime.datetime.fromtimestamp(unix_time)
@classmethod
def de_json(cls, raw_data):
user = User.deserialize(raw_data.get('user'))

View file

@ -74,10 +74,6 @@ class Message(Deserializable):
self.content_type = content_type
@classmethod
def _parse_date(cls, unix_time):
return datetime.datetime.fromtimestamp(unix_time)
@classmethod
def de_json(cls, raw_data):
message_id = raw_data.get('message_id')

View file

@ -19,10 +19,6 @@ class WebhookInfo(Deserializable):
self.max_connections: int = max_connections
self.allowed_updates: [str] = allowed_updates
@classmethod
def _parse_date(cls, unix_time):
return datetime.datetime.fromtimestamp(unix_time)
@classmethod
def de_json(cls, raw_data):
url = raw_data.get('url')