MCPcopy Create free account
hub / github.com/DHTMLX/scheduler / updateFollowingRRULE

Function updateFollowingRRULE

codebase/sources/dhtmlxscheduler.es.js:18357–18398  ·  view source on GitHub ↗
(id, ev)

Source from the content-addressed store, hash-verified

18355 ev.rrule = new RRule(parsedRRule.origOptions).toString().replace("RRULE:", "").split("\n")[1];
18356 }
18357 function updateFollowingRRULE(id, ev) {
18358 if (!ev) {
18359 ev = scheduler2.getEvent(id);
18360 }
18361 let rruleStringparts = ev.rrule.split(";");
18362 let updatedRRULE = [];
18363 let interval;
18364 for (let i = 0; i < rruleStringparts.length; i++) {
18365 let splited = rruleStringparts[i].split("=");
18366 let code = splited[0];
18367 let name = splited[1];
18368 if (code === "BYDAY") {
18369 if (!(ev.rrule.includes("WEEKLY") && name.length > 3)) {
18370 continue;
18371 }
18372 }
18373 if (code === "UNTIL") {
18374 const rule = rrulestr(ev.rrule);
18375 const untilDate = rule.options.until;
18376 if (untilDate.valueOf() < ev.start_date.valueOf()) {
18377 ev._end_date = ev.end_date;
18378 }
18379 }
18380 if (code === "INTERVAL") {
18381 interval = Number(name);
18382 }
18383 if (code === "COUNT") {
18384 if (ev._shorten_end_date) {
18385 const start = scheduler2.date.date_part(new Date(ev._start_date));
18386 const end = scheduler2.date.date_part(new Date(ev._shorten_end_date));
18387 const days = Math.floor((end - start) / (1e3 * 60 * 60 * 24 * interval)) + 1;
18388 name = name - days;
18389 }
18390 }
18391 updatedRRULE.push(code);
18392 updatedRRULE.push("=");
18393 updatedRRULE.push(name);
18394 updatedRRULE.push(";");
18395 }
18396 updatedRRULE.pop();
18397 ev.rrule = updatedRRULE.join("");
18398 }
18399 scheduler2._isFollowing = function(id) {
18400 let ev = scheduler2.getEvent(id);
18401 return !!(ev && ev._thisAndFollowing);

Callers 1

handleFollowingFunction · 0.70

Calls 3

rrulestrFunction · 0.70
getEventMethod · 0.65
date_partMethod · 0.65

Tested by

no test coverage detected