From dffcb0ec03caea7c325952a65cdb39a57d7560c0 Mon Sep 17 00:00:00 2001 From: Antonio Barcelos Date: Fri, 16 Jun 2023 13:02:31 +0200 Subject: [PATCH] Fix DateTime with ZoneId unpacking 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. --- packages/bolt-connection/src/packstream/packstream-utc.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/bolt-connection/src/packstream/packstream-utc.js b/packages/bolt-connection/src/packstream/packstream-utc.js index ba202ce3d..bd29b6a9a 100644 --- a/packages/bolt-connection/src/packstream/packstream-utc.js +++ b/packages/bolt-connection/src/packstream/packstream-utc.js @@ -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) }