Make Plan.time a datetime object
This commit is contained in:
@@ -1733,7 +1733,7 @@ class Client:
|
|||||||
|
|
||||||
data = {
|
data = {
|
||||||
"event_type": "EVENT",
|
"event_type": "EVENT",
|
||||||
"event_time": plan.time,
|
"event_time": _util.datetime_to_seconds(plan.time),
|
||||||
"title": plan.title,
|
"title": plan.title,
|
||||||
"thread_id": thread_id,
|
"thread_id": thread_id,
|
||||||
"location_id": plan.location_id or "",
|
"location_id": plan.location_id or "",
|
||||||
@@ -1760,7 +1760,7 @@ class Client:
|
|||||||
data = {
|
data = {
|
||||||
"event_reminder_id": plan.uid,
|
"event_reminder_id": plan.uid,
|
||||||
"delete": "false",
|
"delete": "false",
|
||||||
"date": new_plan.time,
|
"date": _util.datetime_to_seconds(new_plan.time),
|
||||||
"location_name": new_plan.location or "",
|
"location_name": new_plan.location or "",
|
||||||
"location_id": new_plan.location_id or "",
|
"location_id": new_plan.location_id or "",
|
||||||
"title": new_plan.title,
|
"title": new_plan.title,
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import attr
|
import attr
|
||||||
import json
|
import json
|
||||||
from ._core import Enum
|
from ._core import Enum
|
||||||
|
from . import _util
|
||||||
|
|
||||||
|
|
||||||
class GuestStatus(Enum):
|
class GuestStatus(Enum):
|
||||||
@@ -15,8 +16,8 @@ class Plan:
|
|||||||
|
|
||||||
#: ID of the plan
|
#: ID of the plan
|
||||||
uid = attr.ib(None, init=False)
|
uid = attr.ib(None, init=False)
|
||||||
#: Plan time (timestamp), only precise down to the minute
|
#: Plan time (datetime), only precise down to the minute
|
||||||
time = attr.ib(converter=int)
|
time = attr.ib()
|
||||||
#: Plan title
|
#: Plan title
|
||||||
title = attr.ib()
|
title = attr.ib()
|
||||||
#: Plan location name
|
#: Plan location name
|
||||||
@@ -58,7 +59,7 @@ class Plan:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def _from_pull(cls, data):
|
def _from_pull(cls, data):
|
||||||
rtn = cls(
|
rtn = cls(
|
||||||
time=data.get("event_time"),
|
time=_util.seconds_to_datetime(int(data.get("event_time"))),
|
||||||
title=data.get("event_title"),
|
title=data.get("event_title"),
|
||||||
location=data.get("event_location_name"),
|
location=data.get("event_location_name"),
|
||||||
location_id=data.get("event_location_id"),
|
location_id=data.get("event_location_id"),
|
||||||
@@ -74,7 +75,7 @@ class Plan:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def _from_fetch(cls, data):
|
def _from_fetch(cls, data):
|
||||||
rtn = cls(
|
rtn = cls(
|
||||||
time=data.get("event_time"),
|
time=_util.seconds_to_datetime(data.get("event_time")),
|
||||||
title=data.get("title"),
|
title=data.get("title"),
|
||||||
location=data.get("location_name"),
|
location=data.get("location_name"),
|
||||||
location_id=str(data["location_id"]) if data.get("location_id") else None,
|
location_id=str(data["location_id"]) if data.get("location_id") else None,
|
||||||
@@ -87,7 +88,7 @@ class Plan:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def _from_graphql(cls, data):
|
def _from_graphql(cls, data):
|
||||||
rtn = cls(
|
rtn = cls(
|
||||||
time=data.get("time"),
|
time=_util.seconds_to_datetime(data.get("time")),
|
||||||
title=data.get("event_title"),
|
title=data.get("event_title"),
|
||||||
location=data.get("location_name"),
|
location=data.get("location_name"),
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user