Refactors DateCalculator to be a static class
This change refactors the DateCalculator class to be a static class. This removes the need to instantiate DateCalculator in multiple managers and renderers, simplifying dependency management and ensuring consistent date calculations across the application. The configuration is now initialized once at the application start.
This commit is contained in:
parent
0da875a224
commit
b8b44ddae8
11 changed files with 107 additions and 83 deletions
|
|
@ -39,7 +39,8 @@ export class WorkHoursManager {
|
|||
|
||||
constructor(config: CalendarConfig) {
|
||||
this.config = config;
|
||||
this.dateCalculator = new DateCalculator(config);
|
||||
DateCalculator.initialize(config);
|
||||
this.dateCalculator = new DateCalculator();
|
||||
|
||||
// Default work schedule - will be loaded from JSON later
|
||||
this.workSchedule = {
|
||||
|
|
@ -64,7 +65,7 @@ export class WorkHoursManager {
|
|||
* Get work hours for a specific date
|
||||
*/
|
||||
getWorkHoursForDate(date: Date): DayWorkHours | 'off' {
|
||||
const dateString = this.dateCalculator.formatISODate(date);
|
||||
const dateString = DateCalculator.formatISODate(date);
|
||||
|
||||
// Check for date-specific override first
|
||||
if (this.workSchedule.dateOverrides[dateString]) {
|
||||
|
|
@ -83,7 +84,7 @@ export class WorkHoursManager {
|
|||
const workHoursMap = new Map<string, DayWorkHours | 'off'>();
|
||||
|
||||
dates.forEach(date => {
|
||||
const dateString = this.dateCalculator.formatISODate(date);
|
||||
const dateString = DateCalculator.formatISODate(date);
|
||||
const workHours = this.getWorkHoursForDate(date);
|
||||
workHoursMap.set(dateString, workHours);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue