Skip to content

Commit a030485

Browse files
authored
refactor: to timezone specific datetime helpers to avoid use deprecated functions (#86)
1 parent 18cec22 commit a030485

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
1. [#89](https://github.com/InfluxCommunity/influxdb3-python/pull/89): Use `datetime.fromisoformat` over `dateutil.parse` in Python 3.11+
88
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.
99

10+
### Bug Fixes
11+
12+
1. [#86](https://github.com/InfluxCommunity/influxdb3-python/pull/86): Refactor to `timezone` specific `datetime` helpers to avoid use deprecated functions
13+
1014
## 0.5.0 [2024-05-17]
1115

1216
### Features
@@ -25,7 +29,7 @@
2529

2630
```
2731

28-
### Bugfix
32+
### Bug Fixes
2933

3034
1. [#87](https://github.com/InfluxCommunity/influxdb3-python/pull/87): Fix examples to use `write_options` instead of the object name `WriteOptions`
3135

influxdb_client_3/write_client/client/write/point.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from influxdb_client_3.write_client.client.util.date_utils import get_date_helper
1111
from influxdb_client_3.write_client.domain.write_precision import WritePrecision
1212

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

1515
DEFAULT_WRITE_PRECISION = WritePrecision.NS
1616

tests/test_point.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import datetime
2+
import unittest
3+
4+
from influxdb_client_3.write_client.client.write.point import EPOCH, Point
5+
6+
7+
class TestPoint(unittest.TestCase):
8+
9+
def test_epoch(self):
10+
self.assertEqual(EPOCH, datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc))
11+
12+
def test_point(self):
13+
point = Point.measurement("h2o").tag("location", "europe").field("level", 2.2).time(1_000_000)
14+
self.assertEqual('h2o,location=europe level=2.2 1000000', point.to_line_protocol())

0 commit comments

Comments
 (0)