Refactors date handling for ISO week compatibility

Centralizes all date calculations into a new `DateCalculator` class for better maintainability and consistency.

Ensures correct ISO week handling (Monday as the first day) throughout the calendar.

Updates `CalendarConfig` to use ISO day numbering (1-7 for Mon-Sun) for work week definitions.

Fixes issue where date calculations were inconsistent.
Enhances event rendering and navigation.
Updates navigation logic to use pre-rendered events.
Removes the need for `CONTAINER_READY_FOR_EVENTS` event.
This commit is contained in:
Janus Knudsen 2025-08-20 00:39:31 +02:00
parent efc1742dad
commit 7d513600d8
13 changed files with 230 additions and 343 deletions

View file

@ -40,10 +40,9 @@ interface DateViewSettings {
*/
interface WorkWeekSettings {
id: string;
workDays: number[]; // [1,2,3,4,5] for mon-fri
dayNames: string[]; // ['Mon','Tue','Wed','Thu','Fri']
workDays: number[]; // ISO 8601: [1,2,3,4,5] for mon-fri (1=Mon, 7=Sun)
totalDays: number; // 5
firstWorkDay: number; // 1 = Monday
firstWorkDay: number; // ISO: 1 = Monday, 7 = Sunday
}
/**
@ -442,38 +441,33 @@ export class CalendarConfig {
return {
'standard': {
id: 'standard',
workDays: [1,2,3,4,5],
dayNames: ['Mon','Tue','Wed','Thu','Fri'],
workDays: [1,2,3,4,5], // Monday-Friday (ISO)
totalDays: 5,
firstWorkDay: 1
},
'compressed': {
id: 'compressed',
workDays: [1,2,3,4],
dayNames: ['Mon','Tue','Wed','Thu'],
workDays: [1,2,3,4], // Monday-Thursday (ISO)
totalDays: 4,
firstWorkDay: 1
},
'midweek': {
id: 'midweek',
workDays: [3,4,5],
dayNames: ['Wed','Thu','Fri'],
workDays: [3,4,5], // Wednesday-Friday (ISO)
totalDays: 3,
firstWorkDay: 3
},
'weekend': {
id: 'weekend',
workDays: [6,0],
dayNames: ['Sat','Sun'],
workDays: [6,7], // Saturday-Sunday (ISO)
totalDays: 2,
firstWorkDay: 6
},
'fullweek': {
id: 'fullweek',
workDays: [0,1,2,3,4,5,6],
dayNames: ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],
workDays: [1,2,3,4,5,6,7], // Monday-Sunday (ISO)
totalDays: 7,
firstWorkDay: 0
firstWorkDay: 1
}
};
}
@ -511,6 +505,7 @@ export class CalendarConfig {
getCurrentWorkWeek(): string {
return this.currentWorkWeek;
}
}
// Create singleton instance