/
githubmirror
/
dayjs
Обзор
Документация
Войти
/
githubmirror
/
dayjs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
src/plugin/buddhistEra/index.js
17 строк
582 B
Mário Gonçalves
fix: skip square brackets in buddhistEra, advancedFormat plugins (#556)
26 апр 2019, 09:22
26 апр 2019, 09:22
9279718
Код
Авторство
О чём код?
import { FORMAT_DEFAULT } from '../../constant' export default (o, c) => { // locale needed later const proto = c.prototype const oldFormat = proto.format // extend en locale here proto.format = function (formatStr) { const yearBias = 543 const str = formatStr || FORMAT_DEFAULT const result = str.replace(/(\[[^\]]+])|BBBB|BB/g, (match, a) => { const year = String(this.$y + yearBias) const args = match === 'BB' ? [year.slice(-2), 2] : [year, 4] return a || this.$utils().s(...args, '0') }) return oldFormat.bind(this)(result) } }