Skip to main content
Implemented

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

Related products:API and SDKs
  • July 4, 2022
  • 7 replies
  • 97 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
Seasoned Practitioner
Forum|alt.badge.img+1
  • Head of Community
  • July 28, 2022
Updated idea statusNewGathering Interest

Forum|alt.badge.img

@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?


  • Author
  • Inactive
  • 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
Seasoned Practitioner
Forum|alt.badge.img+1
  • Head of Community
  • July 28, 2022
Updated idea statusGathering InterestImplemented

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?


Forum|alt.badge.img

@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?


Forum|alt.badge.img

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