Skip to content

Commit

Permalink
fix(Scheduler): test fix impl (test commit)
Browse files Browse the repository at this point in the history
  • Loading branch information
wdevfx committed Feb 7, 2025
1 parent c5e22ca commit d7b0845
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 4 deletions.
27 changes: 27 additions & 0 deletions packages/devextreme/js/__internal/core/utils/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,33 @@ const addOffsets = (date: Date, offsets: number[]): Date => {
return new Date(newDateMs);
};

/**
* TODO: write a description
*/
const getDateTimePart = (date: Date): number => {
const dateCopy = new Date(date);
const trimmedDateMs = new Date(dateCopy.setHours(0, 0, 0, 0)).getTime();
return date.getTime() - trimmedDateMs;
};

/**
* This function compares equality time part of the dates
* Cases:
* a) '2024-01-01T10:00:00Z' and '2025-01-01T10:00:00Z' -> returns true
* b) '2024-01-01T10:00:00Z' and '2025-01-01T09:00:00Z' -> returns false
*/
const hasDifferentTimePart = (
firstDate: Date,
secondDate: Date,
): boolean => {
const firstDateTimePart = getDateTimePart(firstDate);
const secondDateTimePart = getDateTimePart(secondDate);

return firstDateTimePart !== secondDateTimePart;
};

export const dateUtilsTs = {
addOffsets,
getDateTimePart,
hasDifferentTimePart,
};
31 changes: 27 additions & 4 deletions packages/devextreme/js/__internal/scheduler/m_recurrence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import errors from '@js/core/errors';
import dateUtils from '@js/core/utils/date';
import { each } from '@js/core/utils/iterator';
// import { dateUtilsTs } from '@ts/core/utils/date';
import { RRule, RRuleSet } from 'rrule';

import timeZoneUtils from './m_utils_time_zone';
Expand Down Expand Up @@ -271,6 +272,7 @@ class RecurrenceProcessor {

_initializeRRule(options, startDateUtc, until) {
const ruleOptions = RRule.parseString(options.rule);
// start: startIntervalDate
const { firstDayOfWeek } = options;

ruleOptions.dtstart = startDateUtc;
Expand All @@ -296,15 +298,36 @@ class RecurrenceProcessor {
.map((rule) => this.getDateByAsciiString(rule));

exceptionDates.forEach((date) => {
if (options.getPostProcessedException) {
date = options.getPostProcessedException(date);
}
// if (options.getPostProcessedException) {
// date = options.getPostProcessedException(date);
// }

// const hasDifferentTimeFromStartIntervalDate = dateUtilsTs.hasDifferentTimePart(
// startIntervalDate,
// date,
// );

// const hasDifferentTimeFromStartIntervalDate = startIntervalDate.getUTCHours() !== date.getUTCHours();

// const additionalOffset = hasDifferentTimeFromStartIntervalDate
// ? dateUtils.getTimezonesDifference(startIntervalDate, date)
// : 0;

const utcDate = timeZoneUtils.setOffsetsToDate(
date,
[-timeZoneUtils.getClientTimezoneOffset(date), options.appointmentTimezoneOffset],
[
-timeZoneUtils.getClientTimezoneOffset(date),
options.appointmentTimezoneOffset,
// additionalOffset,
],
);

// console.log('-----');
// console.log('start date: ', startIntervalDate.toString(), startIntervalDate.toUTCString());
// console.log('excluded date: ', date.toString(), date.toUTCString());
// console.log('offsets: ', -timeZoneUtils.getClientTimezoneOffset(date) / 3600000, options.appointmentTimezoneOffset / 3600000, additionalOffset / 3600000);
// console.log('excluded date: ', utcDate.toString(), utcDate.toUTCString());

this.rRuleSet!.exdate(utcDate);
});
}
Expand Down
4 changes: 4 additions & 0 deletions packages/devextreme/js/__internal/scheduler/m_scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,9 @@ class Scheduler extends Widget<any> {
this.timeZoneCalculator,
);

// console.log('target appt: ', targetedAppointment, targetedAdapter);
// console.log('excluded date: ', targetedAdapter.startDate);

const deletingOptions = this.fireOnAppointmentDeleting(appointment, targetedAdapter);
this._checkRecurringAppointment(
appointment,
Expand Down Expand Up @@ -2088,6 +2091,7 @@ class Scheduler extends Widget<any> {

getTargetedAppointment(appointment, element) {
const settings: any = utils.dataAccessors.getAppointmentSettings(element);

const info = utils.dataAccessors.getAppointmentInfo(element);

const appointmentIndex = $(element).data(this._appointments._itemIndexKey());
Expand Down

0 comments on commit d7b0845

Please sign in to comment.