Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const computeWeekly = ({ interval, days }) => ({
freq: RRule.WEEKLY,
interval,
byweekday: values(days).reduce(
(activeDays, isDayActive, dayIndex) =>
(isDayActive ? [...activeDays, dayIndex] : activeDays),
[],
),
});
}
},
{
title: 'Recurs yearly on the 10th of the current month',
color: colors.blue,
rrule: {
freq: RRule.YEARLY,
bymonth: moment().month() + 1,
bymonthday: 10
}
},
{
title: 'Recurs weekly on mondays',
color: colors.red,
rrule: {
freq: RRule.WEEKLY,
byweekday: [RRule.MO]
}
}
];
calendarEvents: CalendarEvent[] = [];
viewPeriod: ViewPeriod;
constructor(private cdr: ChangeDetectorRef) {}
updateCalendarEvents(
viewRender:
| CalendarMonthViewBeforeRenderEvent
| CalendarWeekViewBeforeRenderEvent
| CalendarDayViewBeforeRenderEvent
Tuesday: 'TU',
Wednesday: 'WE',
Thursday: 'TH',
Friday: 'FR',
Saturday: 'SA',
Sunday: 'SU',
};
const rules = {
daily: {
name: 'Every Day',
frequency: RRule.DAILY,
},
weekdays: {
name: 'Every Weekday (Mon-Fri)',
frequency: RRule.WEEKLY,
byweekday: ['MO', 'TU', 'WE', 'TH', 'FR'],
},
weekends: {
name: 'Weekends (Sat/Sun)',
frequency: RRule.WEEKLY,
byweekday: ['SA', 'SU'],
},
weekly: {
name: `Weekly on ${dateSpelled}`,
frequency: RRule.WEEKLY,
byweekday: [dayToRRule[dateSpelled]],
},
byposition_FirstOfMonth: {
name: `First ${dateSpelled} of the Month`,
frequency: RRule.MONTHLY,
byweekday: [dayToRRule[dateSpelled]],
const doesRecurringEventsOverlap = (startingDate, endingDate, recurringRule) => {
if (!recurringRule || !startingDate || !endingDate ||
!('frequency' in recurringRule) || !('interval' in recurringRule)) return false;
const freqMap = {
YEARLY: RRule.YEARLY,
MONTHLY: RRule.MONTHLY,
WEEKLY: RRule.WEEKLY,
DAILY: RRule.DAILY,
};
const dayMap = {
MO: RRule.MO,
TU: RRule.TU,
WE: RRule.WE,
TH: RRule.TH,
FR: RRule.FR,
SA: RRule.SA,
SU: RRule.SU,
};
const rules = {
freq: freqMap[recurringRule.frequency],
interval: parseInt(recurringRule.interval, 10) || 1,
name: 'Every Day',
frequency: RRule.DAILY,
},
weekdays: {
name: 'Every Weekday (Mon-Fri)',
frequency: RRule.WEEKLY,
byweekday: ['MO', 'TU', 'WE', 'TH', 'FR'],
},
weekends: {
name: 'Weekends (Sat/Sun)',
frequency: RRule.WEEKLY,
byweekday: ['SA', 'SU'],
},
weekly: {
name: `Weekly on ${dateSpelled}`,
frequency: RRule.WEEKLY,
byweekday: [dayToRRule[dateSpelled]],
},
byposition_FirstOfMonth: {
name: `First ${dateSpelled} of the Month`,
frequency: RRule.MONTHLY,
byweekday: [dayToRRule[dateSpelled]],
bysetpos: 1,
},
byposition_LastOfMonth: {
name: `Last ${dateSpelled} of the Month`,
frequency: RRule.MONTHLY,
byweekday: [dayToRRule[dateSpelled]],
bysetpos: -1,
},
byday: {
name: `On day ${dateNumber} of the month`,