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

Function updateFollowingRRULE

codebase/sources/dhtmlxscheduler.js:18361–18402  ·  view source on GitHub ↗
(id, ev)

Source from the content-addressed store, hash-verified

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