diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e7aa49..4716440 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ 1. [#92](https://github.com/InfluxCommunity/influxdb3-python/pull/92): Update `user-agent` header value to `influxdb3-python/{VERSION}` and add it to queries as well. +### Bug Fixes + +1. [#86](https://github.com/InfluxCommunity/influxdb3-python/pull/86): Refactor to `timezone` specific `datetime` helpers to avoid use deprecated functions + ## 0.5.0 [2024-05-17] ### Features @@ -24,7 +28,7 @@ ``` -### Bugfix +### Bug Fixes 1. [#87](https://github.com/InfluxCommunity/influxdb3-python/pull/87): Fix examples to use `write_options` instead of the object name `WriteOptions` diff --git a/influxdb_client_3/write_client/client/write/point.py b/influxdb_client_3/write_client/client/write/point.py index e65aee6..bc7211d 100644 --- a/influxdb_client_3/write_client/client/write/point.py +++ b/influxdb_client_3/write_client/client/write/point.py @@ -10,7 +10,7 @@ from influxdb_client_3.write_client.client.util.date_utils import get_date_helper from influxdb_client_3.write_client.domain.write_precision import WritePrecision -EPOCH = datetime.utcfromtimestamp(0).replace(tzinfo=timezone.utc) +EPOCH = datetime.fromtimestamp(0, tz=timezone.utc) DEFAULT_WRITE_PRECISION = WritePrecision.NS diff --git a/tests/test_point.py b/tests/test_point.py new file mode 100644 index 0000000..1559b62 --- /dev/null +++ b/tests/test_point.py @@ -0,0 +1,14 @@ +import datetime +import unittest + +from influxdb_client_3.write_client.client.write.point import EPOCH, Point + + +class TestPoint(unittest.TestCase): + + def test_epoch(self): + self.assertEqual(EPOCH, datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)) + + def test_point(self): + point = Point.measurement("h2o").tag("location", "europe").field("level", 2.2).time(1_000_000) + self.assertEqual('h2o,location=europe level=2.2 1000000', point.to_line_protocol())