Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: to timezone specific datetime helpers to avoid use deprecated functions #86

Merged
merged 7 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`

Expand Down
2 changes: 1 addition & 1 deletion influxdb_client_3/write_client/client/write/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions tests/test_point.py
Original file line number Diff line number Diff line change
@@ -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())
Loading