mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-12 18:22:16 +01:00
Fix DST-related timezone offset when creating/resizing/dragging calendar
events
This commit is contained in:
@@ -147,6 +147,18 @@ export function getLocalizedDayJs(timestamp?: string | null) {
|
||||
return dayjs.utc(timestamp).tz(getUserTimezone());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a dayjs instance for a specific wall-clock time on a given day.
|
||||
* Sets hour/minute directly to avoid DST issues with .add() on transition days.
|
||||
*/
|
||||
export function getLocalizedDayJsFromMinutes(dayStr: string, minutesFromMidnight: number) {
|
||||
return dayjs
|
||||
.tz(`${dayStr}T00:00:00`, getUserTimezone())
|
||||
.hour(Math.floor(minutesFromMidnight / 60))
|
||||
.minute(Math.round(minutesFromMidnight % 60))
|
||||
.second(0);
|
||||
}
|
||||
|
||||
export function getLocalizedDateFromTimestamp(timestamp: string) {
|
||||
return getLocalizedDayJs(timestamp).format('YYYY-MM-DD');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user