Skip to content

Commit

Permalink
refactor: to timezone specific datetime helpers to avoid use depr…
Browse files Browse the repository at this point in the history
…ecated functions (#86)
  • Loading branch information
bednar authored Jun 12, 2024
1 parent 18cec22 commit a030485
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
1. [#89](https://github.com/InfluxCommunity/influxdb3-python/pull/89): Use `datetime.fromisoformat` over `dateutil.parse` in Python 3.11+
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 @@ -25,7 +29,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())

0 comments on commit a030485

Please sign in to comment.