/
githubmirror
/
dayjs
Обзор
Документация
Войти
/
githubmirror
/
dayjs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
src/plugin/localizedFormat/utils.js
17 строк
554 B
Jukka Raimovaara
fix: customParseFormat plugin supports parsing localizedFormats (#1110)
30 окт 2020, 06:10
30 окт 2020, 06:10
402b603
Код
Авторство
О чём код?
// eslint-disable-next-line import/prefer-default-export export const t = format => format.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, (_, a, b) => a || b.slice(1)) export const englishFormats = { LTS: 'h:mm:ss A', LT: 'h:mm A', L: 'MM/DD/YYYY', LL: 'MMMM D, YYYY', LLL: 'MMMM D, YYYY h:mm A', LLLL: 'dddd, MMMM D, YYYY h:mm A' } export const u = (formatStr, formats) => formatStr.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, (_, a, b) => { const B = b && b.toUpperCase() return a || formats[b] || englishFormats[b] || t(formats[B]) })