1.0.6 • Published 3 years ago
date-pattern-lookup v1.0.6
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
Property | type | Description |
---|---|---|
shortPatternLookup | Map | returns the short date pattern for the provided locale |