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

PR for v.1.2.1 #62

Merged
merged 4 commits into from
Jun 10, 2023
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
10 changes: 10 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Release 1.2.1
=========================================

* **ENHANCEMENT:** Added autoconversion of ``plotLine.value`` from ``datetime.datetime`` to POSIX timestamp (#58).
* **BUGFIX:** Fixed incorrect ``datetime`` serialization to SECONDS from Unix epoch. Now serializing to JS-compatible MILLISECONDS from Unix epoch (#61).

------------------

Release 1.2.0
=========================================

Expand Down Expand Up @@ -25,6 +33,8 @@ Release 1.1.1
* **FIXED:** Problem when producing a JS literal, with the JS code inserting an unnecessary ``new`` (#42 and #43).
* **ENHANCEMENT:** Added more elegant error handling when something goes wrong displaying a chart in Jupyter (#43).

-------------

Release 1.1.0
=========================================

Expand Down
2 changes: 1 addition & 1 deletion highcharts_core/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.2.0'
__version__ = '1.2.1'
2 changes: 1 addition & 1 deletion highcharts_core/js_literal_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def serialize_to_js_literal(item, encoding = 'utf-8') -> Optional[str]:
elif checkers.is_datetime(item):
if not item.tzinfo:
item = item.replace(tzinfo = datetime.timezone.utc)
return item.timestamp()
return item.timestamp()*1000
elif checkers.is_date(item):
return f'Date.UTC({item.year}, {item.month - 1}, {item.day})'
elif checkers.is_time(item):
Expand Down
3 changes: 3 additions & 0 deletions highcharts_core/options/axes/plot_bands.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ def value(self) -> Optional[int | float | Decimal]:

@value.setter
def value(self, value):
if hasattr(value, 'timestamp'):
value = value.timestamp() * 1000

self._value = validators.numeric(value, allow_empty = True)

@property
Expand Down
4 changes: 2 additions & 2 deletions highcharts_core/options/plot_options/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,10 +797,10 @@ def point_start(self, value):
value = validators.datetime(value)

if hasattr(value, 'timestamp') and value.tzinfo is not None:
self._point_start = value.timestamp()
self._point_start = value.timestamp()*1000
elif hasattr(value, 'timestamp'):
value = value.replace(tzinfo = datetime.timezone.utc)
value = value.timestamp()
value = value.timestamp()*1000
else:
raise error

Expand Down
4 changes: 2 additions & 2 deletions highcharts_core/options/plot_options/treegraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,10 +491,10 @@ def point_start(self, value):
value = validators.datetime(value)

if hasattr(value, 'timestamp') and value.tzinfo is not None:
self._point_start = value.timestamp()
self._point_start = value.timestamp()*1000
elif hasattr(value, 'timestamp'):
value = value.replace(tzinfo = datetime.timezone.utc)
value = value.timestamp()
value = value.timestamp()*1000
else:
raise error

Expand Down