influxdb-client-python icon indicating copy to clipboard operation
influxdb-client-python copied to clipboard

Replace deprecated call to `datetime.utcfromtimestamp`

Open cdce8p opened this issue 2 years ago • 2 comments

Proposal: Starting with Python 3.12 datetime.utcfromtimestamp will be deprecated in favor of the timezone aware datetime.fromtimestamp. https://docs.python.org/3.12/library/datetime.html#datetime.datetime.utcfromtimestamp AFAICT this only effects one instance in the active (excluding examples) code base and the fix should be pretty simple https://github.com/influxdata/influxdb-client-python/blob/1ec64b7e1039c891ac3a667ee6697731c61ddbaf/influxdb_client/client/write/point.py#L13

-    EPOCH = datetime.utcfromtimestamp(0).replace(tzinfo=timezone.utc)
+    EPOCH = datetime.fromtimestamp(0, tz=timezone.utc)

Note: datetime.utcnow() will also be deprecated in favor of datetime.now(tz=timezone.utc) but that's only used in examples or tests. https://docs.python.org/3.12/library/datetime.html#datetime.datetime.utcnow

cdce8p avatar Aug 20 '23 12:08 cdce8p

Hi @cdce8p,

thanks for using our client.

Is this something you would be willing to help with? All PR is welcome and we will be happy to review your submission.

Regards

bednar avatar Aug 21 '23 09:08 bednar

Hi @bednar, Thanks for the reply! Usually I would be happy to open a PR for it. Please understand though, that I'm not willing to sign a CLA just for a one line change. Feel free to use my suggestion from above to contribute it yourself, though.

cdce8p avatar Aug 21 '23 23:08 cdce8p