diff --git a/CHANGES.rst b/CHANGES.rst index a45504d5..a6c783ef 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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 ========================================= @@ -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 ========================================= diff --git a/highcharts_core/__version__.py b/highcharts_core/__version__.py index e916218b..ce34e913 100644 --- a/highcharts_core/__version__.py +++ b/highcharts_core/__version__.py @@ -1 +1 @@ -__version__ = '1.2.0' \ No newline at end of file +__version__ = '1.2.1' \ No newline at end of file diff --git a/highcharts_core/js_literal_functions.py b/highcharts_core/js_literal_functions.py index 15019c50..914fba01 100644 --- a/highcharts_core/js_literal_functions.py +++ b/highcharts_core/js_literal_functions.py @@ -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): diff --git a/highcharts_core/options/axes/plot_bands.py b/highcharts_core/options/axes/plot_bands.py index 4c276af1..b2bfabe6 100644 --- a/highcharts_core/options/axes/plot_bands.py +++ b/highcharts_core/options/axes/plot_bands.py @@ -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 diff --git a/highcharts_core/options/plot_options/series.py b/highcharts_core/options/plot_options/series.py index 9f2074b6..04a0de72 100644 --- a/highcharts_core/options/plot_options/series.py +++ b/highcharts_core/options/plot_options/series.py @@ -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 diff --git a/highcharts_core/options/plot_options/treegraph.py b/highcharts_core/options/plot_options/treegraph.py index 6d85957f..8797c8b5 100644 --- a/highcharts_core/options/plot_options/treegraph.py +++ b/highcharts_core/options/plot_options/treegraph.py @@ -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