Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/devextreme/js/__internal/scheduler/m_utils_time_zone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,18 @@ const isLocalTimeMidnightDST = (date: Date): boolean => {
return startDayDate.getHours() === 1;
};

const adjustDayIntervalMinForMidnightDST = (
dayIntervalMin: number,
startDayHour: number,
): number => {
const date = createDateFromUTCWithLocalOffset(new Date(dayIntervalMin));
const isMidnightDST = startDayHour === 0 && isLocalTimeMidnightDST(date);

return isMidnightDST
? dayIntervalMin + date.getHours() * 60 * 60 * 1000
Comment thread
aleksei-semikozov marked this conversation as resolved.
Outdated
: dayIntervalMin;
};

const utils = {
getDaylightOffset,
getDaylightOffsetInMs,
Expand Down Expand Up @@ -285,6 +297,7 @@ const utils = {
cacheTimeZones,

isLocalTimeMidnightDST,
adjustDayIntervalMinForMidnightDST,
Comment thread
aleksei-semikozov marked this conversation as resolved.
Outdated
};

export default utils;
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import timeZoneUtils from '../../../m_utils_time_zone';
import { splitIntervalByDay } from '../../common/split_interval_by_days';
import type { CellInterval, DateInterval } from '../../types';

Expand Down Expand Up @@ -30,8 +31,12 @@ export const getMinutesCellIntervals = ({

let columnIndex = 0;
filterBySkippedDays(dayIntervals, skippedDays).forEach((dayInterval) => {
const date = new Date(dayInterval.min);
while (date.getTime() < dayInterval.max) {
const firstAvailableDayTime = timeZoneUtils
.adjustDayIntervalMinForMidnightDST(dayInterval.min, startDayHour);
const intervalMin = Math.max(firstAvailableDayTime, interval.min);
const intervalMax = Math.min(dayInterval.max, interval.max);
Comment thread
aleksei-semikozov marked this conversation as resolved.
Outdated
const date = new Date(intervalMin);
while (date.getTime() < intervalMax) {
const min = date.getTime();
let max = date.setUTCMinutes(date.getUTCMinutes() + durationMinutes);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* @timezone Africa/Cairo
*/

import {
describe, expect, it,
} from '@jest/globals';

import { getWeekIntervals } from './get_week_intervals';

describe('getWeekIntervals', () => {
it('T1327394: should not add a timeline cell before the first available local time on midnight DST', () => {
const intervals = getWeekIntervals({
startDayHour: 0,
endDayHour: 24,
min: Date.UTC(2026, 3, 24, 1),
max: Date.UTC(2026, 3, 25),
skippedDays: [],
}, 60, 0, true);

expect(intervals.cells[0]).toEqual({
min: Date.UTC(2026, 3, 24, 1),
max: Date.UTC(2026, 3, 24, 2),
rowIndex: 0,
columnIndex: 0,
cellIndex: 0,
});
});

it('T1327394: should not add a timeline week cell before the first available local time on midnight DST', () => {
const intervals = getWeekIntervals({
startDayHour: 0,
endDayHour: 24,
min: Date.UTC(2026, 3, 20),
max: Date.UTC(2026, 3, 27),
skippedDays: [],
}, 60, 0, true);

expect(intervals.cells.find((cell) => cell.min === Date.UTC(2026, 3, 24))).toBeUndefined();
expect(intervals.cells.find((cell) => cell.min === Date.UTC(2026, 3, 24, 1))).toEqual({
min: Date.UTC(2026, 3, 24, 1),
max: Date.UTC(2026, 3, 24, 2),
rowIndex: 0,
columnIndex: 96,
cellIndex: 96,
});
});
});
Loading