Refactors date handling with DateService
Replaces DateCalculator with DateService for improved date and time operations, including timezone handling. This change enhances the calendar's accuracy and flexibility in managing dates, especially concerning timezone configurations. It also corrects a typo in the `allDay` dataset attribute.
This commit is contained in:
parent
4859f42450
commit
6bbf2d8adb
17 changed files with 159 additions and 749 deletions
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import { CalendarEvent } from '../types/CalendarTypes';
|
||||
import { calendarConfig } from '../core/CalendarConfig';
|
||||
import { DateCalculator } from '../utils/DateCalculator';
|
||||
import { eventBus } from '../core/EventBus';
|
||||
import { OverlapDetector, OverlapResult } from '../utils/OverlapDetector';
|
||||
import { SwpEventElement } from '../elements/SwpEventElement';
|
||||
|
|
@ -38,18 +37,13 @@ export interface EventRendererStrategy {
|
|||
*/
|
||||
export class DateEventRenderer implements EventRendererStrategy {
|
||||
|
||||
private dateService: DateService;
|
||||
|
||||
constructor(dateCalculator?: DateCalculator) {
|
||||
|
||||
if (!dateCalculator) {
|
||||
DateCalculator.initialize(calendarConfig);
|
||||
}
|
||||
this.dateCalculator = dateCalculator || new DateCalculator();
|
||||
|
||||
|
||||
constructor() {
|
||||
const timezone = calendarConfig.getTimezone?.() || 'Europe/Copenhagen';
|
||||
this.dateService = new DateService(timezone);
|
||||
this.setupDragEventListeners();
|
||||
}
|
||||
private dateCalculator: DateCalculator;
|
||||
|
||||
private draggedClone: HTMLElement | null = null;
|
||||
private originalEvent: HTMLElement | null = null;
|
||||
|
|
@ -634,10 +628,9 @@ export class DateEventRenderer implements EventRendererStrategy {
|
|||
}
|
||||
|
||||
const columnEvents = events.filter(event => {
|
||||
const eventDateStr = DateCalculator.formatISODate(event.start);
|
||||
const eventDateStr = this.dateService.formatISODate(event.start);
|
||||
const matches = eventDateStr === columnDate;
|
||||
|
||||
|
||||
return matches;
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue