How to use the @fullcalendar/core.createDuration function in @fullcalendar/core

To help you get started, we’ve selected a few @fullcalendar/core 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 avpeery / Moon-Phase-Tracker / static / fullcalendar / packages / timegrid / main.esm.js View on Github external
this.snapsPerSlot = snapsPerSlot;
        // might be an array value (for TimelineView).
        // if so, getting the most granular entry (the last one probably).
        input = this.opt('slotLabelFormat');
        if (Array.isArray(input)) {
            input = input[input.length - 1];
        }
        this.labelFormat = createFormatter(input || {
            hour: 'numeric',
            minute: '2-digit',
            omitZeroMinute: true,
            meridiem: 'short'
        });
        input = this.opt('slotLabelInterval');
        this.labelInterval = input ?
            createDuration(input) :
            this.computeLabelInterval(slotDuration);
    };
    // Computes an automatic value for slotLabelInterval
github fullcalendar / fullcalendar / packages / interaction / src / interactions / EventResizing.ts View on Github external
jsEvent: ev.origEvent as MouseEvent, // Is this always a mouse event? See #4655
        view
      }
    ])

    if (this.validMutation) {
      calendar.dispatch({
        type: 'MERGE_EVENTS',
        eventStore: mutatedRelevantEvents
      })

      calendar.publiclyTrigger('eventResize', [
        {
          el: this.draggingSeg.el,
          startDelta: this.validMutation.startDelta || createDuration(0),
          endDelta: this.validMutation.endDelta || createDuration(0),
          prevEvent: eventApi,
          event: new EventApi( // the data AFTER the mutation
            calendar,
            mutatedRelevantEvents.defs[eventDef.defId],
            eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null
          ),
          revert: function() {
            calendar.dispatch({
              type: 'MERGE_EVENTS',
              eventStore: relevantEvents
            })
          },
          jsEvent: ev.origEvent,
          view
        }
      ])
github avpeery / Moon-Phase-Tracker / static / fullcalendar / packages / interaction / main.esm.js View on Github external
el: _this.draggingSeg.el,
                    event: eventApi,
                    jsEvent: ev.origEvent,
                    view: view
                }
            ]);
            if (_this.validMutation) {
                calendar.dispatch({
                    type: 'MERGE_EVENTS',
                    eventStore: mutatedRelevantEvents
                });
                calendar.publiclyTrigger('eventResize', [
                    {
                        el: _this.draggingSeg.el,
                        startDelta: _this.validMutation.startDelta || createDuration(0),
                        endDelta: _this.validMutation.endDelta || createDuration(0),
                        prevEvent: eventApi,
                        event: new EventApi(// the data AFTER the mutation
                        calendar, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null),
                        revert: function () {
                            calendar.dispatch({
                                type: 'MERGE_EVENTS',
                                eventStore: relevantEvents
                            });
                        },
                        jsEvent: ev.origEvent,
                        view: view
                    }
                ]);
            }
            else {
                calendar.publiclyTrigger('_noEventResize');
github fullcalendar / fullcalendar / packages / timegrid / src / TimeGrid.ts View on Github external
// if so, getting the most granular entry (the last one probably).
    input = options.slotLabelFormat
    if (Array.isArray(input)) {
      input = input[input.length - 1]
    }

    this.labelFormat = createFormatter(input || {
      hour: 'numeric',
      minute: '2-digit',
      omitZeroMinute: true,
      meridiem: 'short'
    })

    input = options.slotLabelInterval
    this.labelInterval = input ?
      createDuration(input) :
      this.computeLabelInterval(slotDuration)
  }
github fullcalendar / fullcalendar / packages / interaction / src / interactions / EventResizing.ts View on Github external
event: eventApi,
        jsEvent: ev.origEvent as MouseEvent, // Is this always a mouse event? See #4655
        view
      }
    ])

    if (this.validMutation) {
      calendar.dispatch({
        type: 'MERGE_EVENTS',
        eventStore: mutatedRelevantEvents
      })

      calendar.publiclyTrigger('eventResize', [
        {
          el: this.draggingSeg.el,
          startDelta: this.validMutation.startDelta || createDuration(0),
          endDelta: this.validMutation.endDelta || createDuration(0),
          prevEvent: eventApi,
          event: new EventApi( // the data AFTER the mutation
            calendar,
            mutatedRelevantEvents.defs[eventDef.defId],
            eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null
          ),
          revert: function() {
            calendar.dispatch({
              type: 'MERGE_EVENTS',
              eventStore: relevantEvents
            })
          },
          jsEvent: ev.origEvent,
          view
        }
github fullcalendar / fullcalendar / packages / timegrid / src / TimeGrid.ts View on Github external
computeLabelInterval(slotDuration) {
    let i
    let labelInterval
    let slotsPerLabel

    // find the smallest stock label interval that results in more than one slots-per-label
    for (i = AGENDA_STOCK_SUB_DURATIONS.length - 1; i >= 0; i--) {
      labelInterval = createDuration(AGENDA_STOCK_SUB_DURATIONS[i])
      slotsPerLabel = wholeDivideDurations(labelInterval, slotDuration)
      if (slotsPerLabel !== null && slotsPerLabel > 1) {
        return labelInterval
      }
    }

    return slotDuration // fall back
  }
github avpeery / Moon-Phase-Tracker / static / fullcalendar / packages / interaction / main.esm.js View on Github external
{
                    el: _this.draggingSeg.el,
                    event: eventApi,
                    jsEvent: ev.origEvent,
                    view: view
                }
            ]);
            if (_this.validMutation) {
                calendar.dispatch({
                    type: 'MERGE_EVENTS',
                    eventStore: mutatedRelevantEvents
                });
                calendar.publiclyTrigger('eventResize', [
                    {
                        el: _this.draggingSeg.el,
                        startDelta: _this.validMutation.startDelta || createDuration(0),
                        endDelta: _this.validMutation.endDelta || createDuration(0),
                        prevEvent: eventApi,
                        event: new EventApi(// the data AFTER the mutation
                        calendar, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null),
                        revert: function () {
                            calendar.dispatch({
                                type: 'MERGE_EVENTS',
                                eventStore: relevantEvents
                            });
                        },
                        jsEvent: ev.origEvent,
                        view: view
                    }
                ]);
            }
            else {
github fullcalendar / fullcalendar / packages / __tests__ / src / datelib / main.js View on Github external
it('accepts just hours and minutes', function() {
      var dur = createDuration('01:02')
      expect(dur).toEqual({
        years: 0,
        months: 0,
        days: 0,
        milliseconds:
          1 * 60 * 60 * 1000 +
          2 * 60 * 1000
      })
    })
github fullcalendar / fullcalendar / packages / __tests__ / src / datelib / main.js View on Github external
it('accepts whole day in string', function() {
      var dur = createDuration('2.00:00:00')
      expect(dur).toEqual({
        years: 0,
        months: 0,
        days: 2,
        milliseconds: 0
      })
    })
github fullcalendar / fullcalendar / packages / timegrid / src / TimeGrid.ts View on Github external
computeDateTop(when: DateMarker, startOfDayDate?: DateMarker) {
    if (!startOfDayDate) {
      startOfDayDate = startOfDay(when)
    }
    return this.computeTimeTop(createDuration(when.valueOf() - startOfDayDate.valueOf()))
  }