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

Use configured time-zone when converting DateTimeType to ZonedDateTime #408

Merged
merged 1 commit into from
Dec 23, 2024
Merged
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
8 changes: 4 additions & 4 deletions src/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
florian-h05 marked this conversation as resolved.
Show resolved Hide resolved
} else if (rawState instanceof QuantityType) { // Number:Time type Items
return _addQuantityType(rawState);
} else {
Expand Down Expand Up @@ -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<Time> to now
Expand Down
Loading