Skip to content

Commit

Permalink
Fix DateTime with ZoneId unpacking (#1098)
Browse files Browse the repository at this point in the history
The timezone offset was miss-calculated because of an error on extracting timezone information when the hour equals to `0`.
The problems happens because `Intl.DateTimeFormat` when configured with `hour12: false` returns `0` hour as `24`.

The solution for this is convert `24` to `0` before calculate the `offset`.

NOTE:
Other valid solution would be change `hourCycle` to `h23`.
However, this solution is not supported by all javascript environment.
  • Loading branch information
bigmontz authored Jun 16, 2023
1 parent 6fb7fff commit 0436752
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/bolt-connection/src/packstream/packstream-utc.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ export function packDateTime (value, packer) {
currentValue.value.toUpperCase() === 'B'
? year => year.subtract(1).negate() // 1BC equals to year 0 in astronomical year numbering
: year => year
} else if (currentValue.type === 'hour') {
obj.hour = int(currentValue.value).modulo(24)
} else if (currentValue.type !== 'literal') {
obj[currentValue.type] = int(currentValue.value)
}
Expand Down

0 comments on commit 0436752

Please sign in to comment.