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

Function parseOptions

codebase/sources/dhtmlxscheduler.js:16893–17019  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

16891 return __assign({}, options);
16892 }
16893 function parseOptions(options) {
16894 var opts = __assign(__assign({}, DEFAULT_OPTIONS$1), initializeOptions$1(options));
16895 if (isPresent(opts.byeaster))
16896 opts.freq = RRule.YEARLY;
16897 if (!(isPresent(opts.freq) && RRule.FREQUENCIES[opts.freq])) {
16898 throw new Error("Invalid frequency: ".concat(opts.freq, " ").concat(options.freq));
16899 }
16900 if (!opts.dtstart)
16901 opts.dtstart = new Date((/* @__PURE__ */ new Date()).setMilliseconds(0));
16902 if (!isPresent(opts.wkst)) {
16903 opts.wkst = RRule.MO.weekday;
16904 } else if (isNumber(opts.wkst))
16905 ;
16906 else {
16907 opts.wkst = opts.wkst.weekday;
16908 }
16909 if (isPresent(opts.bysetpos)) {
16910 if (isNumber(opts.bysetpos))
16911 opts.bysetpos = [opts.bysetpos];
16912 for (var i = 0; i < opts.bysetpos.length; i++) {
16913 var v = opts.bysetpos[i];
16914 if (v === 0 || !(v >= -366 && v <= 366)) {
16915 throw new Error("bysetpos must be between 1 and 366, or between -366 and -1");
16916 }
16917 }
16918 }
16919 if (!(Boolean(opts.byweekno) || notEmpty(opts.byweekno) || notEmpty(opts.byyearday) || Boolean(opts.bymonthday) || notEmpty(opts.bymonthday) || isPresent(opts.byweekday) || isPresent(opts.byeaster))) {
16920 switch (opts.freq) {
16921 case RRule.YEARLY:
16922 if (!opts.bymonth)
16923 opts.bymonth = opts.dtstart.getUTCMonth() + 1;
16924 opts.bymonthday = opts.dtstart.getUTCDate();
16925 break;
16926 case RRule.MONTHLY:
16927 opts.bymonthday = opts.dtstart.getUTCDate();
16928 break;
16929 case RRule.WEEKLY:
16930 opts.byweekday = [getWeekday(opts.dtstart)];
16931 break;
16932 }
16933 }
16934 if (isPresent(opts.bymonth) && !isArray(opts.bymonth)) {
16935 opts.bymonth = [opts.bymonth];
16936 }
16937 if (isPresent(opts.byyearday) && !isArray(opts.byyearday) && isNumber(opts.byyearday)) {
16938 opts.byyearday = [opts.byyearday];
16939 }
16940 if (!isPresent(opts.bymonthday)) {
16941 opts.bymonthday = [];
16942 opts.bynmonthday = [];
16943 } else if (isArray(opts.bymonthday)) {
16944 var bymonthday = [];
16945 var bynmonthday = [];
16946 for (var i = 0; i < opts.bymonthday.length; i++) {
16947 var v = opts.bymonthday[i];
16948 if (v > 0) {
16949 bymonthday.push(v);
16950 } else if (v < 0) {

Callers 1

RRule2Function · 0.70

Calls 7

__assignFunction · 0.70
initializeOptions$1Function · 0.70
isPresentFunction · 0.70
isNumberFunction · 0.70
notEmptyFunction · 0.70
getWeekdayFunction · 0.70
isWeekdayStrFunction · 0.70

Tested by

no test coverage detected