How to use the moment-timezone.isMoment 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 eventespresso / event-espresso-core / assets / src / vo / date-time / datetime.js View on Github external
static fromMoment( momentInstance ) {
		if ( ! moment.isMoment( momentInstance ) ) {
			throw new TypeError( 'Requires an instance of moment.' );
		}

		// this would account for client code that is using `moment` but not
		// using `moment-timezone`.
		return isFunction( momentInstance.tz ) &&
			! isUndefined( momentInstance.tz() ) &&
			momentInstance.tz() !== 'UTC' ?
			new this(
				...this[ privateMethods.normalizeArguments ](
					momentInstance.toISOString(),
					momentInstance.tz(),
					momentInstance.locale()
				)
			) :
			new this(
github tarlepp / Taskboard / backend / api / models / Task.js View on Github external
timeDuration: function() {
            var output;

            if (moment.isMoment(this.timeStartObject()) && moment.isMoment(this.timeEndObject())) {
                output = this.timeEndObject().diff(this.timeStartObject(), 'seconds');
            } else if (moment.isMoment(this.timeStartObject())) {
                output = moment.utc().diff(this.timeStartObject(), 'seconds');
            } else {
                output = 0;
            }

            return output;
        },
        // Current task duration as human readable format
github metasfresh / metasfresh-webui-frontend / src / components / widget / DatePicker.js View on Github external
handleBlur = date => {
    const {
      patch,
      handleBackdropLock,
      dispatch,
      field,
      handleChange,
      timeZone,
    } = this.props;
    const { cache, open } = this.state;

    if (!open) {
      return;
    }

    if (date && !MomentTZ.isMoment(date)) {
      date = MomentTZ(date, `L LT`);
      date = date.tz(timeZone, true);
    }

    try {
      if (
        JSON.stringify(cache) !==
        (date !== '' ? JSON.stringify(date && date.toDate()) : '')
      ) {
        // calling handleChange manually to update date stored in the MasterWidget
        handleChange && handleChange(field, date);

        patch(date);
      }
    } catch (error) {
      dispatch(
github tarlepp / Taskboard / api / models / PhaseDuration.js View on Github external
timeDurationHuman: function() {
            var output;

            if (moment.isMoment(this.timeStartObject()) && moment.isMoment(this.timeEndObject())) {
                output = this.timeStartObject().from(this.timeEndObject(), true);
            } else {
                output = "";
            }

            return output;
        },
        createdAtObject: function () {
github metasfresh / metasfresh-webui-frontend / src / components / table / TableCell.js View on Github external
static createDate = (fieldValue, fieldType) => {
    if (fieldValue) {
      return !Moment.isMoment(fieldValue) && fieldValue.match(TIME_REGEX_TEST)
        ? Moment.utc(Moment.duration(fieldValue).asMilliseconds()).format(
            TIME_FORMAT
          )
        : Moment(fieldValue).format(TableCell.getDateFormat(fieldType));
    }

    return '';
  };
github sebbo2002 / ical-generator / src / event.js View on Github external
if (repeating.interval) {
            if (!isFinite(repeating.interval)) {
                throw new Error('`repeating.interval` must be a Number!');
            }

            c._data.repeating.interval = repeating.interval;
        }

        if (repeating.until !== undefined) {
            if (typeof repeating.until === 'string') {
                repeating.until = moment(repeating.until);
            }
            else if (repeating.until instanceof Date) {
                repeating.until = moment(repeating.until);
            }
            else if (!moment.isMoment(repeating.until)) {
                throw new Error('`repeating.until` must be a Date or a moment object!');
            }

            if (!repeating.until.isValid()) {
                throw new Error('`repeating.until` has to be a valid date!');
            }

            c._data.repeating.until = repeating.until;
        }

        if (repeating.byDay) {
            if (!Array.isArray(repeating.byDay)) {
                repeating.byDay = [repeating.byDay];
            }

            c._data.repeating.byDay = [];
github metasfresh / metasfresh-webui-frontend / src / components / widget / RawWidgetHelpers.js View on Github external
export function generateMomentObj(value, FORMAT) {
  if (Moment.isMoment(value)) {
    return value.format(FORMAT);
  }
  return value ? Moment(value).format(FORMAT) : null;
}
github metasfresh / metasfresh-webui-frontend / src / utils / documentListHelper.js View on Github external
export function parseDateWithCurrentTimezone(value) {
  if (value) {
    if (Moment.isMoment(value)) {
      return value;
    }

    value = convertTimeStringToMoment(value);
    return Moment(value);
  }
  return '';
}
github tarlepp / Taskboard / api / controllers / StoryController.js View on Github external
_.each(data.tasks, function(task) {
                task.type = _.find(data.types, function(type) {
                    return type.id === task.typeId;
                });

                task.user = _.find(data.users, function(user) {
                    return user.id === task.userId;
                });

                task.phase = _.find(data.phases, function(phase) {
                    return phase.id === task.phaseId;
                });

                task.timeStartObjectUser = moment.isMoment(task.timeStartObject())
                    ? task.timeStartObject().tz(request.user.momentTimezone) : null;

                task.timeEndObjectUser = moment.isMoment(task.timeEndObject())
                    ? task.timeEndObject().tz(request.user.momentTimezone) : null;
            });