Skip to content

Commit

Permalink
Scheduler: update recurrenceRule code snippet (DevExpress#6825)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladaskorohodova committed Nov 29, 2024
1 parent e1b31df commit 2d6755e
Showing 1 changed file with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,26 @@ The **recurrenceRule** value should contain an `RRULE` pattern as per the <a hre
If you need to obtain individual dates from an appointment series, use a 3rd-party library. In the following example, the <a href="https://github.com/jakubroztocil/rrule#rrulejs" target="_blank">rrule</a> library is used:

<!-- tab: JavaScript -->
const rule = new rrule.rrulestr(
"DTSTART:20210805T050000Z\n"
+ "RRULE:FREQ=WEEKLY;UNTIL=20210905T045959Z;BYDAY=MO,TU,WE,TH,FR\n"
+ "EXDATE:20210825T050000Z,20210819T050000Z"
);
import { formatDate } from "devextreme/localization";

const occurences = rule.all();
occurences.forEach(date => console.log(date));
const data = [{
text: 'Watercolor Landscape',
startDate: new Date('2020-11-01T17:30:00.000Z'),
endDate: new Date('2020-11-01T19:00:00.000Z'),
recurrenceRule: 'FREQ=WEEKLY;BYDAY=MO,TH;COUNT=6',
recurrenceException: '20201109T173000Z'
}];

function logAppointmentOccurrences(appointmentData) {
const startDateStr = formatDate(appointmentData.startDate, "yyyyMMddTHHmmssZ");
const rule = new rrule.rrulestr(
`DTSTART:${startDateStr}\n`
+ `RRULE:${appointmentData.recurrenceRule}\n`
+ `EXDATE:${appointmentData.recurrenceException}`
);
const occurrences = rule.all();
occurrences.forEach(date => console.log(date));
}

#####See Also#####
- [recurrenceRuleExpr](/api-reference/10%20UI%20Components/dxScheduler/1%20Configuration/recurrenceRuleExpr.md '/Documentation/ApiReference/UI_Components/dxScheduler/Configuration/#recurrenceRuleExpr')
Expand Down

0 comments on commit 2d6755e

Please sign in to comment.