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

Function parseOptions

codebase/sources/dhtmlxscheduler.es.js:16889–17015  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

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