From 1a85f582fa360a09694e479fa38f528bae1d2527 Mon Sep 17 00:00:00 2001 From: Jacob Laursen Date: Wed, 18 Dec 2024 23:02:45 +0100 Subject: [PATCH] Use configured time-zone when converting DateTimeType to ZonedDateTime Resolves #404 Signed-off-by: Jacob Laursen --- src/time.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/time.js b/src/time.js index 9a267cd29..ce33d7e7c 100644 --- a/src/time.js +++ b/src/time.js @@ -186,7 +186,7 @@ function _convertItemRawState (rawState) { } else if (rawState instanceof StringType) { // String type Items return _parseString(rawState.toString()); } else if (rawState instanceof DateTimeType) { // DateTime Items - return javaZDTToJsZDT(rawState.getZonedDateTime()); + return javaInstantToJsInstant(rawState.getInstant()).atZone(time.ZoneId.systemDefault()); } else if (rawState instanceof QuantityType) { // Number:Time type Items return _addQuantityType(rawState); } else { @@ -288,10 +288,10 @@ function toZDT (when) { return _addMillisToNow(when.floatValue()); } - // DateTimeType, extract the javaZDT and convert to time.ZDT + // DateTimeType, extract the javaInstant and convert to time.ZDT, use the configured timezone if (when instanceof DateTimeType) { - log.debug('toZTD: Converting DateTimeType ' + when); - return javaZDTToJsZDT(when.getZonedDateTime()); + log.debug('toZDT: Converting DateTimeType ' + when); + return javaInstantToJsInstant(when.getInstant()).atZone(time.ZoneId.systemDefault()); } // Add Quantity or QuantityType