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
|
|
@ -32,17 +32,18 @@ export class DateColumnRenderer implements ColumnRenderer {
|
|||
const { currentWeek, config } = context;
|
||||
|
||||
// Initialize date calculator and work hours manager
|
||||
this.dateCalculator = new DateCalculator(config);
|
||||
DateCalculator.initialize(config);
|
||||
this.dateCalculator = new DateCalculator();
|
||||
this.workHoursManager = new WorkHoursManager(config);
|
||||
|
||||
const dates = this.dateCalculator.getWorkWeekDates(currentWeek);
|
||||
const dates = DateCalculator.getWorkWeekDates(currentWeek);
|
||||
const dateSettings = config.getDateViewSettings();
|
||||
const daysToShow = dates.slice(0, dateSettings.weekDays);
|
||||
|
||||
|
||||
daysToShow.forEach((date) => {
|
||||
const column = document.createElement('swp-day-column');
|
||||
(column as any).dataset.date = this.dateCalculator.formatISODate(date);
|
||||
(column as any).dataset.date = DateCalculator.formatISODate(date);
|
||||
|
||||
// Apply work hours styling
|
||||
this.applyWorkHoursToColumn(column, date);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue