1.0.6 • Published 3 years ago

date-pattern-lookup v1.0.6

Weekly downloads
25
License
MIT
Repository
github
Last release
3 years ago

Date Pattern Lookup

A simple library to get the date pattern for a locale. Useful if you have a date input that allows for inline editing and requires a date format / pattern to build the appropriate input mask.

Demo Sandbox

Getting Started

Installation

yarn add date-pattern-lookup

Usage

import { shortPatternLookup } from "date-pattern-lookup";

Example

Below example uses the KeyboardDatePicker from Material-UI pickers

import { shortpattern } from "date-pattern-lookup";
import { KeyboardDatePicker } from "@material-ui/pickers";

function MyDatePicker() {
  const code = "en-US";
  const pattern = shortPatternLookup.get(code);
  // pattern = MM/dd/yyyy

  return (
    <KeyboardDatePicker
      clearable
      value={selectedDate}
      placeholder={pattern}
      onChange={(date) => handleDateChange(date)}
      format={pattern}
    />
  );
}

Options

PropertytypeDescription
shortPatternLookupMapreturns the short date pattern for the provided locale
1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago