Skip to main content
Practitioner ⭐️⭐️⭐️
July 4, 2022
Implemented

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

Related products:REST API
  • July 4, 2022
  • 7 replies
  • 111 views

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
July 28, 2022
Updated idea statusNewGathering Interest
Anita Hæhre
Lead Product Manager
July 28, 2022

@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 ⭐️⭐️⭐️
July 28, 2022

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
July 28, 2022
Updated idea statusGathering InterestImplemented
Anita Hæhre
Ben Brandt
Seasoned ⭐️⭐️⭐️
Seasoned ⭐️⭐️⭐️
August 18, 2022

@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
August 18, 2022

@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
August 18, 2022

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