Skip to main content
Practitioner ⭐️⭐️⭐️
Jul 4, 2022 10:32 AM UTC
Implemented

Cognite Data Fusion: Add support for timezone-aware datetimes in CDF API

Related products:REST API

Currently, the client.datapoints.insert() function does not support timezone aware datetime objects, and throws an error if you try to upload datapoints with such datetimes:

Can you fix this? I imagine the fix would be very simple, simply switch out the definition of the datetime_to_ms() function to:

def datetime_to_ms(dt):

    return dt.timestamp()*1000 

7 replies

Anita Hæhre
Expert ⭐️⭐️⭐️⭐️
Head of Community
Jul 28, 2022 7:26 AM UTC
Updated idea statusNew→Gathering Interest
Anita Hæhre
Lead Product Manager
Jul 28, 2022 8:56 AM UTC

@Edvard Holen It looks like, as of approx July 13th, datetime_to_ms() was updated in v3.1.0 of the Python SDK to support timezone aware datetimes.

Have you had a chance to try that version of the SDK yet?

Practitioner ⭐️⭐️⭐️
Jul 28, 2022 9:17 AM UTC

Hi @Thomas Sjølshagen, I just tested the new version of the SDK and it seems that this issue has been fixed. Great work!

Anita Hæhre
Expert ⭐️⭐️⭐️⭐️
Head of Community
Jul 28, 2022 10:56 AM UTC
Updated idea statusGathering Interest→Implemented
Anita Hæhre
Ben Brandt
Seasoned ⭐️⭐️⭐️
Seasoned ⭐️⭐️⭐️
Aug 18, 2022 2:52 PM UTC

@Thomas Sjølshagen @Anita Hæhre Was this documented as a “Breaking Change” in the SDK for anyone that may be expecting the old behavior?

Lead Product Manager
Aug 18, 2022 2:55 PM UTC

@Ben Brandt

Since we didn’t support timestamps prior to 01.01.1970 and we implemented the timestamps prior to that date as negative values, we believe it’s not a breaking change. 
 

Do you have a different experience after it was added to the API?

Lead Product Manager
Aug 18, 2022 2:58 PM UTC

And ignore that reply… *sigh* Too many moving parts, sorry!