Default the initial hour to local time of day instead of always Prime
Deploy / deploy (push) Successful in 1m18s

Visiting the app with no hour in the URL previously always showed
Prime for today, since selectedHour was hardcoded in AppState. Now it
picks the hour whose band contains the visitor's local clock time.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L3wxvz3mPXiHxkPB5JpnmD
This commit is contained in:
2026-08-21 06:50:42 -04:00
parent 9e6b36bed9
commit 945c5ef109
2 changed files with 53 additions and 1 deletions
+14 -1
View File
@@ -16,9 +16,22 @@ export function todayIso(): string {
return `${yyyy}-${mm}-${dd}`;
}
/** Which hour to default to when the URL doesn't specify one, based on local wall-clock time. */
export function defaultHourForTime(date: Date): HourId {
const h = date.getHours();
if (h < 6) return 'matins';
if (h < 8) return 'lauds';
if (h < 9) return 'prime';
if (h < 12) return 'terce';
if (h < 15) return 'sext';
if (h < 17) return 'none';
if (h < 21) return 'vespers';
return 'compline';
}
const state: AppState = {
date: todayIso(),
selectedHour: 'prime',
selectedHour: defaultHourForTime(new Date()),
languages: ['en'],
};