From 6d13937c4aa5c82e02d75562d8ecc74a931fbb16 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Sun, 8 Sep 2019 15:24:57 +0200 Subject: [PATCH] Make Plan.time a datetime object --- fbchat/_client.py | 4 ++-- fbchat/_plan.py | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/fbchat/_client.py b/fbchat/_client.py index 0465ba5..20784ab 100644 --- a/fbchat/_client.py +++ b/fbchat/_client.py @@ -1733,7 +1733,7 @@ class Client: data = { "event_type": "EVENT", - "event_time": plan.time, + "event_time": _util.datetime_to_seconds(plan.time), "title": plan.title, "thread_id": thread_id, "location_id": plan.location_id or "", @@ -1760,7 +1760,7 @@ class Client: data = { "event_reminder_id": plan.uid, "delete": "false", - "date": new_plan.time, + "date": _util.datetime_to_seconds(new_plan.time), "location_name": new_plan.location or "", "location_id": new_plan.location_id or "", "title": new_plan.title, diff --git a/fbchat/_plan.py b/fbchat/_plan.py index 1a3c5bd..373f8da 100644 --- a/fbchat/_plan.py +++ b/fbchat/_plan.py @@ -1,6 +1,7 @@ import attr import json from ._core import Enum +from . import _util class GuestStatus(Enum): @@ -15,8 +16,8 @@ class Plan: #: ID of the plan uid = attr.ib(None, init=False) - #: Plan time (timestamp), only precise down to the minute - time = attr.ib(converter=int) + #: Plan time (datetime), only precise down to the minute + time = attr.ib() #: Plan title title = attr.ib() #: Plan location name @@ -58,7 +59,7 @@ class Plan: @classmethod def _from_pull(cls, data): rtn = cls( - time=data.get("event_time"), + time=_util.seconds_to_datetime(int(data.get("event_time"))), title=data.get("event_title"), location=data.get("event_location_name"), location_id=data.get("event_location_id"), @@ -74,7 +75,7 @@ class Plan: @classmethod def _from_fetch(cls, data): rtn = cls( - time=data.get("event_time"), + time=_util.seconds_to_datetime(data.get("event_time")), title=data.get("title"), location=data.get("location_name"), location_id=str(data["location_id"]) if data.get("location_id") else None, @@ -87,7 +88,7 @@ class Plan: @classmethod def _from_graphql(cls, data): rtn = cls( - time=data.get("time"), + time=_util.seconds_to_datetime(data.get("time")), title=data.get("event_title"), location=data.get("location_name"), )