Major upgrade
Do not update if you are using @material-ui/pickers v3
Breaking changes
- Remove all static format fields like
dateTimeFormat
- Introduce new object for cross utils formatting. It is overridable via constructor
formats
prop and provides easy localization formatting
export interface DateIOFormats {
/** Full date, useful for accessibility @example "2019, January 1st" */
fullDate: string;
/** Day format string extremely required to localize @example "Wed, Jan 1st" for US, "January 1st" for Europe */
normalDate: string;
/** Shorter day format @example "Jan 1st" */
shortDate: string;
/** Year format string @example "2019" */
year: string;
/** Month format string @example "January" */
month: string;
/** Short month format string @example "Jan" */
monthShort: string;
/** Short month format string @example "January 2018" */
monthAndYear: string;
/** Month with date format string @example "January 1st" */
monthAndDate: string;
/** Day format string @example "12" */
dayOfMonth: string;
/** Full time format string @example "11:44 PM" */
fullTime12h: string;
/** Full time format string @example "23:59" */
fullTime24h: string;
/** Hours format string @example "11" */
hours12h: string;
/** Hours format string @example "23" */
hours24h: string;
/** Minutes format string @example "59" */
minutes: string;
/** Seconds format string @example "59" */
seconds: string;
/** Date & Time format string @example "2018, Jan 1st 11:44 PM" */
fullDateTime12h: string;
/** Date & Time format string @example "2018, Jan 1st 23:44" */
fullDateTime24h: string;
/** Keyboard input friendly date format @example "2019/01/01" */
keyboardDate: string;
/** Keyboard input friendly date/time 12h format @example "2019/01/01 23:44" */
keyboardDateTime12h: string;
/** Keyboard input friendly date/time 24h format @example "2019/01/01 11:44 PM" */
keyboardDateTime24h: string;
}
format
method now has signature (date: TDate, formatKey: keyof IDateIOFormat) => string
in order to simplify formatting using new format keys
formatByString
allowes to use custom (mostly user-provided) format strings formatByString(value: TDate, formatString: string): string;