fix: tolerate invalid device timezones in Week Ahead (Closes #1177)
All checks were successful
CI / lint (pull_request) Successful in 3m19s
CI / build-release (pull_request) Successful in 8s
CI / browser-journey (pull_request) Successful in 4m30s
CI / release-candidate (pull_request) Has been skipped

This commit is contained in:
timmy 2026-08-20 12:26:35 +00:00
parent 5a9cce4a08
commit 53c4340d76
2 changed files with 19 additions and 1 deletions

View File

@ -4,7 +4,13 @@ function createTodayRollover(options = {}) {
Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC'); Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC');
function timeZone() { function timeZone() {
return options.timeZone?.() || resolvedTimeZone(); const candidate = options.timeZone?.() || resolvedTimeZone();
try {
new Intl.DateTimeFormat('en', { timeZone: candidate }).format(now());
return candidate;
} catch (_error) {
return 'UTC';
}
} }
function localDate() { function localDate() {

View File

@ -132,6 +132,18 @@ process.stdout.write(JSON.stringify({{date:rollover.localDate(),zone:rollover.ti
assert run_node(script) == {"date": "2026-11-01", "zone": "America/New_York"} assert run_node(script) == {"date": "2026-11-01", "zone": "America/New_York"}
def test_invalid_runtime_timezone_falls_back_to_utc_without_breaking_planners():
script = f"""
const create = require({json.dumps(str(ROLLOVER))});
const rollover = create({{
now:()=>new Date('2026-08-20T23:30:00Z'),
resolvedTimeZone:()=> 'Etc/Unknown'
}});
process.stdout.write(JSON.stringify({{date:rollover.localDate(),zone:rollover.timeZone()}}));
"""
assert run_node(script) == {"date": "2026-08-20", "zone": "UTC"}
def test_rollover_is_one_durable_sync_operation_with_the_server_revision(): def test_rollover_is_one_durable_sync_operation_with_the_server_revision():
script = f""" script = f"""
const createSync = require({json.dumps(str(SYNC))}); const createSync = require({json.dumps(str(SYNC))});