fix: tolerate unavailable browser timezone data
All checks were successful
CI / lint (pull_request) Successful in 3m25s
CI / build-release (pull_request) Successful in 7s
CI / browser-journey (pull_request) Successful in 4m2s
CI / release-candidate (pull_request) Has been skipped

This commit is contained in:
timmy 2026-08-19 23:39:34 +00:00
parent 7deb1c1de9
commit 7c2e9861d7
2 changed files with 23 additions and 2 deletions

View File

@ -27,8 +27,15 @@ function createTomorrowPlan({fetchJson,localDate,timeZone}={}) {
function millisecondsUntilNextDay() {
const now=Date.now();
const zone=timeZone();
const formatter=new Intl.DateTimeFormat('en-CA',{timeZone:zone,year:'numeric',month:'2-digit',day:'2-digit',
let formatter;
try {
formatter=new Intl.DateTimeFormat('en-CA',{timeZone:zone,year:'numeric',month:'2-digit',day:'2-digit',
hour:'2-digit',minute:'2-digit',second:'2-digit',hourCycle:'h23'});
} catch (_error) {
const next=new Date(now);
next.setHours(24,0,0,250);
return Math.max(1,next.getTime()-now);
}
const zoned=value=>Object.fromEntries(formatter.formatToParts(new Date(value))
.filter(part=>part.type!=='literal').map(part=>[part.type,Number(part.value)]));
const current=zoned(now);

View File

@ -124,6 +124,20 @@ console.log(JSON.stringify({checks,delays:timers.map(timer=>timer.delay),cleared
assert result["cleared"] == [1, 2]
def test_tomorrow_rollover_falls_back_when_the_reported_timezone_is_invalid():
result = run_controller("""
let scheduled=null;
const planner=createTomorrowPlan({fetchJson:async()=>({}),localDate:()=> '2026-08-20',timeZone:()=> 'Etc/Unknown'});
const lifecycle=planner.startLifecycle({
check:async()=>false,setTimer:(_fn,delay)=>{scheduled=delay;return 1;},clearTimer:()=>{},
});
await lifecycle.run();
console.log(JSON.stringify({scheduled:Number.isFinite(scheduled)&&scheduled>0}));
""")
assert result == {"scheduled": True}
def test_tomorrow_plan_has_a_touch_safe_mobile_entry_and_reuses_the_ordered_planner():
index = INDEX.read_text()
css = CSS.read_text()