Skip to content

Commit 77bd54a

Browse files
committed
fix: fix bug for timelineweek and day views
1 parent 2891546 commit 77bd54a

2 files changed

Lines changed: 32 additions & 13 deletions

File tree

packages/devextreme/js/__internal/scheduler/view_model/generate_view_model/options/get_minutes_cell_intervals.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import timeZoneUtils from '../../../m_utils_time_zone';
12
import { splitIntervalByDay } from '../../common/split_interval_by_days';
23
import type { CellInterval, DateInterval } from '../../types';
34

@@ -17,16 +18,16 @@ const filterBySkippedDays = <T extends DateInterval>(
1718
return !skippedDays.includes(weekday);
1819
});
1920

20-
const isFirstMidnightDSTInterval = (interval: DateInterval, dayInterval: DateInterval): boolean => {
21-
const intervalMin = new Date(interval.min);
22-
const dayIntervalMin = new Date(dayInterval.min);
21+
const getFirstAvailableDayTime = (
22+
dayInterval: DateInterval,
23+
startDayHour: number,
24+
): number => {
25+
const date = timeZoneUtils.createDateFromUTCWithLocalOffset(new Date(dayInterval.min));
26+
const isMidnightDST = startDayHour === 0 && timeZoneUtils.isLocalTimeMidnightDST(date);
2327

24-
return interval.min > dayInterval.min
25-
&& intervalMin.getUTCHours() === 1
26-
&& dayIntervalMin.getUTCHours() === 0
27-
&& intervalMin.getUTCFullYear() === dayIntervalMin.getUTCFullYear()
28-
&& intervalMin.getUTCMonth() === dayIntervalMin.getUTCMonth()
29-
&& intervalMin.getUTCDate() === dayIntervalMin.getUTCDate();
28+
return isMidnightDST
29+
? dayInterval.min + date.getHours() * 60 * 60 * 1000
30+
: dayInterval.min;
3031
};
3132

3233
export const getMinutesCellIntervals = ({
@@ -42,10 +43,9 @@ export const getMinutesCellIntervals = ({
4243

4344
let columnIndex = 0;
4445
filterBySkippedDays(dayIntervals, skippedDays).forEach((dayInterval) => {
45-
const isFirstDSTInterval = isFirstMidnightDSTInterval(interval, dayInterval);
46-
const intervalMin = isFirstDSTInterval ? interval.min : dayInterval.min;
47-
const intervalMax = isFirstDSTInterval
48-
? Math.min(dayInterval.max, interval.max) : dayInterval.max;
46+
const firstAvailableDayTime = getFirstAvailableDayTime(dayInterval, startDayHour);
47+
const intervalMin = Math.max(firstAvailableDayTime, interval.min);
48+
const intervalMax = Math.min(dayInterval.max, interval.max);
4949
const date = new Date(intervalMin);
5050
while (date.getTime() < intervalMax) {
5151
const min = date.getTime();

packages/devextreme/js/__internal/scheduler/view_model/generate_view_model/options/get_week_intervals.cairo.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,23 @@ describe('getWeekIntervals', () => {
2626
cellIndex: 0,
2727
});
2828
});
29+
30+
it('T1327394: should not add a timeline week cell before the first available local time on midnight DST', () => {
31+
const intervals = getWeekIntervals({
32+
startDayHour: 0,
33+
endDayHour: 24,
34+
min: Date.UTC(2026, 3, 20),
35+
max: Date.UTC(2026, 3, 27),
36+
skippedDays: [],
37+
}, 60, 0, true);
38+
39+
expect(intervals.cells.find((cell) => cell.min === Date.UTC(2026, 3, 24))).toBeUndefined();
40+
expect(intervals.cells.find((cell) => cell.min === Date.UTC(2026, 3, 24, 1))).toEqual({
41+
min: Date.UTC(2026, 3, 24, 1),
42+
max: Date.UTC(2026, 3, 24, 2),
43+
rowIndex: 0,
44+
columnIndex: 96,
45+
cellIndex: 96,
46+
});
47+
});
2948
});

0 commit comments

Comments
 (0)