Skip to content
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ Setup `index.js` with your new class, and edit `test.js` to test your destinatio
* SixFlags
* HansaPark
* Knoebels
* OceanParkHongKong
<!-- END_DESTINATIONS -->

## Configuration
Expand Down
3 changes: 2 additions & 1 deletion TODO.MD
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
- Universal Studios Singapore (USS)
- Lotte World
- Chimelong: Guangzhou + Zhuhai (2 destinations)
- Ocean Park Hong Kong: Auth token, coordinate affine transform, showtimes, park schedule

**Totals: ~118 destinations, 1068 tests, 45 test files**
**Totals: ~119 destinations, 1068 tests, 45 test files**

## Remaining Migrations

Expand Down
8 changes: 5 additions & 3 deletions src/__tests__/datetime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,11 @@ describe('DateTime Utilities', () => {
expect(formatted1).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/);
expect(formatted2).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/);

// Verify timezone offsets are included
expect(formatted1).toMatch(/(-5|GMT-5)/); // EST
expect(formatted2).toMatch(/(-4|GMT-4)/); // EDT
// Verify timezone offsets are included. formatInTimezone normalizes
// GMT-style offsets to the canonical RFC 3339 "-HH:MM" form; accept
// both shapes to keep the test resilient if the helper changes.
expect(formatted1).toMatch(/(-05:00|-5|GMT-5)/); // EST
expect(formatted2).toMatch(/(-04:00|-4|GMT-4)/); // EDT
});

test('should handle midnight correctly', () => {
Expand Down
17 changes: 16 additions & 1 deletion src/datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,22 @@ export function formatInTimezone(
const hour = parts.find(p => p.type === 'hour')?.value;
const minute = parts.find(p => p.type === 'minute')?.value;
const second = parts.find(p => p.type === 'second')?.value;
const offset = parts.find(p => p.type === 'timeZoneName')?.value || 'Z';
const rawOffset = parts.find(p => p.type === 'timeZoneName')?.value || 'Z';

// Intl.DateTimeFormat's `shortOffset` value is locale-dependent: for some
// timezones (e.g. Asia/Hong_Kong, Europe/Paris in summer) it returns a
// GMT-prefixed form like "GMT+8" or "GMT+2" rather than the RFC 3339
// "+HH:MM" form. Normalize so callers always get a valid ISO 8601 string.
let offset = rawOffset;
if (rawOffset === 'GMT' || rawOffset === 'UTC' || rawOffset === 'Z') {
offset = '+00:00';
} else {
const gmtMatch = rawOffset.match(/^GMT([+-])(\d{1,2})(?::(\d{2}))?$/);
if (gmtMatch) {
const [, sign, h, m = '00'] = gmtMatch;
offset = `${sign}${h.padStart(2, '0')}:${m}`;
}
}

return `${year}-${month}-${day}T${hour}:${minute}:${second}${offset}`;
}
Expand Down
Loading