Skip to content

Commit 63e8c43

Browse files
Merge pull request #464 from spokodev/fix/lord-howe-half-hour-dst
fix(timezone): half-hour DST shift for Australia/Lord_Howe
2 parents f600c99 + 9ab7a91 commit 63e8c43

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

src/timezone/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,14 @@ const timezone = s => {
6565
//(these variable names are north-centric)
6666
const summer = found.offset // (july)
6767
let winter = summer // (january) assume it's the same for now
68+
//most zones shift by 1hr on dst, but Lord Howe is a ½-hour shift
69+
const dstShift = tz === 'australia/lord_howe' ? 0.5 : 1
6870
if (result.hasDst === true) {
6971
if (result.hemisphere === 'North') {
70-
winter = summer - 1
72+
winter = summer - dstShift
7173
} else {
7274
//southern hemisphere
73-
winter = found.offset + 1
75+
winter = found.offset + dstShift
7476
}
7577
}
7678

test/dst-south.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,28 @@ test('south-increment-nov', (t) => {
5959
})
6060
t.end()
6161
})
62+
63+
// oracle: native Intl offset (minutes) for a UTC instant
64+
function intlOffsetMin(tz, utcISO) {
65+
const v = new Intl.DateTimeFormat('en-US', { timeZone: tz, timeZoneName: 'longOffset' })
66+
.formatToParts(new Date(utcISO))
67+
.find((x) => x.type === 'timeZoneName').value // e.g. 'GMT+11:00'
68+
const m = v.match(/GMT([+-])(\d{2}):(\d{2})/)
69+
if (!m) return 0
70+
const sign = m[1] === '-' ? -1 : 1
71+
return sign * (+m[2] * 60 + +m[3])
72+
}
73+
74+
test('Lord Howe half-hour DST offset', (t) => {
75+
const tz = 'Australia/Lord_Howe'
76+
// January = southern summer = DST on. Intl: +11:00 (660 min).
77+
const janUTC = '2026-01-15T00:00:00Z'
78+
const jan = spacetime(new Date(janUTC).getTime(), tz)
79+
t.equal(jan.offset(), intlOffsetMin(tz, janUTC), 'Lord Howe January offset matches Intl (+11:00)')
80+
81+
// July = southern winter = standard. Intl: +10:30 (630 min).
82+
const julUTC = '2026-07-15T00:00:00Z'
83+
const jul = spacetime(new Date(julUTC).getTime(), tz)
84+
t.equal(jul.offset(), intlOffsetMin(tz, julUTC), 'Lord Howe July offset matches Intl (+10:30)')
85+
t.end()
86+
})

0 commit comments

Comments
 (0)