How to use @fullcalendar/moment - 10 common examples

To help you get started, we’ve selected a few @fullcalendar/moment 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 fullcalendar / fullcalendar / packages / __tests__ / src / datelib / moment.js View on Github external
it('converts correctly', function() {
      let calendar = new Calendar(document.createElement('div'), {
        plugins: [ DayGridPlugin ],
        defaultTimedEventDuration: '05:00',
        defaultAllDayEventDuration: { days: 3 }
      })

      // hacky way to have a duration parsed
      let timedDuration = toDuration(calendar.defaultTimedEventDuration)
      let allDayDuration = toDuration(calendar.defaultAllDayEventDuration)

      expect(timedDuration.asHours()).toBe(5)
      expect(allDayDuration.asDays()).toBe(3)
    })
github fullcalendar / fullcalendar / packages / __tests__ / src / datelib / moment.js View on Github external
it('converts correctly', function() {
      let calendar = new Calendar(document.createElement('div'), {
        plugins: [ DayGridPlugin ],
        defaultTimedEventDuration: '05:00',
        defaultAllDayEventDuration: { days: 3 }
      })

      // hacky way to have a duration parsed
      let timedDuration = toDuration(calendar.defaultTimedEventDuration)
      let allDayDuration = toDuration(calendar.defaultAllDayEventDuration)

      expect(timedDuration.asHours()).toBe(5)
      expect(allDayDuration.asDays()).toBe(3)
    })
github fullcalendar / fullcalendar / packages / __tests__ / src / datelib / moment.js View on Github external
it('transfers UTC', function() {
        let calendar = new Calendar(document.createElement('div'), {
          plugins: [ DayGridPlugin ],
          events: [ { start: '2018-09-05T12:00:00', end: '2018-09-05T18:00:00' } ],
          timeZone: 'UTC'
        })
        let event = calendar.getEvents()[0]
        var startMom = toMoment(event.start, calendar)
        var endMom = toMoment(event.end, calendar)
        expect(startMom.format()).toEqual('2018-09-05T12:00:00Z')
        expect(endMom.format()).toEqual('2018-09-05T18:00:00Z')
      })
github fullcalendar / fullcalendar / packages / __tests__ / src / datelib / moment.js View on Github external
it('transfers local', function() {
        let calendar = new Calendar(document.createElement('div'), {
          plugins: [ DayGridPlugin ],
          events: [ { start: '2018-09-05T12:00:00', end: '2018-09-05T18:00:00' } ],
          timeZone: 'local'
        })
        let event = calendar.getEvents()[0]
        var startMom = toMoment(event.start, calendar)
        var endMom = toMoment(event.end, calendar)
        expect(startMom.toDate()).toEqualLocalDate('2018-09-05T12:00:00')
        expect(endMom.toDate()).toEqualLocalDate('2018-09-05T18:00:00')
      })
github fullcalendar / fullcalendar / packages / __tests__ / src / datelib / moment.js View on Github external
it('transfers UTC', function() {
        let calendar = new Calendar(document.createElement('div'), {
          plugins: [ DayGridPlugin ],
          events: [ { start: '2018-09-05T12:00:00', end: '2018-09-05T18:00:00' } ],
          timeZone: 'UTC'
        })
        let event = calendar.getEvents()[0]
        var startMom = toMoment(event.start, calendar)
        var endMom = toMoment(event.end, calendar)
        expect(startMom.format()).toEqual('2018-09-05T12:00:00Z')
        expect(endMom.format()).toEqual('2018-09-05T18:00:00Z')
      })
github teamapps-org / teamapps / teamapps-client / ts / modules / util / FullCalendarMonthGrid.ts View on Github external
private getMonthRangesToBeDisplayed(): DisplayedMonth[] {
		let startMoment = toMoment(this.currentStart, this.calendar);
		let endMoment = toMoment(this.currentEnd, this.calendar);
		const numberOfMonths = endMoment.diff(startMoment, 'month');
		const displayedMonths: DisplayedMonth[] = [];
		for (let i = 0; i < numberOfMonths; i++) {
			let intervalStart = startMoment.clone().add(i, 'month');
			let intervalEnd = startMoment.clone().add(i + 1, 'month');
			const monthRange: DisplayedMonth = {
				intervalStart,
				intervalEnd,
				displayedStart: this.startOfWeek(startMoment),
				displayedEnd: this.startOfWeek(intervalEnd).add(7, "day"),
				displayedWeeks: this.getDisplayedWeeks(intervalStart)
			};
			displayedMonths.push(monthRange);
		}
		return displayedMonths;
github teamapps-org / teamapps / teamapps-client / ts / modules / util / FullCalendarMonthGrid.ts View on Github external
private eventToSegments(event: EventApi): Segment[] {
		let startMoment = toMoment(event.start, this.calendar);
		let endMoment = event.end != null ? toMoment(event.end, this.calendar) : null;
		if (event.end == null) {
			let start = startMoment.clone().startOf("day").hour(8);
			let end = startMoment.clone().startOf("day").hour(16);
			return [new Segment(moment(start), moment(end), true, true, event)];
		} else if (startMoment.day() === endMoment.day() && endMoment.valueOf() - startMoment.valueOf() < 86400000 /*day*/) {
			return [new Segment(startMoment, endMoment, true, true, event)];
		} else {
			let segments: Segment[] = [];
			let segStart = startMoment;
			let segEnd = startMoment;
			while (segEnd.valueOf() < endMoment.valueOf()) {
				segStart = segEnd;
				segEnd = moment.min(endMoment, segStart.clone().startOf("day").add(1, "day"));
				segments.push(new Segment(segStart.clone(), segEnd.clone(), +segStart === +event.start, +segEnd === +event.end, event));
			}
			return segments;
github teamapps-org / teamapps / teamapps-client / ts / modules / util / FullCalendarMonthGrid.ts View on Github external
private eventToSegments(event: EventApi): Segment[] {
		let startMoment = toMoment(event.start, this.calendar);
		let endMoment = event.end != null ? toMoment(event.end, this.calendar) : null;
		if (event.end == null) {
			let start = startMoment.clone().startOf("day").hour(8);
			let end = startMoment.clone().startOf("day").hour(16);
			return [new Segment(moment(start), moment(end), true, true, event)];
		} else if (startMoment.day() === endMoment.day() && endMoment.valueOf() - startMoment.valueOf() < 86400000 /*day*/) {
			return [new Segment(startMoment, endMoment, true, true, event)];
		} else {
			let segments: Segment[] = [];
			let segStart = startMoment;
			let segEnd = startMoment;
			while (segEnd.valueOf() < endMoment.valueOf()) {
				segStart = segEnd;
				segEnd = moment.min(endMoment, segStart.clone().startOf("day").add(1, "day"));
				segments.push(new Segment(segStart.clone(), segEnd.clone(), +segStart === +event.start, +segEnd === +event.end, event));
			}
github teamapps-org / teamapps / teamapps-client / ts / modules / util / FullCalendarMonthGrid.ts View on Github external
return this.events.filter(e => {
			let eventStart = toMoment(e.start, this.calendar);
			let eventEnd = e.end != null ? toMoment(e.end, this.calendar) : eventStart.clone().add(1, 'second');
			return +eventEnd > +dayStart && +eventStart < +(dayEnd);
		});
	}
github teamapps-org / teamapps / teamapps-client / ts / modules / util / FullCalendarMonthGrid.ts View on Github external
private getMonthRangesToBeDisplayed(): DisplayedMonth[] {
		let startMoment = toMoment(this.currentStart, this.calendar);
		let endMoment = toMoment(this.currentEnd, this.calendar);
		const numberOfMonths = endMoment.diff(startMoment, 'month');
		const displayedMonths: DisplayedMonth[] = [];
		for (let i = 0; i < numberOfMonths; i++) {
			let intervalStart = startMoment.clone().add(i, 'month');
			let intervalEnd = startMoment.clone().add(i + 1, 'month');
			const monthRange: DisplayedMonth = {
				intervalStart,
				intervalEnd,
				displayedStart: this.startOfWeek(startMoment),
				displayedEnd: this.startOfWeek(intervalEnd).add(7, "day"),
				displayedWeeks: this.getDisplayedWeeks(intervalStart)
			};
			displayedMonths.push(monthRange);
		}
		return displayedMonths;
	}

@fullcalendar/moment

Enhanced date formatting and conversion with Moment

MIT
Latest version published 4 months ago

Package Health Score

78 / 100
Full package analysis