How to use the @instructure/ui-i18n.DateTime.parse function in @instructure/ui-i18n

To help you get started, we’ve selected a few @instructure/ui-i18n 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 instructure / instructure-ui / packages / ui-forms / src / DateTimeInput / index.js View on Github external
parseISO (iso = '', locale = this.locale, timezone = this.timezone) {
    const parsed = DateTime.parse(iso, locale, timezone)

    if (parsed.isValid()) {
      return {
        iso: parsed.toISOString(true),
        message: {
          type: 'success',
          text: parsed.format(this.props.messageFormat),
        },
      }
    }
    return {
      iso: undefined,
      message: iso ? this.getErrorMessage(...iso.split('T')) : null,
    }
  }
github instructure / instructure-ui / packages / ui-forms / src / DateInput / DatePicker / index.js View on Github external
_parseDate (dateStr, locale, timezone) {
    return DateTime.parse(dateStr, locale, timezone)
  }
github instructure / instructure-ui / packages / ui-forms / src / TimeInput / index.js View on Github external
getBaseDateForRendering (defaultValue, locale, timezone, value) {
    let baseDate
    const baseValue = value || defaultValue
    if (baseValue) {
      baseDate = DateTime.parse(baseValue, locale, timezone)
    } else {
      baseDate = DateTime.now(locale, timezone)
    }
    return baseDate.second(0).millisecond(0)
  }
github instructure / instructure-ui / packages / ui-forms / src / DateInput / index.js View on Github external
_parseDate (dateStr, locale, timezone) {
    return DateTime.parse(dateStr, locale, timezone)
  }
github instructure / instructure-ui / packages / ui-forms / src / TimeInput / index.js View on Github external
getSelectedOption (format, locale, timezone, value) {
    if (!value) {
      return
    }
    const date = DateTime.parse(value, locale, timezone)

    return {
      value: date.toISOString(),
      label: date.format(format)
    }
  }