How to use the rrule.rrulestr function in rrule

To help you get started, we’ve selected a few rrule examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github runbox / runbox7 / src / app / calendar-app / runbox-calendar-event.ts View on Github external
this.id = event.id;
        if (this.id) {
            this.calendar = this.id.split('/')[0];
        }

        if (event['VEVENT']) {
            const vevent = event['VEVENT'];
            this.dtstart = moment(vevent.dtstart, moment.ISO_8601);
            if (vevent.dtend) {
                this.dtend = moment(vevent.dtend, moment.ISO_8601);
            }
            this.title   = vevent.summary;
            this.allDay  = vevent.dtstart.indexOf('T') === -1;
            this.vevent  = vevent;
            if (vevent.rrule) {
                this.rrule = rrulestr(vevent.rrule, { dtstart: this.dtstart.toDate() });
                this.draggable = false;
            }
        } else {
            // "copy constructor" :)
            this.dtstart   = event.dtstart;
            this.dtend     = event.dtend;
            this.title     = event.title;
            this.allDay    = event.allDay;
            this.vevent    = event.vevent;
            this.rrule     = event.rrule;
            this.color     = event.color;
            this.draggable = event.draggable;
        }

        this.refreshDates();
github fullcalendar / fullcalendar / packages / rrule / src / main.ts View on Github external
function parseRRule(input, dateEnv: DateEnv) {
  let allDayGuess = null
  let rrule

  if (typeof input === 'string') {
    rrule = rrulestr(input)

  } else if (typeof input === 'object' && input) { // non-null object
    let refined = { ...input } // copy

    if (typeof refined.dtstart === 'string') {
      let dtstartMeta = dateEnv.createMarkerMeta(refined.dtstart)

      if (dtstartMeta) {
        refined.dtstart = dtstartMeta.marker
        allDayGuess = dtstartMeta.isTimeUnspecified
      } else {
        delete refined.dtstart
      }
    }

    if (typeof refined.until === 'string') {
github MyPureCloud / developercenter-tutorials / architect-schedules / nodejs / isOpen.js View on Github external
function isCurrentlyInSchedule(schedule) {
	var rule = rrulestr('RRULE:' + schedule.rrule);

	var nextOccurance = rule.after(moment().startOf('day').toDate(), true);
	console.log(`nextOccurance ${nextOccurance}`);

	var doesMatchDay = moment(nextOccurance).isSame(moment(), 'day');

	if (!doesMatchDay) {
		return false;
	}

	var date = moment().format('YYYY-MM-DD');

	var start = moment(date + 'T' + schedule.start.split('T')[1]);
	var end = moment(date + 'T' + schedule.end.split('T')[1]);

	return moment().isBetween(start, end);
github Fafruch / react-rrule-generator / src / lib / utils / computeRRule / fromString / computeRRule.js View on Github external
const computeRRule = (data, rrule) => {
  if (!rrule) {
    return data;
  }

  let newDataObj;
  try {
    const rruleObj = RRuleObjectFromString(rrule).origOptions;

    newDataObj = {
      ...data,
      repeat: {
        ...data.repeat,
        frequency: computeFrequency(data, rruleObj),
        yearly: {
          ...data.repeat.yearly,
          mode: computeYearlyMode(data, rruleObj),
          on: {
            month: computeYearlyOnMonth(data, rruleObj),
            day: computeYearlyOnMonthday(data, rruleObj),
          },
          onThe: {
            month: computeYearlyOnTheMonth(data, rruleObj),
            day: computeYearlyOnTheMonthday(data, rruleObj),
github teambition / teambition-sdk / src / models / events / RecurrenceEvent.ts View on Github external
set (rec: string[]) {
        if (rec && rec instanceof Array && rec.length) {
          this._recurrence = rrulestr(rec.join('\n'), { forceset: true })
          this._isRecurrenceEvent = true
        } else {
          this._isRecurrenceEvent = false
        }
        _event.recurrence = rec
      }
    })
github StephenChou1017 / react-big-scheduler / src / SchedulerData.js View on Github external
recurringEvents.forEach((item) => {
            let windowStart = this.localeMoment(this.startDate),
                windowEnd = this.localeMoment(this.endDate).add(1, 'days'),
                oldStart = this.localeMoment(item.start),
                oldEnd = this.localeMoment(item.end),
                rule = rrulestr(item.rrule),
                oldDtstart = undefined,
                oldUntil = rule.origOptions.until || windowEnd.toDate();
            if(!!rule.origOptions.dtstart) {
                oldDtstart = this.localeMoment(rule.origOptions.dtstart);
            }
            //rule.origOptions.dtstart = oldStart.toDate();
            if(windowEnd < oldUntil) {
                rule.origOptions.until = windowEnd.toDate();
            }
                
            //reload
            rule = rrulestr(rule.toString());
            if (item.exdates || item.exrule)
            {
                const rruleSet = new RRuleSet()    
                rruleSet.rrule(rule);
github StephenChou1017 / react-big-scheduler / src / SchedulerData.js View on Github external
windowEnd = this.localeMoment(this.endDate).add(1, 'days'),
                oldStart = this.localeMoment(item.start),
                oldEnd = this.localeMoment(item.end),
                rule = rrulestr(item.rrule),
                oldDtstart = undefined,
                oldUntil = rule.origOptions.until || windowEnd.toDate();
            if(!!rule.origOptions.dtstart) {
                oldDtstart = this.localeMoment(rule.origOptions.dtstart);
            }
            //rule.origOptions.dtstart = oldStart.toDate();
            if(windowEnd < oldUntil) {
                rule.origOptions.until = windowEnd.toDate();
            }
                
            //reload
            rule = rrulestr(rule.toString());
            if (item.exdates || item.exrule)
            {
                const rruleSet = new RRuleSet()    
                rruleSet.rrule(rule); 
                if(item.exrule) {
                    rruleSet.exrule(rrulestr(item.exrule));
                }
                if(item.exdates) {
                    item.exdates.forEach((exdate) => 
                    {
                        rruleSet.exdate(this.localeMoment(exdate).toDate());
                    });
                }
                rule = rruleSet;
            }
github teambition / teambition-sdk / src / models / events / RecurrenceEvent.ts View on Github external
constructor(_event: EventData) {
    super()
    const recurrence = _event.recurrence
    this._startDate = new Date(_event.startDate)
    this._interval = new Date(_event.endDate).valueOf() - new Date(_event.startDate).valueOf()
    /** istanbul ignore if */
    if (recurrence && recurrence.length) {
      this._recurrence = rrulestr(recurrence.join('\n'), { forceset: true })
      this._interval = new Date(_event.endDate).valueOf() - new Date(_event.startDate).valueOf()
      this._isRecurrenceEvent = true
    }
    this.recurrence = _event.recurrence
    Object.defineProperty(this, 'recurrence', {
      get() {
        return _event.recurrence
      },
      set (rec: string[]) {
        if (rec && rec instanceof Array && rec.length) {
          this._recurrence = rrulestr(rec.join('\n'), { forceset: true })
          this._isRecurrenceEvent = true
        } else {
          this._isRecurrenceEvent = false
        }
        _event.recurrence = rec
github QoboLtd / project-template-cakephp / resources / src / components / RecurrenceInput.vue View on Github external
setRRule (recurrenceData) {
      const recurrence = rrulestr(this.recurrenceData)

      this.frequency = recurrence.options.freq
      this.interval = recurrence.options.interval
      this.count = recurrence.options.count
      this.bymonth = recurrence.options.bymonth

      this.byweekday = this.getWeekdaysFromCaptions(recurrence.options.byweekday)

      this.getRRule()
    },
    getRRule () {