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

Related products: API and SDKs

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 

Updated idea statusNewGathering Interest

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


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


Updated idea statusGathering InterestImplemented

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


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


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