How to use the moment-timezone.isDuration function in moment-timezone

To help you get started, we’ve selected a few moment-timezone 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 NLeSC / spot / framework / partition.js View on Github external
set: function (value) {
        var newValue;

        // check for momentjs objects
        if (moment.isDuration(value)) {
          return {
            val: moment.duration(value),
            type: 'numberDatetimeOrDuration'
          };
        }
        if (moment.isMoment(value)) {
          return {
            val: value.clone(),
            type: 'numberDatetimeOrDuration'
          };
        }

        // try to create momentjs objects
        newValue = moment(value, moment.ISO_8601);
        if (newValue.isValid()) {
          return {
github NLeSC / spot / framework / util / crossfilter.js View on Github external
return function (d) {
        var value = rawValFn(d);

        // parse string if necessary
        if (value !== misval && typeof value === 'string' && value[0].toLowerCase() === 'p') {
          value = moment.duration(value);
        }

        // check for valid duration
        if (moment.isDuration(value)) {
          return value;
        }

        return misval;
      };
    } else {
github NLeSC / spot / spec / framework / crossfilter_spec.js View on Github external
it('duration baseValueFn from property should be a momentjs duration', function () {
      var datum = {'a': 'P10D'};
      facet = new Facet({accessor: 'a', type: 'duration'});
      baseVal = utildx.baseValueFn(facet);
      expect(moment.isDuration(baseVal(datum))).toBe(true);
    });
github sebbo2002 / ical-generator / src / alarm.js View on Github external
}


        if (!trigger) {
            this._data.trigger = null;
            return this;
        }
        if (trigger instanceof Date) {
            this._data.trigger = moment(trigger);
            return this;
        }
        if (moment.isMoment(trigger)) {
            this._data.trigger = trigger;
            return this;
        }
        if (moment.isDuration(trigger)) {
            this._data.trigger = -1 * trigger.as('seconds');
            return this;
        }
        if (typeof trigger === 'number' && isFinite(trigger)) {
            this._data.trigger = -1 * trigger;
            return this;
        }

        throw new Error('`trigger` is not correct, must be a `Number`, `Date` or `moment` or a `moment.duration`!');
    }
github NLeSC / spot / framework / util / selection.js View on Github external
return function (d) {
      if (d === misval) {
        return false;
      }
      var m = moment.duration(d);
      return moment.isDuration(m) && m >= min && (m < max || (m <= max && max >= edge));
    };
  }
github eventespresso / event-espresso-core / assets / src / vo / date-time / duration.js View on Github external
constructor( values, locale = DEFAULT_VALID_LOCALE ) {
		this[ privateProperties.isValid ] = true;
		assertions.assertLocaleIsValid( locale );
		if ( typeof values !== 'object' ) {
			values = moment.duration( values ).locale( locale );
		}
		if ( moment.isDuration( values ) ) {
			this[ privateProperties.duration ] = values;
			this[ privateMethods.populateValuesFromDuration ]( values );
		} else {
			values = this[ privateMethods.filterValues ]( values );
			this[ privateMethods.setValues ]( values );
			this[ privateProperties.duration ] = moment.duration(
				values
			).locale( locale );
		}
		this[ privateMethods.createGetters ]();
		Object.freeze( this );
	}
github NLeSC / spot / framework / facet.js View on Github external
fn: function () {
        var max;
        if (this.isContinuous) {
          max = parseFloat(this.maxvalAsText);
          if (isNaN(max)) {
            max = 100;
          }
        } else if (this.isDatetime) {
          max = moment(this.maxvalAsText, moment.ISO_8601);
          if (!max.isValid()) {
            max = moment('2020-01-01 00:00', moment.ISO_8601);
          }
        } else if (this.isDuration) {
          max = moment.duration(this.maxvalAsText);
          if (!moment.isDuration(max)) {
            max = moment.duration(100, 'seconds');
          }
        }
        return max;
      },
      cache: false
github sebbo2002 / ical-generator / src / alarm.js View on Github external
triggerAfter (trigger) {
        if (trigger === undefined) {
            return this._data.trigger;
        }
        if (moment.isDuration(trigger)) {
            this._data.trigger = -1 * trigger.as('seconds');
            return this;
        }

        return this.trigger(typeof trigger === 'number' ? -1 * trigger : trigger);
    }
github NLeSC / spot / framework / facet.js View on Github external
fn: function () {
        var min;
        if (this.isContinuous) {
          min = parseFloat(this.minvalAsText);
          if (isNaN(min)) {
            min = 0;
          }
        } else if (this.isDatetime) {
          min = moment(this.minvalAsText, moment.ISO_8601);
          if (!min.isValid()) {
            min = moment('2010-01-01 00:00', moment.ISO_8601);
          }
        } else if (this.isDuration) {
          min = moment.duration(this.minvalAsText);
          if (!moment.isDuration(min)) {
            min = moment.duration(1, 'seconds');
          }
        }
        return min;
      },
      cache: false