app-datepicker-rtl
Version:
A custom datepicker element based on Google's Material Design built from scratch with lit-element. Fork of app-datepicker by motts.
36 lines (35 loc) • 1.41 kB
JavaScript
import { getFormatter } from 'nodemod/dist/calendar/helpers/get-formatter.js';
import { INTL_DATE_TIME_FORMAT } from '../constants.js';
export function getFormatters(locale) {
const dateFmt = INTL_DATE_TIME_FORMAT(locale, {
timeZone: 'UTC',
weekday: 'short',
month: 'short',
day: 'numeric',
});
const dayFmt = INTL_DATE_TIME_FORMAT(locale, { timeZone: 'UTC', day: 'numeric' });
const fullDateFmt = INTL_DATE_TIME_FORMAT(locale, {
timeZone: 'UTC',
year: 'numeric',
month: 'short',
day: 'numeric',
});
const longMonthYearFmt = INTL_DATE_TIME_FORMAT(locale, {
timeZone: 'UTC',
year: 'numeric',
month: 'long',
});
const longWeekdayFmt = INTL_DATE_TIME_FORMAT(locale, { timeZone: 'UTC', weekday: 'long' });
const narrowWeekdayFmt = INTL_DATE_TIME_FORMAT(locale, { timeZone: 'UTC', weekday: 'narrow' });
const yearFmt = INTL_DATE_TIME_FORMAT(locale, { timeZone: 'UTC', year: 'numeric' });
return {
locale,
dateFormat: getFormatter(dateFmt),
dayFormat: getFormatter(dayFmt),
fullDateFormat: getFormatter(fullDateFmt),
longMonthYearFormat: getFormatter(longMonthYearFmt),
longWeekdayFormat: getFormatter(longWeekdayFmt),
narrowWeekdayFormat: getFormatter(narrowWeekdayFmt),
yearFormat: getFormatter(yearFmt),
};
}