lastorel / pytion

Unofficial Python client for official Notion API
GNU General Public License v3.0
44 stars 3 forks source link

Timezones for Date property values #1

Closed lastorel closed 2 years ago

lastorel commented 2 years ago

This example {'date': {'start': '2021-11-24T00:20:42.171423', 'end': None}} will be accepted like UTC time. Notion shows Today 00:20 (UTC) Well it is not correct time for my timezone in reality. Yeah, I can to modify timezone in "Date format..." in Notion, but this is not the automation.

Let's try to push to API other representations of date.

lastorel commented 2 years ago

Notion API always returns time in format 2021-11-23T18:57:00.000Z . UTC. This string converts in 2021-11-23T18:57:00.000+00:00 and Models have UTC time. You can use .astimezone() to convert this time to your local system time.

When you create or update something, ex. PropertyValue(type_="date", value=datetime.datetime.now()), your timezone will be added automatically. Thus Notion receives correct time value.