How to use the react-widgets/lib/configure.setDateLocalizer function in react-widgets

To help you get started, we’ve selected a few react-widgets 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 jquense / react-widgets / packages / localizer-moment / localizer.js View on Github external
return moment.localeData(culture).firstDayOfWeek()
    },

    parse(value, format, culture) {
      if (!value) return null;
      const m = getMoment(culture, value, format);
      if (m.isValid()) return m.toDate();
      return null;
    },

    format(value, format, culture) {
      return getMoment(culture, value).format(format)
    }
  }

  configure.setDateLocalizer(localizer)
}
github jquense / react-widgets / packages / localizer-date-fns / localizer.js View on Github external
new Date(),
      format,
      value
    )
    if (result.toString() === 'Invalid Date') {
      return null;
    }
    return result;
  }

  function firstOfWeek(culture) {
    const { options } = getLocale(culture)
    return (options && options.weekStartsOn) || 0
  }

  configure.setDateLocalizer({ formats, firstOfWeek, parse, format })
}