8000 Merge remote-tracking branch 'origin/master' into 0.9.0_support · DASpringate/influxdb-python@0d178b0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0d178b0

Browse files
author
aviau
committed
Merge remote-tracking branch 'origin/master' into 0.9.0_support
2 parents 7d60a3f + 1a62701 commit 0d178b0

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

influxdb/dataframe_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def _datetime_to_epoch(self, datetime, time_precision='s'):
133133
seconds = (datetime - self.EPOCH).total_seconds()
134134
if time_precision == 's':
135135
return seconds
136-
elif time_precision == 'm':
136+
elif time_precision == 'm' or time_precision == 'ms':
137137
return seconds * 1000
138138
elif time_precision == 'u':
139139
return seconds * 1000000

tests/influxdb/dataframe_client_test.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,28 @@ def test_list_series(self):
222222
cli = DataFrameClient('host', 8086, 'username', 'password', 'db')
223223
series_list = cli.get_list_series()
224224
assert series_list == ['seriesA', 'seriesB']
225+
226+
def test_datetime_to_epoch(self):
227+
timestamp = pd.Timestamp('2013-01-01 00:00:00.000+00:00')
228+
cli = DataFrameClient('host', 8086, 'username', 'password', 'db')
229+
230+
self.assertEqual(
231+
cli._datetime_to_epoch(timestamp),
232+
1356998400.0
233+
)
234+
self.assertEqual(
235+
cli._datetime_to_epoch(timestamp, time_precision='s'),
236+
1356998400.0
237+
)
238+
self.assertEqual(
239+
cli._datetime_to_epoch(timestamp, time_precision='m'),
240+
1356998400000.0
241+
)
242+
self.assertEqual(
243+
cli._datetime_to_epoch(timestamp, time_precision='ms'),
244+
1356998400000.0
245+
)
246+
self.assertEqual(
247+
cli._datetime_to_epoch(timestamp, time_precision='u'),
248+
1356998400000000.0
249+
)

0 commit comments

Comments
 (0)
0