Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const computeYearly = ({ mode, on, onThe }) => ({
freq: RRule.YEARLY,
...(mode === 'on' ? computeYearlyOn(on) : computeYearlyOnThe(onThe)),
});
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 = {
viewDate = moment().toDate();
recurringEvents: RecurringEvent[] = [
{
title: 'Recurs on the 5th of each month',
color: colors.yellow,
rrule: {
freq: RRule.MONTHLY,
bymonthday: 5
}
},
{
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[] = [];