Adds technical date and time formatting

Adds options for technical date and time formatting and includes the option to show seconds.

Updates time formatting to use UTC-to-local conversion and ensures consistent colon separators for time values.

Adjusts all-day event handling to preserve original start/end times.
This commit is contained in:
Janus C. H. Knudsen 2025-10-03 16:05:22 +02:00
parent c8d78f472d
commit 38737762c5
7 changed files with 370 additions and 26 deletions

View file

@ -112,10 +112,10 @@ export class DateEventRenderer implements EventRendererStrategy {
/**
* Update clone timestamp based on new position
*/
private updateCloneTimestamp(clone: HTMLElement, snappedY: number): void {
private updateCloneTimestamp(payload: DragMoveEventPayload): void {
//important as events can pile up, so they will still fire after event has been converted to another rendered type
if (clone.dataset.allDay == "true") return;
if (payload.draggedClone.dataset.allDay == "true") return;
const gridSettings = calendarConfig.getGridSettings();
const hourHeight = gridSettings.hourHeight;
@ -123,7 +123,7 @@ export class DateEventRenderer implements EventRendererStrategy {
const snapInterval = gridSettings.snapInterval;
// Calculate minutes from grid start (not from midnight)
const minutesFromGridStart = (snappedY / hourHeight) * 60;
const minutesFromGridStart = (payload.snappedY / hourHeight) * 60;
// Add dayStartHour offset to get actual time
const actualStartMinutes = (dayStartHour * 60) + minutesFromGridStart;
@ -132,13 +132,13 @@ export class DateEventRenderer implements EventRendererStrategy {
const snappedStartMinutes = Math.round(actualStartMinutes / snapInterval) * snapInterval;
if (!clone.dataset.originalDuration)
if (!payload.draggedClone.dataset.originalDuration)
throw new DOMException("missing clone.dataset.originalDuration")
const endTotalMinutes = snappedStartMinutes + parseInt(clone.dataset.originalDuration);
const endTotalMinutes = snappedStartMinutes + parseInt(payload.draggedClone.dataset.originalDuration);
// Update visual time display only
const timeElement = clone.querySelector('swp-event-time');
const timeElement = payload.draggedClone.querySelector('swp-event-time');
if (timeElement) {
let startTime = TimeFormatter.formatTimeFromMinutes(snappedStartMinutes);
let endTime = TimeFormatter.formatTimeFromMinutes(endTotalMinutes);
@ -183,7 +183,7 @@ export class DateEventRenderer implements EventRendererStrategy {
this.draggedClone.style.top = (payload.snappedY - payload.mouseOffset.y) + 'px';
// Update timestamp display
this.updateCloneTimestamp(this.draggedClone, payload.snappedY);
this.updateCloneTimestamp(payload);
}