Skip to content

Commit d86da20

Browse files
committed
Updated serialization of datetime to milliseconds rather than seconds. Closes #61.
1 parent dc4c280 commit d86da20

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

highcharts_core/js_literal_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def serialize_to_js_literal(item, encoding = 'utf-8') -> Optional[str]:
4949
elif checkers.is_datetime(item):
5050
if not item.tzinfo:
5151
item = item.replace(tzinfo = datetime.timezone.utc)
52-
return item.timestamp()
52+
return item.timestamp()*1000
5353
elif checkers.is_date(item):
5454
return f'Date.UTC({item.year}, {item.month - 1}, {item.day})'
5555
elif checkers.is_time(item):

highcharts_core/options/plot_options/series.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,10 +797,10 @@ def point_start(self, value):
797797
value = validators.datetime(value)
798798

799799
if hasattr(value, 'timestamp') and value.tzinfo is not None:
800-
self._point_start = value.timestamp()
800+
self._point_start = value.timestamp()*1000
801801
elif hasattr(value, 'timestamp'):
802802
value = value.replace(tzinfo = datetime.timezone.utc)
803-
value = value.timestamp()
803+
value = value.timestamp()*1000
804804
else:
805805
raise error
806806

highcharts_core/options/plot_options/treegraph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,10 +491,10 @@ def point_start(self, value):
491491
value = validators.datetime(value)
492492

493493
if hasattr(value, 'timestamp') and value.tzinfo is not None:
494-
self._point_start = value.timestamp()
494+
self._point_start = value.timestamp()*1000
495495
elif hasattr(value, 'timestamp'):
496496
value = value.replace(tzinfo = datetime.timezone.utc)
497-
value = value.timestamp()
497+
value = value.timestamp()*1000
498498
else:
499499
raise error
500500

0 commit comments

Comments
 (0)