first commit

This commit is contained in:
lingxiao865
2026-02-10 08:05:03 +08:00
commit c5af079d8c
1094 changed files with 97530 additions and 0 deletions

View File

@@ -0,0 +1,114 @@
import { t } from '../localizedFormat/utils';
export default (function (o, c, dayjs) {
// locale needed later
var proto = c.prototype;
var getLocalePart = function getLocalePart(part) {
return part && (part.indexOf ? part : part.s);
};
var getShort = function getShort(ins, target, full, num, localeOrder) {
var locale = ins.name ? ins : ins.$locale();
var targetLocale = getLocalePart(locale[target]);
var fullLocale = getLocalePart(locale[full]);
var result = targetLocale || fullLocale.map(function (f) {
return f.slice(0, num);
});
if (!localeOrder) return result;
var weekStart = locale.weekStart;
return result.map(function (_, index) {
return result[(index + (weekStart || 0)) % 7];
});
};
var getDayjsLocaleObject = function getDayjsLocaleObject() {
return dayjs.Ls[dayjs.locale()];
};
var getLongDateFormat = function getLongDateFormat(l, format) {
return l.formats[format] || t(l.formats[format.toUpperCase()]);
};
var localeData = function localeData() {
var _this = this;
return {
months: function months(instance) {
return instance ? instance.format('MMMM') : getShort(_this, 'months');
},
monthsShort: function monthsShort(instance) {
return instance ? instance.format('MMM') : getShort(_this, 'monthsShort', 'months', 3);
},
firstDayOfWeek: function firstDayOfWeek() {
return _this.$locale().weekStart || 0;
},
weekdays: function weekdays(instance) {
return instance ? instance.format('dddd') : getShort(_this, 'weekdays');
},
weekdaysMin: function weekdaysMin(instance) {
return instance ? instance.format('dd') : getShort(_this, 'weekdaysMin', 'weekdays', 2);
},
weekdaysShort: function weekdaysShort(instance) {
return instance ? instance.format('ddd') : getShort(_this, 'weekdaysShort', 'weekdays', 3);
},
longDateFormat: function longDateFormat(format) {
return getLongDateFormat(_this.$locale(), format);
},
meridiem: this.$locale().meridiem,
ordinal: this.$locale().ordinal
};
};
proto.localeData = function () {
return localeData.bind(this)();
};
dayjs.localeData = function () {
var localeObject = getDayjsLocaleObject();
return {
firstDayOfWeek: function firstDayOfWeek() {
return localeObject.weekStart || 0;
},
weekdays: function weekdays() {
return dayjs.weekdays();
},
weekdaysShort: function weekdaysShort() {
return dayjs.weekdaysShort();
},
weekdaysMin: function weekdaysMin() {
return dayjs.weekdaysMin();
},
months: function months() {
return dayjs.months();
},
monthsShort: function monthsShort() {
return dayjs.monthsShort();
},
longDateFormat: function longDateFormat(format) {
return getLongDateFormat(localeObject, format);
},
meridiem: localeObject.meridiem,
ordinal: localeObject.ordinal
};
};
dayjs.months = function () {
return getShort(getDayjsLocaleObject(), 'months');
};
dayjs.monthsShort = function () {
return getShort(getDayjsLocaleObject(), 'monthsShort', 'months', 3);
};
dayjs.weekdays = function (localeOrder) {
return getShort(getDayjsLocaleObject(), 'weekdays', null, null, localeOrder);
};
dayjs.weekdaysShort = function (localeOrder) {
return getShort(getDayjsLocaleObject(), 'weekdaysShort', 'weekdays', 3, localeOrder);
};
dayjs.weekdaysMin = function (localeOrder) {
return getShort(getDayjsLocaleObject(), 'weekdaysMin', 'weekdays', 2, localeOrder);
};
});

View File

@@ -0,0 +1,20 @@
import { FORMAT_DEFAULT } from '../../constant';
import { u, englishFormats } from './utils';
export default (function (o, c, d) {
var proto = c.prototype;
var oldFormat = proto.format;
d.en.formats = englishFormats;
proto.format = function (formatStr) {
if (formatStr === void 0) {
formatStr = FORMAT_DEFAULT;
}
var _this$$locale = this.$locale(),
_this$$locale$formats = _this$$locale.formats,
formats = _this$$locale$formats === void 0 ? {} : _this$$locale$formats;
var result = u(formatStr, formats);
return oldFormat.call(this, result);
};
});

View File

@@ -0,0 +1,20 @@
// eslint-disable-next-line import/prefer-default-export
export var t = function t(format) {
return format.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, function (_, a, b) {
return a || b.slice(1);
});
};
export var 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 var u = function u(formatStr, formats) {
return formatStr.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, function (_, a, b) {
var B = b && b.toUpperCase();
return a || formats[b] || englishFormats[b] || t(formats[B]);
});
};