Skip to content

Commit 0436752

Browse files
authored
Fix DateTime with ZoneId unpacking (#1098)
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.
1 parent 6fb7fff commit 0436752

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

packages/bolt-connection/src/packstream/packstream-utc.js

+2
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ export function packDateTime (value, packer) {
279279
currentValue.value.toUpperCase() === 'B'
280280
? year => year.subtract(1).negate() // 1BC equals to year 0 in astronomical year numbering
281281
: year => year
282+
} else if (currentValue.type === 'hour') {
283+
obj.hour = int(currentValue.value).modulo(24)
282284
} else if (currentValue.type !== 'literal') {
283285
obj[currentValue.type] = int(currentValue.value)
284286
}

0 commit comments

Comments
 (0)