This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/vuetify/lib/components/VDatePicker/util/createNativeLocaleFormatter.js
2019-08-11 20:48:02 +02:00

21 lines
No EOL
799 B
JavaScript

import pad from './pad';
function createNativeLocaleFormatter(locale, options, substrOptions = {
start: 0,
length: 0
}) {
const makeIsoString = dateString => {
const [year, month, date] = dateString.trim().split(' ')[0].split('-');
return [pad(year, 4), pad(month || 1), pad(date || 1)].join('-');
};
try {
const intlFormatter = new Intl.DateTimeFormat(locale || undefined, options);
return dateString => intlFormatter.format(new Date(`${makeIsoString(dateString)}T00:00:00+00:00`));
} catch (e) {
return substrOptions.start || substrOptions.length ? dateString => makeIsoString(dateString).substr(substrOptions.start || 0, substrOptions.length) : undefined;
}
}
export default createNativeLocaleFormatter;
//# sourceMappingURL=createNativeLocaleFormatter.js.map