feat: add Night Shift layer (boot intro, ops strip, headlight, chapter numerals, film grain)

This commit is contained in:
2026-10-10 14:13:26 +03:00
parent 475e494675
commit d16ce88639
8 changed files with 389 additions and 0 deletions

38
src/lib/operations.ts Normal file
View File

@@ -0,0 +1,38 @@
export interface Uptime {
readonly months: number;
readonly days: number;
}
/** Whole calendar months plus remaining days since `start`, clamped to zero. */
export function uptimeSince(start: Date, now: Date): Uptime {
if (now.getTime() <= start.getTime()) return { months: 0, days: 0 };
let months = (now.getUTCFullYear() - start.getUTCFullYear()) * 12 + (now.getUTCMonth() - start.getUTCMonth());
let anchor = addMonths(start, months);
if (anchor.getTime() > now.getTime()) {
months -= 1;
anchor = addMonths(start, months);
}
const days = Math.floor((now.getTime() - anchor.getTime()) / 86_400_000);
return { months, days };
}
function addMonths(date: Date, months: number): Date {
return new Date(Date.UTC(
date.getUTCFullYear(),
date.getUTCMonth() + months,
date.getUTCDate(),
date.getUTCHours(),
date.getUTCMinutes(),
));
}
const clockFormat = new Intl.DateTimeFormat('en-GB', {
hour: '2-digit',
minute: '2-digit',
hourCycle: 'h23',
timeZone: 'Europe/Bucharest',
});
export function bucharestClock(now: Date): string {
return clockFormat.format(now);
}