mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Handle date range shift during daylight saving time days (#24868)
This commit is contained in:
parent
40c200a172
commit
6017d82c21
@ -6,6 +6,10 @@ import {
|
||||
differenceInMilliseconds,
|
||||
differenceInMonths,
|
||||
endOfMonth,
|
||||
startOfDay,
|
||||
endOfDay,
|
||||
differenceInDays,
|
||||
addDays,
|
||||
} from "date-fns";
|
||||
import { toZonedTime, fromZonedTime } from "date-fns-tz";
|
||||
import type { HassConfig } from "home-assistant-js-websocket";
|
||||
@ -100,6 +104,32 @@ export const shiftDateRange = (
|
||||
locale,
|
||||
config
|
||||
);
|
||||
} else if (
|
||||
calcDateProperty(
|
||||
startDate,
|
||||
(date) => startOfDay(date).getMilliseconds() === date.getMilliseconds(),
|
||||
locale,
|
||||
config
|
||||
) &&
|
||||
calcDateProperty(
|
||||
endDate,
|
||||
(date) => endOfDay(date).getMilliseconds() === date.getMilliseconds(),
|
||||
locale,
|
||||
config
|
||||
)
|
||||
) {
|
||||
const difference =
|
||||
((calcDateDifferenceProperty(
|
||||
endDate,
|
||||
startDate,
|
||||
differenceInDays,
|
||||
locale,
|
||||
config
|
||||
) as number) +
|
||||
1) *
|
||||
(forward ? 1 : -1);
|
||||
start = calcDate(startDate, addDays, locale, config, difference);
|
||||
end = calcDate(endDate, addDays, locale, config, difference);
|
||||
} else {
|
||||
const difference =
|
||||
((calcDateDifferenceProperty(
|
||||
|
Loading…
x
Reference in New Issue
Block a user