fix: tolerate invalid device timezones in Week Ahead (Closes #1177)
This commit is contained in:
parent
5a9cce4a08
commit
53c4340d76
|
|
@ -4,7 +4,13 @@ function createTodayRollover(options = {}) {
|
|||
Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC');
|
||||
|
||||
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() {
|
||||
|
|
|
|||
|
|
@ -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"}
|
||||
|
||||
|
||||
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():
|
||||
script = f"""
|
||||
const createSync = require({json.dumps(str(SYNC))});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user