first commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
export var SECONDS_A_MINUTE = 60;
|
||||
export var SECONDS_A_HOUR = SECONDS_A_MINUTE * 60;
|
||||
export var SECONDS_A_DAY = SECONDS_A_HOUR * 24;
|
||||
export var SECONDS_A_WEEK = SECONDS_A_DAY * 7;
|
||||
export var MILLISECONDS_A_SECOND = 1e3;
|
||||
export var MILLISECONDS_A_MINUTE = SECONDS_A_MINUTE * MILLISECONDS_A_SECOND;
|
||||
export var MILLISECONDS_A_HOUR = SECONDS_A_HOUR * MILLISECONDS_A_SECOND;
|
||||
export var MILLISECONDS_A_DAY = SECONDS_A_DAY * MILLISECONDS_A_SECOND;
|
||||
export var MILLISECONDS_A_WEEK = SECONDS_A_WEEK * MILLISECONDS_A_SECOND; // English locales
|
||||
|
||||
export var MS = 'millisecond';
|
||||
export var S = 'second';
|
||||
export var MIN = 'minute';
|
||||
export var H = 'hour';
|
||||
export var D = 'day';
|
||||
export var W = 'week';
|
||||
export var M = 'month';
|
||||
export var Q = 'quarter';
|
||||
export var Y = 'year';
|
||||
export var DATE = 'date';
|
||||
export var FORMAT_DEFAULT = 'YYYY-MM-DDTHH:mm:ssZ';
|
||||
export var INVALID_DATE_STRING = 'Invalid Date'; // regex
|
||||
|
||||
export var REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/;
|
||||
export var REGEX_FORMAT = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;
|
||||
541
uni_modules/tdesign-uniapp/components/npm/dayjs/esm/index.js
Normal file
541
uni_modules/tdesign-uniapp/components/npm/dayjs/esm/index.js
Normal file
@@ -0,0 +1,541 @@
|
||||
import * as C from './constant';
|
||||
import en from './locale/en';
|
||||
import U from './utils';
|
||||
var L = 'en'; // global locale
|
||||
|
||||
var Ls = {}; // global loaded locale
|
||||
|
||||
Ls[L] = en;
|
||||
var IS_DAYJS = '$isDayjsObject'; // eslint-disable-next-line no-use-before-define
|
||||
|
||||
var isDayjs = function isDayjs(d) {
|
||||
return d instanceof Dayjs || !!(d && d[IS_DAYJS]);
|
||||
};
|
||||
|
||||
var parseLocale = function parseLocale(preset, object, isLocal) {
|
||||
var l;
|
||||
if (!preset) return L;
|
||||
|
||||
if (typeof preset === 'string') {
|
||||
var presetLower = preset.toLowerCase();
|
||||
|
||||
if (Ls[presetLower]) {
|
||||
l = presetLower;
|
||||
}
|
||||
|
||||
if (object) {
|
||||
Ls[presetLower] = object;
|
||||
l = presetLower;
|
||||
}
|
||||
|
||||
var presetSplit = preset.split('-');
|
||||
|
||||
if (!l && presetSplit.length > 1) {
|
||||
return parseLocale(presetSplit[0]);
|
||||
}
|
||||
} else {
|
||||
var name = preset.name;
|
||||
Ls[name] = preset;
|
||||
l = name;
|
||||
}
|
||||
|
||||
if (!isLocal && l) L = l;
|
||||
return l || !isLocal && L;
|
||||
};
|
||||
|
||||
var dayjs = function dayjs(date, c) {
|
||||
if (isDayjs(date)) {
|
||||
return date.clone();
|
||||
} // eslint-disable-next-line no-nested-ternary
|
||||
|
||||
|
||||
var cfg = typeof c === 'object' ? c : {};
|
||||
cfg.date = date;
|
||||
cfg.args = arguments; // eslint-disable-line prefer-rest-params
|
||||
|
||||
return new Dayjs(cfg); // eslint-disable-line no-use-before-define
|
||||
};
|
||||
|
||||
var wrapper = function wrapper(date, instance) {
|
||||
return dayjs(date, {
|
||||
locale: instance.$L,
|
||||
utc: instance.$u,
|
||||
x: instance.$x,
|
||||
$offset: instance.$offset // todo: refactor; do not use this.$offset in you code
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
var Utils = U; // for plugin use
|
||||
|
||||
Utils.l = parseLocale;
|
||||
Utils.i = isDayjs;
|
||||
Utils.w = wrapper;
|
||||
|
||||
var parseDate = function parseDate(cfg) {
|
||||
var date = cfg.date,
|
||||
utc = cfg.utc;
|
||||
if (date === null) return new Date(NaN); // null is invalid
|
||||
|
||||
if (Utils.u(date)) return new Date(); // today
|
||||
|
||||
if (date instanceof Date) return new Date(date);
|
||||
|
||||
if (typeof date === 'string' && !/Z$/i.test(date)) {
|
||||
var d = date.match(C.REGEX_PARSE);
|
||||
|
||||
if (d) {
|
||||
var m = d[2] - 1 || 0;
|
||||
var ms = (d[7] || '0').substring(0, 3);
|
||||
|
||||
if (utc) {
|
||||
return new Date(Date.UTC(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms));
|
||||
}
|
||||
|
||||
return new Date(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms);
|
||||
}
|
||||
}
|
||||
|
||||
return new Date(date); // everything else
|
||||
};
|
||||
|
||||
var Dayjs = /*#__PURE__*/function () {
|
||||
function Dayjs(cfg) {
|
||||
this.$L = parseLocale(cfg.locale, null, true);
|
||||
this.parse(cfg); // for plugin
|
||||
|
||||
this.$x = this.$x || cfg.x || {};
|
||||
this[IS_DAYJS] = true;
|
||||
}
|
||||
|
||||
var _proto = Dayjs.prototype;
|
||||
|
||||
_proto.parse = function parse(cfg) {
|
||||
this.$d = parseDate(cfg);
|
||||
this.init();
|
||||
};
|
||||
|
||||
_proto.init = function init() {
|
||||
var $d = this.$d;
|
||||
this.$y = $d.getFullYear();
|
||||
this.$M = $d.getMonth();
|
||||
this.$D = $d.getDate();
|
||||
this.$W = $d.getDay();
|
||||
this.$H = $d.getHours();
|
||||
this.$m = $d.getMinutes();
|
||||
this.$s = $d.getSeconds();
|
||||
this.$ms = $d.getMilliseconds();
|
||||
} // eslint-disable-next-line class-methods-use-this
|
||||
;
|
||||
|
||||
_proto.$utils = function $utils() {
|
||||
return Utils;
|
||||
};
|
||||
|
||||
_proto.isValid = function isValid() {
|
||||
return !(this.$d.toString() === C.INVALID_DATE_STRING);
|
||||
};
|
||||
|
||||
_proto.isSame = function isSame(that, units) {
|
||||
var other = dayjs(that);
|
||||
return this.startOf(units) <= other && other <= this.endOf(units);
|
||||
};
|
||||
|
||||
_proto.isAfter = function isAfter(that, units) {
|
||||
return dayjs(that) < this.startOf(units);
|
||||
};
|
||||
|
||||
_proto.isBefore = function isBefore(that, units) {
|
||||
return this.endOf(units) < dayjs(that);
|
||||
};
|
||||
|
||||
_proto.$g = function $g(input, get, set) {
|
||||
if (Utils.u(input)) return this[get];
|
||||
return this.set(set, input);
|
||||
};
|
||||
|
||||
_proto.unix = function unix() {
|
||||
return Math.floor(this.valueOf() / 1000);
|
||||
};
|
||||
|
||||
_proto.valueOf = function valueOf() {
|
||||
// timezone(hour) * 60 * 60 * 1000 => ms
|
||||
return this.$d.getTime();
|
||||
};
|
||||
|
||||
_proto.startOf = function startOf(units, _startOf) {
|
||||
var _this = this;
|
||||
|
||||
// startOf -> endOf
|
||||
var isStartOf = !Utils.u(_startOf) ? _startOf : true;
|
||||
var unit = Utils.p(units);
|
||||
|
||||
var instanceFactory = function instanceFactory(d, m) {
|
||||
var ins = Utils.w(_this.$u ? Date.UTC(_this.$y, m, d) : new Date(_this.$y, m, d), _this);
|
||||
return isStartOf ? ins : ins.endOf(C.D);
|
||||
};
|
||||
|
||||
var instanceFactorySet = function instanceFactorySet(method, slice) {
|
||||
var argumentStart = [0, 0, 0, 0];
|
||||
var argumentEnd = [23, 59, 59, 999];
|
||||
return Utils.w(_this.toDate()[method].apply( // eslint-disable-line prefer-spread
|
||||
_this.toDate('s'), (isStartOf ? argumentStart : argumentEnd).slice(slice)), _this);
|
||||
};
|
||||
|
||||
var $W = this.$W,
|
||||
$M = this.$M,
|
||||
$D = this.$D;
|
||||
var utcPad = "set" + (this.$u ? 'UTC' : '');
|
||||
|
||||
switch (unit) {
|
||||
case C.Y:
|
||||
return isStartOf ? instanceFactory(1, 0) : instanceFactory(31, 11);
|
||||
|
||||
case C.M:
|
||||
return isStartOf ? instanceFactory(1, $M) : instanceFactory(0, $M + 1);
|
||||
|
||||
case C.W:
|
||||
{
|
||||
var weekStart = this.$locale().weekStart || 0;
|
||||
var gap = ($W < weekStart ? $W + 7 : $W) - weekStart;
|
||||
return instanceFactory(isStartOf ? $D - gap : $D + (6 - gap), $M);
|
||||
}
|
||||
|
||||
case C.D:
|
||||
case C.DATE:
|
||||
return instanceFactorySet(utcPad + "Hours", 0);
|
||||
|
||||
case C.H:
|
||||
return instanceFactorySet(utcPad + "Minutes", 1);
|
||||
|
||||
case C.MIN:
|
||||
return instanceFactorySet(utcPad + "Seconds", 2);
|
||||
|
||||
case C.S:
|
||||
return instanceFactorySet(utcPad + "Milliseconds", 3);
|
||||
|
||||
default:
|
||||
return this.clone();
|
||||
}
|
||||
};
|
||||
|
||||
_proto.endOf = function endOf(arg) {
|
||||
return this.startOf(arg, false);
|
||||
};
|
||||
|
||||
_proto.$set = function $set(units, _int) {
|
||||
var _C$D$C$DATE$C$M$C$Y$C;
|
||||
|
||||
// private set
|
||||
var unit = Utils.p(units);
|
||||
var utcPad = "set" + (this.$u ? 'UTC' : '');
|
||||
var name = (_C$D$C$DATE$C$M$C$Y$C = {}, _C$D$C$DATE$C$M$C$Y$C[C.D] = utcPad + "Date", _C$D$C$DATE$C$M$C$Y$C[C.DATE] = utcPad + "Date", _C$D$C$DATE$C$M$C$Y$C[C.M] = utcPad + "Month", _C$D$C$DATE$C$M$C$Y$C[C.Y] = utcPad + "FullYear", _C$D$C$DATE$C$M$C$Y$C[C.H] = utcPad + "Hours", _C$D$C$DATE$C$M$C$Y$C[C.MIN] = utcPad + "Minutes", _C$D$C$DATE$C$M$C$Y$C[C.S] = utcPad + "Seconds", _C$D$C$DATE$C$M$C$Y$C[C.MS] = utcPad + "Milliseconds", _C$D$C$DATE$C$M$C$Y$C)[unit];
|
||||
var arg = unit === C.D ? this.$D + (_int - this.$W) : _int;
|
||||
|
||||
if (unit === C.M || unit === C.Y) {
|
||||
// clone is for badMutable plugin
|
||||
var date = this.clone().set(C.DATE, 1);
|
||||
date.$d[name](arg);
|
||||
date.init();
|
||||
this.$d = date.set(C.DATE, Math.min(this.$D, date.daysInMonth())).$d;
|
||||
} else if (name) this.$d[name](arg);
|
||||
|
||||
this.init();
|
||||
return this;
|
||||
};
|
||||
|
||||
_proto.set = function set(string, _int2) {
|
||||
return this.clone().$set(string, _int2);
|
||||
};
|
||||
|
||||
_proto.get = function get(unit) {
|
||||
return this[Utils.p(unit)]();
|
||||
};
|
||||
|
||||
_proto.add = function add(number, units) {
|
||||
var _this2 = this,
|
||||
_C$MIN$C$H$C$S$unit;
|
||||
|
||||
number = Number(number); // eslint-disable-line no-param-reassign
|
||||
|
||||
var unit = Utils.p(units);
|
||||
|
||||
var instanceFactorySet = function instanceFactorySet(n) {
|
||||
var d = dayjs(_this2);
|
||||
return Utils.w(d.date(d.date() + Math.round(n * number)), _this2);
|
||||
};
|
||||
|
||||
if (unit === C.M) {
|
||||
return this.set(C.M, this.$M + number);
|
||||
}
|
||||
|
||||
if (unit === C.Y) {
|
||||
return this.set(C.Y, this.$y + number);
|
||||
}
|
||||
|
||||
if (unit === C.D) {
|
||||
return instanceFactorySet(1);
|
||||
}
|
||||
|
||||
if (unit === C.W) {
|
||||
return instanceFactorySet(7);
|
||||
}
|
||||
|
||||
var step = (_C$MIN$C$H$C$S$unit = {}, _C$MIN$C$H$C$S$unit[C.MIN] = C.MILLISECONDS_A_MINUTE, _C$MIN$C$H$C$S$unit[C.H] = C.MILLISECONDS_A_HOUR, _C$MIN$C$H$C$S$unit[C.S] = C.MILLISECONDS_A_SECOND, _C$MIN$C$H$C$S$unit)[unit] || 1; // ms
|
||||
|
||||
var nextTimeStamp = this.$d.getTime() + number * step;
|
||||
return Utils.w(nextTimeStamp, this);
|
||||
};
|
||||
|
||||
_proto.subtract = function subtract(number, string) {
|
||||
return this.add(number * -1, string);
|
||||
};
|
||||
|
||||
_proto.format = function format(formatStr) {
|
||||
var _this3 = this;
|
||||
|
||||
var locale = this.$locale();
|
||||
if (!this.isValid()) return locale.invalidDate || C.INVALID_DATE_STRING;
|
||||
var str = formatStr || C.FORMAT_DEFAULT;
|
||||
var zoneStr = Utils.z(this);
|
||||
var $H = this.$H,
|
||||
$m = this.$m,
|
||||
$M = this.$M;
|
||||
var weekdays = locale.weekdays,
|
||||
months = locale.months,
|
||||
meridiem = locale.meridiem;
|
||||
|
||||
var getShort = function getShort(arr, index, full, length) {
|
||||
return arr && (arr[index] || arr(_this3, str)) || full[index].slice(0, length);
|
||||
};
|
||||
|
||||
var get$H = function get$H(num) {
|
||||
return Utils.s($H % 12 || 12, num, '0');
|
||||
};
|
||||
|
||||
var meridiemFunc = meridiem || function (hour, minute, isLowercase) {
|
||||
var m = hour < 12 ? 'AM' : 'PM';
|
||||
return isLowercase ? m.toLowerCase() : m;
|
||||
};
|
||||
|
||||
var matches = function matches(match) {
|
||||
switch (match) {
|
||||
case 'YY':
|
||||
return String(_this3.$y).slice(-2);
|
||||
|
||||
case 'YYYY':
|
||||
return Utils.s(_this3.$y, 4, '0');
|
||||
|
||||
case 'M':
|
||||
return $M + 1;
|
||||
|
||||
case 'MM':
|
||||
return Utils.s($M + 1, 2, '0');
|
||||
|
||||
case 'MMM':
|
||||
return getShort(locale.monthsShort, $M, months, 3);
|
||||
|
||||
case 'MMMM':
|
||||
return getShort(months, $M);
|
||||
|
||||
case 'D':
|
||||
return _this3.$D;
|
||||
|
||||
case 'DD':
|
||||
return Utils.s(_this3.$D, 2, '0');
|
||||
|
||||
case 'd':
|
||||
return String(_this3.$W);
|
||||
|
||||
case 'dd':
|
||||
return getShort(locale.weekdaysMin, _this3.$W, weekdays, 2);
|
||||
|
||||
case 'ddd':
|
||||
return getShort(locale.weekdaysShort, _this3.$W, weekdays, 3);
|
||||
|
||||
case 'dddd':
|
||||
return weekdays[_this3.$W];
|
||||
|
||||
case 'H':
|
||||
return String($H);
|
||||
|
||||
case 'HH':
|
||||
return Utils.s($H, 2, '0');
|
||||
|
||||
case 'h':
|
||||
return get$H(1);
|
||||
|
||||
case 'hh':
|
||||
return get$H(2);
|
||||
|
||||
case 'a':
|
||||
return meridiemFunc($H, $m, true);
|
||||
|
||||
case 'A':
|
||||
return meridiemFunc($H, $m, false);
|
||||
|
||||
case 'm':
|
||||
return String($m);
|
||||
|
||||
case 'mm':
|
||||
return Utils.s($m, 2, '0');
|
||||
|
||||
case 's':
|
||||
return String(_this3.$s);
|
||||
|
||||
case 'ss':
|
||||
return Utils.s(_this3.$s, 2, '0');
|
||||
|
||||
case 'SSS':
|
||||
return Utils.s(_this3.$ms, 3, '0');
|
||||
|
||||
case 'Z':
|
||||
return zoneStr;
|
||||
// 'ZZ' logic below
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
return str.replace(C.REGEX_FORMAT, function (match, $1) {
|
||||
return $1 || matches(match) || zoneStr.replace(':', '');
|
||||
}); // 'ZZ'
|
||||
};
|
||||
|
||||
_proto.utcOffset = function utcOffset() {
|
||||
// Because a bug at FF24, we're rounding the timezone offset around 15 minutes
|
||||
// https://github.com/moment/moment/pull/1871
|
||||
return -Math.round(this.$d.getTimezoneOffset() / 15) * 15;
|
||||
};
|
||||
|
||||
_proto.diff = function diff(input, units, _float) {
|
||||
var _this4 = this;
|
||||
|
||||
var unit = Utils.p(units);
|
||||
var that = dayjs(input);
|
||||
var zoneDelta = (that.utcOffset() - this.utcOffset()) * C.MILLISECONDS_A_MINUTE;
|
||||
var diff = this - that;
|
||||
|
||||
var getMonth = function getMonth() {
|
||||
return Utils.m(_this4, that);
|
||||
};
|
||||
|
||||
var result;
|
||||
|
||||
switch (unit) {
|
||||
case C.Y:
|
||||
result = getMonth() / 12;
|
||||
break;
|
||||
|
||||
case C.M:
|
||||
result = getMonth();
|
||||
break;
|
||||
|
||||
case C.Q:
|
||||
result = getMonth() / 3;
|
||||
break;
|
||||
|
||||
case C.W:
|
||||
result = (diff - zoneDelta) / C.MILLISECONDS_A_WEEK;
|
||||
break;
|
||||
|
||||
case C.D:
|
||||
result = (diff - zoneDelta) / C.MILLISECONDS_A_DAY;
|
||||
break;
|
||||
|
||||
case C.H:
|
||||
result = diff / C.MILLISECONDS_A_HOUR;
|
||||
break;
|
||||
|
||||
case C.MIN:
|
||||
result = diff / C.MILLISECONDS_A_MINUTE;
|
||||
break;
|
||||
|
||||
case C.S:
|
||||
result = diff / C.MILLISECONDS_A_SECOND;
|
||||
break;
|
||||
|
||||
default:
|
||||
result = diff; // milliseconds
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return _float ? result : Utils.a(result);
|
||||
};
|
||||
|
||||
_proto.daysInMonth = function daysInMonth() {
|
||||
return this.endOf(C.M).$D;
|
||||
};
|
||||
|
||||
_proto.$locale = function $locale() {
|
||||
// get locale object
|
||||
return Ls[this.$L];
|
||||
};
|
||||
|
||||
_proto.locale = function locale(preset, object) {
|
||||
if (!preset) return this.$L;
|
||||
var that = this.clone();
|
||||
var nextLocaleName = parseLocale(preset, object, true);
|
||||
if (nextLocaleName) that.$L = nextLocaleName;
|
||||
return that;
|
||||
};
|
||||
|
||||
_proto.clone = function clone() {
|
||||
return Utils.w(this.$d, this);
|
||||
};
|
||||
|
||||
_proto.toDate = function toDate() {
|
||||
return new Date(this.valueOf());
|
||||
};
|
||||
|
||||
_proto.toJSON = function toJSON() {
|
||||
return this.isValid() ? this.toISOString() : null;
|
||||
};
|
||||
|
||||
_proto.toISOString = function toISOString() {
|
||||
// ie 8 return
|
||||
// new Dayjs(this.valueOf() + this.$d.getTimezoneOffset() * 60000)
|
||||
// .format('YYYY-MM-DDTHH:mm:ss.SSS[Z]')
|
||||
return this.$d.toISOString();
|
||||
};
|
||||
|
||||
_proto.toString = function toString() {
|
||||
return this.$d.toUTCString();
|
||||
};
|
||||
|
||||
return Dayjs;
|
||||
}();
|
||||
|
||||
var proto = Dayjs.prototype;
|
||||
dayjs.prototype = proto;
|
||||
[['$ms', C.MS], ['$s', C.S], ['$m', C.MIN], ['$H', C.H], ['$W', C.D], ['$M', C.M], ['$y', C.Y], ['$D', C.DATE]].forEach(function (g) {
|
||||
proto[g[1]] = function (input) {
|
||||
return this.$g(input, g[0], g[1]);
|
||||
};
|
||||
});
|
||||
|
||||
dayjs.extend = function (plugin, option) {
|
||||
if (!plugin.$i) {
|
||||
// install plugin only once
|
||||
plugin(option, Dayjs, dayjs);
|
||||
plugin.$i = true;
|
||||
}
|
||||
|
||||
return dayjs;
|
||||
};
|
||||
|
||||
dayjs.locale = parseLocale;
|
||||
dayjs.isDayjs = isDayjs;
|
||||
|
||||
dayjs.unix = function (timestamp) {
|
||||
return dayjs(timestamp * 1e3);
|
||||
};
|
||||
|
||||
dayjs.en = Ls[L];
|
||||
dayjs.Ls = Ls;
|
||||
dayjs.p = {};
|
||||
export default dayjs;
|
||||
@@ -0,0 +1,12 @@
|
||||
// English [en]
|
||||
// We don't need weekdaysShort, weekdaysMin, monthsShort in en.js locale
|
||||
export default {
|
||||
name: 'en',
|
||||
weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
|
||||
months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
|
||||
ordinal: function ordinal(n) {
|
||||
var s = ['th', 'st', 'nd', 'rd'];
|
||||
var v = n % 100;
|
||||
return "[" + n + (s[(v - 20) % 10] || s[v] || s[0]) + "]";
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
// Japanese [ja]
|
||||
import dayjs from '../index';
|
||||
var locale = {
|
||||
name: 'ja',
|
||||
weekdays: '日曜日_月曜日_火曜日_水曜日_木曜日_金曜日_土曜日'.split('_'),
|
||||
weekdaysShort: '日_月_火_水_木_金_土'.split('_'),
|
||||
weekdaysMin: '日_月_火_水_木_金_土'.split('_'),
|
||||
months: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
|
||||
monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
|
||||
ordinal: function ordinal(n) {
|
||||
return n + "\u65E5";
|
||||
},
|
||||
formats: {
|
||||
LT: 'HH:mm',
|
||||
LTS: 'HH:mm:ss',
|
||||
L: 'YYYY/MM/DD',
|
||||
LL: 'YYYY年M月D日',
|
||||
LLL: 'YYYY年M月D日 HH:mm',
|
||||
LLLL: 'YYYY年M月D日 dddd HH:mm',
|
||||
l: 'YYYY/MM/DD',
|
||||
ll: 'YYYY年M月D日',
|
||||
lll: 'YYYY年M月D日 HH:mm',
|
||||
llll: 'YYYY年M月D日(ddd) HH:mm'
|
||||
},
|
||||
meridiem: function meridiem(hour) {
|
||||
return hour < 12 ? '午前' : '午後';
|
||||
},
|
||||
relativeTime: {
|
||||
future: '%s後',
|
||||
past: '%s前',
|
||||
s: '数秒',
|
||||
m: '1分',
|
||||
mm: '%d分',
|
||||
h: '1時間',
|
||||
hh: '%d時間',
|
||||
d: '1日',
|
||||
dd: '%d日',
|
||||
M: '1ヶ月',
|
||||
MM: '%dヶ月',
|
||||
y: '1年',
|
||||
yy: '%d年'
|
||||
}
|
||||
};
|
||||
dayjs.locale(locale, null, true);
|
||||
export default locale;
|
||||
@@ -0,0 +1,45 @@
|
||||
// Korean [ko]
|
||||
import dayjs from '../index';
|
||||
var locale = {
|
||||
name: 'ko',
|
||||
weekdays: '일요일_월요일_화요일_수요일_목요일_금요일_토요일'.split('_'),
|
||||
weekdaysShort: '일_월_화_수_목_금_토'.split('_'),
|
||||
weekdaysMin: '일_월_화_수_목_금_토'.split('_'),
|
||||
months: '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'),
|
||||
monthsShort: '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'),
|
||||
ordinal: function ordinal(n) {
|
||||
return n + "\uC77C";
|
||||
},
|
||||
formats: {
|
||||
LT: 'A h:mm',
|
||||
LTS: 'A h:mm:ss',
|
||||
L: 'YYYY.MM.DD.',
|
||||
LL: 'YYYY년 MMMM D일',
|
||||
LLL: 'YYYY년 MMMM D일 A h:mm',
|
||||
LLLL: 'YYYY년 MMMM D일 dddd A h:mm',
|
||||
l: 'YYYY.MM.DD.',
|
||||
ll: 'YYYY년 MMMM D일',
|
||||
lll: 'YYYY년 MMMM D일 A h:mm',
|
||||
llll: 'YYYY년 MMMM D일 dddd A h:mm'
|
||||
},
|
||||
meridiem: function meridiem(hour) {
|
||||
return hour < 12 ? '오전' : '오후';
|
||||
},
|
||||
relativeTime: {
|
||||
future: '%s 후',
|
||||
past: '%s 전',
|
||||
s: '몇 초',
|
||||
m: '1분',
|
||||
mm: '%d분',
|
||||
h: '한 시간',
|
||||
hh: '%d시간',
|
||||
d: '하루',
|
||||
dd: '%d일',
|
||||
M: '한 달',
|
||||
MM: '%d달',
|
||||
y: '일 년',
|
||||
yy: '%d년'
|
||||
}
|
||||
};
|
||||
dayjs.locale(locale, null, true);
|
||||
export default locale;
|
||||
@@ -0,0 +1,99 @@
|
||||
// Russian [ru]
|
||||
import dayjs from '../index';
|
||||
var monthFormat = 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_');
|
||||
var monthStandalone = 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_');
|
||||
var monthShortFormat = 'янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.'.split('_');
|
||||
var monthShortStandalone = 'янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.'.split('_');
|
||||
var MONTHS_IN_FORMAT = /D[oD]?(\[[^[\]]*\]|\s)+MMMM?/;
|
||||
|
||||
function plural(word, num) {
|
||||
var forms = word.split('_');
|
||||
return num % 10 === 1 && num % 100 !== 11 ? forms[0] : num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]; // eslint-disable-line
|
||||
}
|
||||
|
||||
function relativeTimeWithPlural(number, withoutSuffix, key) {
|
||||
var format = {
|
||||
mm: withoutSuffix ? 'минута_минуты_минут' : 'минуту_минуты_минут',
|
||||
hh: 'час_часа_часов',
|
||||
dd: 'день_дня_дней',
|
||||
MM: 'месяц_месяца_месяцев',
|
||||
yy: 'год_года_лет'
|
||||
};
|
||||
|
||||
if (key === 'm') {
|
||||
return withoutSuffix ? 'минута' : 'минуту';
|
||||
}
|
||||
|
||||
return number + " " + plural(format[key], +number);
|
||||
}
|
||||
|
||||
var months = function months(dayjsInstance, format) {
|
||||
if (MONTHS_IN_FORMAT.test(format)) {
|
||||
return monthFormat[dayjsInstance.month()];
|
||||
}
|
||||
|
||||
return monthStandalone[dayjsInstance.month()];
|
||||
};
|
||||
|
||||
months.s = monthStandalone;
|
||||
months.f = monthFormat;
|
||||
|
||||
var monthsShort = function monthsShort(dayjsInstance, format) {
|
||||
if (MONTHS_IN_FORMAT.test(format)) {
|
||||
return monthShortFormat[dayjsInstance.month()];
|
||||
}
|
||||
|
||||
return monthShortStandalone[dayjsInstance.month()];
|
||||
};
|
||||
|
||||
monthsShort.s = monthShortStandalone;
|
||||
monthsShort.f = monthShortFormat;
|
||||
var locale = {
|
||||
name: 'ru',
|
||||
weekdays: 'воскресенье_понедельник_вторник_среда_четверг_пятница_суббота'.split('_'),
|
||||
weekdaysShort: 'вск_пнд_втр_срд_чтв_птн_сбт'.split('_'),
|
||||
weekdaysMin: 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
|
||||
months: months,
|
||||
monthsShort: monthsShort,
|
||||
weekStart: 1,
|
||||
yearStart: 4,
|
||||
formats: {
|
||||
LT: 'H:mm',
|
||||
LTS: 'H:mm:ss',
|
||||
L: 'DD.MM.YYYY',
|
||||
LL: 'D MMMM YYYY г.',
|
||||
LLL: 'D MMMM YYYY г., H:mm',
|
||||
LLLL: 'dddd, D MMMM YYYY г., H:mm'
|
||||
},
|
||||
relativeTime: {
|
||||
future: 'через %s',
|
||||
past: '%s назад',
|
||||
s: 'несколько секунд',
|
||||
m: relativeTimeWithPlural,
|
||||
mm: relativeTimeWithPlural,
|
||||
h: 'час',
|
||||
hh: relativeTimeWithPlural,
|
||||
d: 'день',
|
||||
dd: relativeTimeWithPlural,
|
||||
M: 'месяц',
|
||||
MM: relativeTimeWithPlural,
|
||||
y: 'год',
|
||||
yy: relativeTimeWithPlural
|
||||
},
|
||||
ordinal: function ordinal(n) {
|
||||
return n;
|
||||
},
|
||||
meridiem: function meridiem(hour) {
|
||||
if (hour < 4) {
|
||||
return 'ночи';
|
||||
} else if (hour < 12) {
|
||||
return 'утра';
|
||||
} else if (hour < 17) {
|
||||
return 'дня';
|
||||
}
|
||||
|
||||
return 'вечера';
|
||||
}
|
||||
};
|
||||
dayjs.locale(locale, null, true);
|
||||
export default locale;
|
||||
@@ -0,0 +1,67 @@
|
||||
// Chinese (China) [zh-cn]
|
||||
import dayjs from '../index';
|
||||
var locale = {
|
||||
name: 'zh-cn',
|
||||
weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
|
||||
weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
|
||||
weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
|
||||
months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
|
||||
monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
|
||||
ordinal: function ordinal(number, period) {
|
||||
switch (period) {
|
||||
case 'W':
|
||||
return number + "\u5468";
|
||||
|
||||
default:
|
||||
return number + "\u65E5";
|
||||
}
|
||||
},
|
||||
weekStart: 1,
|
||||
yearStart: 4,
|
||||
formats: {
|
||||
LT: 'HH:mm',
|
||||
LTS: 'HH:mm:ss',
|
||||
L: 'YYYY/MM/DD',
|
||||
LL: 'YYYY年M月D日',
|
||||
LLL: 'YYYY年M月D日Ah点mm分',
|
||||
LLLL: 'YYYY年M月D日ddddAh点mm分',
|
||||
l: 'YYYY/M/D',
|
||||
ll: 'YYYY年M月D日',
|
||||
lll: 'YYYY年M月D日 HH:mm',
|
||||
llll: 'YYYY年M月D日dddd HH:mm'
|
||||
},
|
||||
relativeTime: {
|
||||
future: '%s内',
|
||||
past: '%s前',
|
||||
s: '几秒',
|
||||
m: '1 分钟',
|
||||
mm: '%d 分钟',
|
||||
h: '1 小时',
|
||||
hh: '%d 小时',
|
||||
d: '1 天',
|
||||
dd: '%d 天',
|
||||
M: '1 个月',
|
||||
MM: '%d 个月',
|
||||
y: '1 年',
|
||||
yy: '%d 年'
|
||||
},
|
||||
meridiem: function meridiem(hour, minute) {
|
||||
var hm = hour * 100 + minute;
|
||||
|
||||
if (hm < 600) {
|
||||
return '凌晨';
|
||||
} else if (hm < 900) {
|
||||
return '早上';
|
||||
} else if (hm < 1100) {
|
||||
return '上午';
|
||||
} else if (hm < 1300) {
|
||||
return '中午';
|
||||
} else if (hm < 1800) {
|
||||
return '下午';
|
||||
}
|
||||
|
||||
return '晚上';
|
||||
}
|
||||
};
|
||||
dayjs.locale(locale, null, true);
|
||||
export default locale;
|
||||
@@ -0,0 +1,65 @@
|
||||
// Chinese (Taiwan) [zh-tw]
|
||||
import dayjs from '../index';
|
||||
var locale = {
|
||||
name: 'zh-tw',
|
||||
weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
|
||||
weekdaysShort: '週日_週一_週二_週三_週四_週五_週六'.split('_'),
|
||||
weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
|
||||
months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
|
||||
monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
|
||||
ordinal: function ordinal(number, period) {
|
||||
switch (period) {
|
||||
case 'W':
|
||||
return number + "\u9031";
|
||||
|
||||
default:
|
||||
return number + "\u65E5";
|
||||
}
|
||||
},
|
||||
formats: {
|
||||
LT: 'HH:mm',
|
||||
LTS: 'HH:mm:ss',
|
||||
L: 'YYYY/MM/DD',
|
||||
LL: 'YYYY年M月D日',
|
||||
LLL: 'YYYY年M月D日 HH:mm',
|
||||
LLLL: 'YYYY年M月D日dddd HH:mm',
|
||||
l: 'YYYY/M/D',
|
||||
ll: 'YYYY年M月D日',
|
||||
lll: 'YYYY年M月D日 HH:mm',
|
||||
llll: 'YYYY年M月D日dddd HH:mm'
|
||||
},
|
||||
relativeTime: {
|
||||
future: '%s內',
|
||||
past: '%s前',
|
||||
s: '幾秒',
|
||||
m: '1 分鐘',
|
||||
mm: '%d 分鐘',
|
||||
h: '1 小時',
|
||||
hh: '%d 小時',
|
||||
d: '1 天',
|
||||
dd: '%d 天',
|
||||
M: '1 個月',
|
||||
MM: '%d 個月',
|
||||
y: '1 年',
|
||||
yy: '%d 年'
|
||||
},
|
||||
meridiem: function meridiem(hour, minute) {
|
||||
var hm = hour * 100 + minute;
|
||||
|
||||
if (hm < 600) {
|
||||
return '凌晨';
|
||||
} else if (hm < 900) {
|
||||
return '早上';
|
||||
} else if (hm < 1100) {
|
||||
return '上午';
|
||||
} else if (hm < 1300) {
|
||||
return '中午';
|
||||
} else if (hm < 1800) {
|
||||
return '下午';
|
||||
}
|
||||
|
||||
return '晚上';
|
||||
}
|
||||
};
|
||||
dayjs.locale(locale, null, true);
|
||||
export default locale;
|
||||
@@ -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);
|
||||
};
|
||||
});
|
||||
@@ -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);
|
||||
};
|
||||
});
|
||||
@@ -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]);
|
||||
});
|
||||
};
|
||||
58
uni_modules/tdesign-uniapp/components/npm/dayjs/esm/utils.js
Normal file
58
uni_modules/tdesign-uniapp/components/npm/dayjs/esm/utils.js
Normal file
@@ -0,0 +1,58 @@
|
||||
import * as C from './constant';
|
||||
|
||||
var padStart = function padStart(string, length, pad) {
|
||||
var s = String(string);
|
||||
if (!s || s.length >= length) return string;
|
||||
return "" + Array(length + 1 - s.length).join(pad) + string;
|
||||
};
|
||||
|
||||
var padZoneStr = function padZoneStr(instance) {
|
||||
var negMinutes = -instance.utcOffset();
|
||||
var minutes = Math.abs(negMinutes);
|
||||
var hourOffset = Math.floor(minutes / 60);
|
||||
var minuteOffset = minutes % 60;
|
||||
return "" + (negMinutes <= 0 ? '+' : '-') + padStart(hourOffset, 2, '0') + ":" + padStart(minuteOffset, 2, '0');
|
||||
};
|
||||
|
||||
var monthDiff = function monthDiff(a, b) {
|
||||
// function from moment.js in order to keep the same result
|
||||
if (a.date() < b.date()) return -monthDiff(b, a);
|
||||
var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month());
|
||||
var anchor = a.clone().add(wholeMonthDiff, C.M);
|
||||
var c = b - anchor < 0;
|
||||
var anchor2 = a.clone().add(wholeMonthDiff + (c ? -1 : 1), C.M);
|
||||
return +(-(wholeMonthDiff + (b - anchor) / (c ? anchor - anchor2 : anchor2 - anchor)) || 0);
|
||||
};
|
||||
|
||||
var absFloor = function absFloor(n) {
|
||||
return n < 0 ? Math.ceil(n) || 0 : Math.floor(n);
|
||||
};
|
||||
|
||||
var prettyUnit = function prettyUnit(u) {
|
||||
var special = {
|
||||
M: C.M,
|
||||
y: C.Y,
|
||||
w: C.W,
|
||||
d: C.D,
|
||||
D: C.DATE,
|
||||
h: C.H,
|
||||
m: C.MIN,
|
||||
s: C.S,
|
||||
ms: C.MS,
|
||||
Q: C.Q
|
||||
};
|
||||
return special[u] || String(u || '').toLowerCase().replace(/s$/, '');
|
||||
};
|
||||
|
||||
var isUndefined = function isUndefined(s) {
|
||||
return s === undefined;
|
||||
};
|
||||
|
||||
export default {
|
||||
s: padStart,
|
||||
z: padZoneStr,
|
||||
m: monthDiff,
|
||||
a: absFloor,
|
||||
p: prettyUnit,
|
||||
u: isUndefined
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user