mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Handle date range shift during daylight saving time days (#24868)
This commit is contained in:
parent
94ced8af32
commit
7893eba7a7
@ -6,6 +6,10 @@ import {
|
|||||||
differenceInMilliseconds,
|
differenceInMilliseconds,
|
||||||
differenceInMonths,
|
differenceInMonths,
|
||||||
endOfMonth,
|
endOfMonth,
|
||||||
|
startOfDay,
|
||||||
|
endOfDay,
|
||||||
|
differenceInDays,
|
||||||
|
addDays,
|
||||||
} from "date-fns";
|
} from "date-fns";
|
||||||
import { toZonedTime, fromZonedTime } from "date-fns-tz";
|
import { toZonedTime, fromZonedTime } from "date-fns-tz";
|
||||||
import type { HassConfig } from "home-assistant-js-websocket";
|
import type { HassConfig } from "home-assistant-js-websocket";
|
||||||
@ -100,6 +104,32 @@ export const shiftDateRange = (
|
|||||||
locale,
|
locale,
|
||||||
config
|
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 {
|
} else {
|
||||||
const difference =
|
const difference =
|
||||||
((calcDateDifferenceProperty(
|
((calcDateDifferenceProperty(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user