Skip to content

Fix DateTime with ZoneId unpacking #1097

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

Merged
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ function getTimeInZoneId (timeZoneId, epochSecond, nano) {
currentValue.value.toUpperCase() === 'B'
? year => year.subtract(1).negate() // 1BC equals to year 0 in astronomical year numbering
: identity
} 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
7 changes: 7 additions & 0 deletions packages/bolt-connection/test/bolt/bolt-protocol-v4x4.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,13 @@ describe('#unit BoltProtocolV4x4', () => {
1655212878, 183_000_000, 'Australia/Eucla'
]),
new DateTime(2022, 6, 14, 22, 6, 18, 183_000_000, 8 * 60 * 60 + 45 * 60, 'Australia/Eucla')
],
[
'DateTimeWithZoneId / Midnight',
new structure.Structure(0x69, [
1685397950, 183_000_000, 'Europe/Berlin'
]),
new DateTime(2023, 5, 30, 0, 5, 50, 183_000_000, 2 * 60 * 60, 'Europe/Berlin')
]
])('should unpack temporal types (%s)', (_, struct, object) => {
const packable = protocol.packable(struct)
Expand Down
7 changes: 7 additions & 0 deletions packages/bolt-connection/test/bolt/bolt-protocol-v5x0.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,13 @@ describe('#unit BoltProtocolV5x0', () => {
1592231400, 183_000_000, 'Pacific/Honolulu'
]),
new DateTime(2020, 6, 15, 4, 30, 0, 183_000_000, -10 * 60 * 60, 'Pacific/Honolulu')
],
[
'DateTimeWithZoneId / Midnight',
new structure.Structure(0x69, [
1685397950, 183_000_000, 'Europe/Berlin'
]),
new DateTime(2023, 5, 30, 0, 5, 50, 183_000_000, 2 * 60 * 60, 'Europe/Berlin')
]
])('should unpack spatial types and temporal types (%s)', (_, struct, object) => {
const buffer = alloc(256)
Expand Down
7 changes: 7 additions & 0 deletions packages/bolt-connection/test/bolt/bolt-protocol-v5x1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,13 @@ describe('#unit BoltProtocolV5x1', () => {
1592231400, 183_000_000, 'Pacific/Honolulu'
]),
new DateTime(2020, 6, 15, 4, 30, 0, 183_000_000, -10 * 60 * 60, 'Pacific/Honolulu')
],
[
'DateTimeWithZoneId / Midnight',
new structure.Structure(0x69, [
1685397950, 183_000_000, 'Europe/Berlin'
]),
new DateTime(2023, 5, 30, 0, 5, 50, 183_000_000, 2 * 60 * 60, 'Europe/Berlin')
]
])('should unpack spatial types and temporal types (%s)', (_, struct, object) => {
const buffer = alloc(256)
Expand Down
7 changes: 7 additions & 0 deletions packages/bolt-connection/test/bolt/bolt-protocol-v5x2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,13 @@ describe('#unit BoltProtocolV5x2', () => {
1592231400, 183_000_000, 'Pacific/Honolulu'
]),
new DateTime(2020, 6, 15, 4, 30, 0, 183_000_000, -10 * 60 * 60, 'Pacific/Honolulu')
],
[
'DateTimeWithZoneId / Midnight',
new structure.Structure(0x69, [
1685397950, 183_000_000, 'Europe/Berlin'
]),
new DateTime(2023, 5, 30, 0, 5, 50, 183_000_000, 2 * 60 * 60, 'Europe/Berlin')
]
])('should unpack spatial types and temporal types (%s)', (_, struct, object) => {
const buffer = alloc(256)
Expand Down
7 changes: 7 additions & 0 deletions packages/bolt-connection/test/bolt/bolt-protocol-v5x3.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,13 @@ describe('#unit BoltProtocolV5x3', () => {
1592231400, 183_000_000, 'Pacific/Honolulu'
]),
new DateTime(2020, 6, 15, 4, 30, 0, 183_000_000, -10 * 60 * 60, 'Pacific/Honolulu')
],
[
'DateTimeWithZoneId / Midnight',
new structure.Structure(0x69, [
1685397950, 183_000_000, 'Europe/Berlin'
]),
new DateTime(2023, 5, 30, 0, 5, 50, 183_000_000, 2 * 60 * 60, 'Europe/Berlin')
]
])('should unpack spatial types and temporal types (%s)', (_, struct, object) => {
const buffer = alloc(256)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ function getTimeInZoneId (timeZoneId, epochSecond, nano) {
currentValue.value.toUpperCase() === 'B'
? year => year.subtract(1).negate() // 1BC equals to year 0 in astronomical year numbering
: identity
} 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