Manage application time, date, and Bell schedule integration
The clock store manages the application’s current time and date, integrating with the Bell schedule system to provide real-time period information and countdown timers.
The current application date, calculated by adding the elapsed time since startTime to urlDate. In 'day' mode, returns the date normalized to midnight (0:00).
Implementation Details
const date = computed((): Date => { const d = new Date(urlDate.value.getTime() + (currentTime.value - startTime.value)); if (clockMode.value === 'current') return d; const normalized = new Date(d); normalized.setHours(0, 0, 0, 0); return normalized;});
A Bell instance for the current date, automatically updated with the current schedules and selected schedule mode. This provides access to period information, countdown timers, and schedule data.
const bell = computed((): Bell => { return new Bell(date.value, scheduleStore.schedules, scheduleStore.scheduleMode);});
function pageLoaded(route: RouteLocationNormalized): void
Initializes the clock when a page loads. Sets the start time, starts the clock interval, determines the mode from route parameters, and parses the date/time from the URL.
The clock store is initialized on page load and maintains a 1-second update interval when in 'current' mode. Always call pageLoaded() in your component’s onMounted hook.