How to use moment-parseformat - 6 common examples

To help you get started, we’ve selected a few moment-parseformat 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 postlight / mercury-parser / src / cleaners / date-published.js View on Github external
export function createDate(dateString, timezone, format) {
  if (TIME_WITH_OFFSET_RE.test(dateString)) {
    return moment(new Date(dateString));
  }

  return timezone ?
    moment.tz(dateString, format || parseFormat(dateString), timezone) :
    moment(dateString, format || parseFormat(dateString));
}
github postlight / mercury-parser / src / cleaners / date-published.js View on Github external
export function createDate(dateString, timezone, format) {
  if (TIME_WITH_OFFSET_RE.test(dateString)) {
    return moment(new Date(dateString));
  }

  return timezone ?
    moment.tz(dateString, format || parseFormat(dateString), timezone) :
    moment(dateString, format || parseFormat(dateString));
}
github postlight / mercury-parser / src / cleaners / date-published.js View on Github external
if (TIME_WITH_OFFSET_RE.test(dateString)) {
    return moment(new Date(dateString));
  }

  if (TIME_AGO_STRING.test(dateString)) {
    const fragments = TIME_AGO_STRING.exec(dateString);
    return moment().subtract(fragments[1], fragments[2]);
  }

  if (TIME_NOW_STRING.test(dateString)) {
    return moment();
  }

  return timezone
    ? moment.tz(dateString, format || parseFormat(dateString), timezone)
    : moment(dateString, format || parseFormat(dateString));
}
github postlight / mercury-parser / src / cleaners / date-published.js View on Github external
export function createDate(dateString, timezone, format) {
  if (TIME_WITH_OFFSET_RE.test(dateString)) {
    return moment(new Date(dateString));
  }

  if (TIME_AGO_STRING.test(dateString)) {
    const fragments = TIME_AGO_STRING.exec(dateString);
    return moment().subtract(fragments[1], fragments[2]);
  }

  if (TIME_NOW_STRING.test(dateString)) {
    return moment();
  }

  return timezone
    ? moment.tz(dateString, format || parseFormat(dateString), timezone)
    : moment(dateString, format || parseFormat(dateString));
}
github joshangell / FFFields / src / components / Date.vue View on Github external
getMomentFromValue: function(value) {

                if (this.config.showDate && this.config.showTime) {
                    return moment(value, parseFormat(this.config.localeDate) + ' ' + parseFormat(this.config.localeTime));
                }

                if (this.config.showDate) {
                    return moment(value, parseFormat(this.config.localeDate));
                }

                if (this.config.showTime) {
                    return moment(value, parseFormat(this.config.localeTime));
                }

            },
github joshangell / FFFields / src / components / Date.vue View on Github external
getMomentFromValue: function(value) {

                if (this.config.showDate && this.config.showTime) {
                    return moment(value, parseFormat(this.config.localeDate) + ' ' + parseFormat(this.config.localeTime));
                }

                if (this.config.showDate) {
                    return moment(value, parseFormat(this.config.localeDate));
                }

                if (this.config.showTime) {
                    return moment(value, parseFormat(this.config.localeTime));
                }

            },

moment-parseformat

A moment.js plugin to extract the format of a date/time string

Apache-2.0
Latest version published 3 years ago

Package Health Score

57 / 100
Full package analysis

Popular moment-parseformat functions