dayjs_esm_index.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. // G:/work/project/2024/手机壳DIY/用户端/phone_uni/node_modules/dayjs/esm/constant.js
  2. var SECONDS_A_MINUTE = 60;
  3. var SECONDS_A_HOUR = SECONDS_A_MINUTE * 60;
  4. var SECONDS_A_DAY = SECONDS_A_HOUR * 24;
  5. var SECONDS_A_WEEK = SECONDS_A_DAY * 7;
  6. var MILLISECONDS_A_SECOND = 1e3;
  7. var MILLISECONDS_A_MINUTE = SECONDS_A_MINUTE * MILLISECONDS_A_SECOND;
  8. var MILLISECONDS_A_HOUR = SECONDS_A_HOUR * MILLISECONDS_A_SECOND;
  9. var MILLISECONDS_A_DAY = SECONDS_A_DAY * MILLISECONDS_A_SECOND;
  10. var MILLISECONDS_A_WEEK = SECONDS_A_WEEK * MILLISECONDS_A_SECOND;
  11. var MS = "millisecond";
  12. var S = "second";
  13. var MIN = "minute";
  14. var H = "hour";
  15. var D = "day";
  16. var W = "week";
  17. var M = "month";
  18. var Q = "quarter";
  19. var Y = "year";
  20. var DATE = "date";
  21. var FORMAT_DEFAULT = "YYYY-MM-DDTHH:mm:ssZ";
  22. var INVALID_DATE_STRING = "Invalid Date";
  23. var REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/;
  24. 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;
  25. // G:/work/project/2024/手机壳DIY/用户端/phone_uni/node_modules/dayjs/esm/locale/en.js
  26. var en_default = {
  27. name: "en",
  28. weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
  29. months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
  30. ordinal: function ordinal(n) {
  31. var s = ["th", "st", "nd", "rd"];
  32. var v = n % 100;
  33. return "[" + n + (s[(v - 20) % 10] || s[v] || s[0]) + "]";
  34. }
  35. };
  36. // G:/work/project/2024/手机壳DIY/用户端/phone_uni/node_modules/dayjs/esm/utils.js
  37. var padStart = function padStart2(string, length, pad) {
  38. var s = String(string);
  39. if (!s || s.length >= length)
  40. return string;
  41. return "" + Array(length + 1 - s.length).join(pad) + string;
  42. };
  43. var padZoneStr = function padZoneStr2(instance) {
  44. var negMinutes = -instance.utcOffset();
  45. var minutes = Math.abs(negMinutes);
  46. var hourOffset = Math.floor(minutes / 60);
  47. var minuteOffset = minutes % 60;
  48. return (negMinutes <= 0 ? "+" : "-") + padStart(hourOffset, 2, "0") + ":" + padStart(minuteOffset, 2, "0");
  49. };
  50. var monthDiff = function monthDiff2(a, b) {
  51. if (a.date() < b.date())
  52. return -monthDiff2(b, a);
  53. var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month());
  54. var anchor = a.clone().add(wholeMonthDiff, M);
  55. var c = b - anchor < 0;
  56. var anchor2 = a.clone().add(wholeMonthDiff + (c ? -1 : 1), M);
  57. return +(-(wholeMonthDiff + (b - anchor) / (c ? anchor - anchor2 : anchor2 - anchor)) || 0);
  58. };
  59. var absFloor = function absFloor2(n) {
  60. return n < 0 ? Math.ceil(n) || 0 : Math.floor(n);
  61. };
  62. var prettyUnit = function prettyUnit2(u) {
  63. var special = {
  64. M,
  65. y: Y,
  66. w: W,
  67. d: D,
  68. D: DATE,
  69. h: H,
  70. m: MIN,
  71. s: S,
  72. ms: MS,
  73. Q
  74. };
  75. return special[u] || String(u || "").toLowerCase().replace(/s$/, "");
  76. };
  77. var isUndefined = function isUndefined2(s) {
  78. return s === void 0;
  79. };
  80. var utils_default = {
  81. s: padStart,
  82. z: padZoneStr,
  83. m: monthDiff,
  84. a: absFloor,
  85. p: prettyUnit,
  86. u: isUndefined
  87. };
  88. // G:/work/project/2024/手机壳DIY/用户端/phone_uni/node_modules/dayjs/esm/index.js
  89. var L = "en";
  90. var Ls = {};
  91. Ls[L] = en_default;
  92. var IS_DAYJS = "$isDayjsObject";
  93. var isDayjs = function isDayjs2(d) {
  94. return d instanceof Dayjs || !!(d && d[IS_DAYJS]);
  95. };
  96. var parseLocale = function parseLocale2(preset, object, isLocal) {
  97. var l;
  98. if (!preset)
  99. return L;
  100. if (typeof preset === "string") {
  101. var presetLower = preset.toLowerCase();
  102. if (Ls[presetLower]) {
  103. l = presetLower;
  104. }
  105. if (object) {
  106. Ls[presetLower] = object;
  107. l = presetLower;
  108. }
  109. var presetSplit = preset.split("-");
  110. if (!l && presetSplit.length > 1) {
  111. return parseLocale2(presetSplit[0]);
  112. }
  113. } else {
  114. var name = preset.name;
  115. Ls[name] = preset;
  116. l = name;
  117. }
  118. if (!isLocal && l)
  119. L = l;
  120. return l || !isLocal && L;
  121. };
  122. var dayjs = function dayjs2(date, c) {
  123. if (isDayjs(date)) {
  124. return date.clone();
  125. }
  126. var cfg = typeof c === "object" ? c : {};
  127. cfg.date = date;
  128. cfg.args = arguments;
  129. return new Dayjs(cfg);
  130. };
  131. var wrapper = function wrapper2(date, instance) {
  132. return dayjs(date, {
  133. locale: instance.$L,
  134. utc: instance.$u,
  135. x: instance.$x,
  136. $offset: instance.$offset
  137. // todo: refactor; do not use this.$offset in you code
  138. });
  139. };
  140. var Utils = utils_default;
  141. Utils.l = parseLocale;
  142. Utils.i = isDayjs;
  143. Utils.w = wrapper;
  144. var parseDate = function parseDate2(cfg) {
  145. var date = cfg.date, utc = cfg.utc;
  146. if (date === null)
  147. return /* @__PURE__ */ new Date(NaN);
  148. if (Utils.u(date))
  149. return /* @__PURE__ */ new Date();
  150. if (date instanceof Date)
  151. return new Date(date);
  152. if (typeof date === "string" && !/Z$/i.test(date)) {
  153. var d = date.match(REGEX_PARSE);
  154. if (d) {
  155. var m = d[2] - 1 || 0;
  156. var ms = (d[7] || "0").substring(0, 3);
  157. if (utc) {
  158. return new Date(Date.UTC(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms));
  159. }
  160. return new Date(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms);
  161. }
  162. }
  163. return new Date(date);
  164. };
  165. var Dayjs = function() {
  166. function Dayjs2(cfg) {
  167. this.$L = parseLocale(cfg.locale, null, true);
  168. this.parse(cfg);
  169. this.$x = this.$x || cfg.x || {};
  170. this[IS_DAYJS] = true;
  171. }
  172. var _proto = Dayjs2.prototype;
  173. _proto.parse = function parse(cfg) {
  174. this.$d = parseDate(cfg);
  175. this.init();
  176. };
  177. _proto.init = function init() {
  178. var $d = this.$d;
  179. this.$y = $d.getFullYear();
  180. this.$M = $d.getMonth();
  181. this.$D = $d.getDate();
  182. this.$W = $d.getDay();
  183. this.$H = $d.getHours();
  184. this.$m = $d.getMinutes();
  185. this.$s = $d.getSeconds();
  186. this.$ms = $d.getMilliseconds();
  187. };
  188. _proto.$utils = function $utils() {
  189. return Utils;
  190. };
  191. _proto.isValid = function isValid() {
  192. return !(this.$d.toString() === INVALID_DATE_STRING);
  193. };
  194. _proto.isSame = function isSame(that, units) {
  195. var other = dayjs(that);
  196. return this.startOf(units) <= other && other <= this.endOf(units);
  197. };
  198. _proto.isAfter = function isAfter(that, units) {
  199. return dayjs(that) < this.startOf(units);
  200. };
  201. _proto.isBefore = function isBefore(that, units) {
  202. return this.endOf(units) < dayjs(that);
  203. };
  204. _proto.$g = function $g(input, get, set) {
  205. if (Utils.u(input))
  206. return this[get];
  207. return this.set(set, input);
  208. };
  209. _proto.unix = function unix() {
  210. return Math.floor(this.valueOf() / 1e3);
  211. };
  212. _proto.valueOf = function valueOf() {
  213. return this.$d.getTime();
  214. };
  215. _proto.startOf = function startOf(units, _startOf) {
  216. var _this = this;
  217. var isStartOf = !Utils.u(_startOf) ? _startOf : true;
  218. var unit = Utils.p(units);
  219. var instanceFactory = function instanceFactory2(d, m) {
  220. var ins = Utils.w(_this.$u ? Date.UTC(_this.$y, m, d) : new Date(_this.$y, m, d), _this);
  221. return isStartOf ? ins : ins.endOf(D);
  222. };
  223. var instanceFactorySet = function instanceFactorySet2(method, slice) {
  224. var argumentStart = [0, 0, 0, 0];
  225. var argumentEnd = [23, 59, 59, 999];
  226. return Utils.w(_this.toDate()[method].apply(
  227. // eslint-disable-line prefer-spread
  228. _this.toDate("s"),
  229. (isStartOf ? argumentStart : argumentEnd).slice(slice)
  230. ), _this);
  231. };
  232. var $W = this.$W, $M = this.$M, $D = this.$D;
  233. var utcPad = "set" + (this.$u ? "UTC" : "");
  234. switch (unit) {
  235. case Y:
  236. return isStartOf ? instanceFactory(1, 0) : instanceFactory(31, 11);
  237. case M:
  238. return isStartOf ? instanceFactory(1, $M) : instanceFactory(0, $M + 1);
  239. case W: {
  240. var weekStart = this.$locale().weekStart || 0;
  241. var gap = ($W < weekStart ? $W + 7 : $W) - weekStart;
  242. return instanceFactory(isStartOf ? $D - gap : $D + (6 - gap), $M);
  243. }
  244. case D:
  245. case DATE:
  246. return instanceFactorySet(utcPad + "Hours", 0);
  247. case H:
  248. return instanceFactorySet(utcPad + "Minutes", 1);
  249. case MIN:
  250. return instanceFactorySet(utcPad + "Seconds", 2);
  251. case S:
  252. return instanceFactorySet(utcPad + "Milliseconds", 3);
  253. default:
  254. return this.clone();
  255. }
  256. };
  257. _proto.endOf = function endOf(arg) {
  258. return this.startOf(arg, false);
  259. };
  260. _proto.$set = function $set(units, _int) {
  261. var _C$D$C$DATE$C$M$C$Y$C;
  262. var unit = Utils.p(units);
  263. var utcPad = "set" + (this.$u ? "UTC" : "");
  264. var name = (_C$D$C$DATE$C$M$C$Y$C = {}, _C$D$C$DATE$C$M$C$Y$C[D] = utcPad + "Date", _C$D$C$DATE$C$M$C$Y$C[DATE] = utcPad + "Date", _C$D$C$DATE$C$M$C$Y$C[M] = utcPad + "Month", _C$D$C$DATE$C$M$C$Y$C[Y] = utcPad + "FullYear", _C$D$C$DATE$C$M$C$Y$C[H] = utcPad + "Hours", _C$D$C$DATE$C$M$C$Y$C[MIN] = utcPad + "Minutes", _C$D$C$DATE$C$M$C$Y$C[S] = utcPad + "Seconds", _C$D$C$DATE$C$M$C$Y$C[MS] = utcPad + "Milliseconds", _C$D$C$DATE$C$M$C$Y$C)[unit];
  265. var arg = unit === D ? this.$D + (_int - this.$W) : _int;
  266. if (unit === M || unit === Y) {
  267. var date = this.clone().set(DATE, 1);
  268. date.$d[name](arg);
  269. date.init();
  270. this.$d = date.set(DATE, Math.min(this.$D, date.daysInMonth())).$d;
  271. } else if (name)
  272. this.$d[name](arg);
  273. this.init();
  274. return this;
  275. };
  276. _proto.set = function set(string, _int2) {
  277. return this.clone().$set(string, _int2);
  278. };
  279. _proto.get = function get(unit) {
  280. return this[Utils.p(unit)]();
  281. };
  282. _proto.add = function add(number, units) {
  283. var _this2 = this, _C$MIN$C$H$C$S$unit;
  284. number = Number(number);
  285. var unit = Utils.p(units);
  286. var instanceFactorySet = function instanceFactorySet2(n) {
  287. var d = dayjs(_this2);
  288. return Utils.w(d.date(d.date() + Math.round(n * number)), _this2);
  289. };
  290. if (unit === M) {
  291. return this.set(M, this.$M + number);
  292. }
  293. if (unit === Y) {
  294. return this.set(Y, this.$y + number);
  295. }
  296. if (unit === D) {
  297. return instanceFactorySet(1);
  298. }
  299. if (unit === W) {
  300. return instanceFactorySet(7);
  301. }
  302. var step = (_C$MIN$C$H$C$S$unit = {}, _C$MIN$C$H$C$S$unit[MIN] = MILLISECONDS_A_MINUTE, _C$MIN$C$H$C$S$unit[H] = MILLISECONDS_A_HOUR, _C$MIN$C$H$C$S$unit[S] = MILLISECONDS_A_SECOND, _C$MIN$C$H$C$S$unit)[unit] || 1;
  303. var nextTimeStamp = this.$d.getTime() + number * step;
  304. return Utils.w(nextTimeStamp, this);
  305. };
  306. _proto.subtract = function subtract(number, string) {
  307. return this.add(number * -1, string);
  308. };
  309. _proto.format = function format(formatStr) {
  310. var _this3 = this;
  311. var locale = this.$locale();
  312. if (!this.isValid())
  313. return locale.invalidDate || INVALID_DATE_STRING;
  314. var str = formatStr || FORMAT_DEFAULT;
  315. var zoneStr = Utils.z(this);
  316. var $H = this.$H, $m = this.$m, $M = this.$M;
  317. var weekdays = locale.weekdays, months = locale.months, meridiem = locale.meridiem;
  318. var getShort = function getShort2(arr, index, full, length) {
  319. return arr && (arr[index] || arr(_this3, str)) || full[index].slice(0, length);
  320. };
  321. var get$H = function get$H2(num) {
  322. return Utils.s($H % 12 || 12, num, "0");
  323. };
  324. var meridiemFunc = meridiem || function(hour, minute, isLowercase) {
  325. var m = hour < 12 ? "AM" : "PM";
  326. return isLowercase ? m.toLowerCase() : m;
  327. };
  328. var matches = function matches2(match) {
  329. switch (match) {
  330. case "YY":
  331. return String(_this3.$y).slice(-2);
  332. case "YYYY":
  333. return Utils.s(_this3.$y, 4, "0");
  334. case "M":
  335. return $M + 1;
  336. case "MM":
  337. return Utils.s($M + 1, 2, "0");
  338. case "MMM":
  339. return getShort(locale.monthsShort, $M, months, 3);
  340. case "MMMM":
  341. return getShort(months, $M);
  342. case "D":
  343. return _this3.$D;
  344. case "DD":
  345. return Utils.s(_this3.$D, 2, "0");
  346. case "d":
  347. return String(_this3.$W);
  348. case "dd":
  349. return getShort(locale.weekdaysMin, _this3.$W, weekdays, 2);
  350. case "ddd":
  351. return getShort(locale.weekdaysShort, _this3.$W, weekdays, 3);
  352. case "dddd":
  353. return weekdays[_this3.$W];
  354. case "H":
  355. return String($H);
  356. case "HH":
  357. return Utils.s($H, 2, "0");
  358. case "h":
  359. return get$H(1);
  360. case "hh":
  361. return get$H(2);
  362. case "a":
  363. return meridiemFunc($H, $m, true);
  364. case "A":
  365. return meridiemFunc($H, $m, false);
  366. case "m":
  367. return String($m);
  368. case "mm":
  369. return Utils.s($m, 2, "0");
  370. case "s":
  371. return String(_this3.$s);
  372. case "ss":
  373. return Utils.s(_this3.$s, 2, "0");
  374. case "SSS":
  375. return Utils.s(_this3.$ms, 3, "0");
  376. case "Z":
  377. return zoneStr;
  378. default:
  379. break;
  380. }
  381. return null;
  382. };
  383. return str.replace(REGEX_FORMAT, function(match, $1) {
  384. return $1 || matches(match) || zoneStr.replace(":", "");
  385. });
  386. };
  387. _proto.utcOffset = function utcOffset() {
  388. return -Math.round(this.$d.getTimezoneOffset() / 15) * 15;
  389. };
  390. _proto.diff = function diff(input, units, _float) {
  391. var _this4 = this;
  392. var unit = Utils.p(units);
  393. var that = dayjs(input);
  394. var zoneDelta = (that.utcOffset() - this.utcOffset()) * MILLISECONDS_A_MINUTE;
  395. var diff2 = this - that;
  396. var getMonth = function getMonth2() {
  397. return Utils.m(_this4, that);
  398. };
  399. var result;
  400. switch (unit) {
  401. case Y:
  402. result = getMonth() / 12;
  403. break;
  404. case M:
  405. result = getMonth();
  406. break;
  407. case Q:
  408. result = getMonth() / 3;
  409. break;
  410. case W:
  411. result = (diff2 - zoneDelta) / MILLISECONDS_A_WEEK;
  412. break;
  413. case D:
  414. result = (diff2 - zoneDelta) / MILLISECONDS_A_DAY;
  415. break;
  416. case H:
  417. result = diff2 / MILLISECONDS_A_HOUR;
  418. break;
  419. case MIN:
  420. result = diff2 / MILLISECONDS_A_MINUTE;
  421. break;
  422. case S:
  423. result = diff2 / MILLISECONDS_A_SECOND;
  424. break;
  425. default:
  426. result = diff2;
  427. break;
  428. }
  429. return _float ? result : Utils.a(result);
  430. };
  431. _proto.daysInMonth = function daysInMonth() {
  432. return this.endOf(M).$D;
  433. };
  434. _proto.$locale = function $locale() {
  435. return Ls[this.$L];
  436. };
  437. _proto.locale = function locale(preset, object) {
  438. if (!preset)
  439. return this.$L;
  440. var that = this.clone();
  441. var nextLocaleName = parseLocale(preset, object, true);
  442. if (nextLocaleName)
  443. that.$L = nextLocaleName;
  444. return that;
  445. };
  446. _proto.clone = function clone() {
  447. return Utils.w(this.$d, this);
  448. };
  449. _proto.toDate = function toDate() {
  450. return new Date(this.valueOf());
  451. };
  452. _proto.toJSON = function toJSON() {
  453. return this.isValid() ? this.toISOString() : null;
  454. };
  455. _proto.toISOString = function toISOString() {
  456. return this.$d.toISOString();
  457. };
  458. _proto.toString = function toString() {
  459. return this.$d.toUTCString();
  460. };
  461. return Dayjs2;
  462. }();
  463. var proto = Dayjs.prototype;
  464. dayjs.prototype = proto;
  465. [["$ms", MS], ["$s", S], ["$m", MIN], ["$H", H], ["$W", D], ["$M", M], ["$y", Y], ["$D", DATE]].forEach(function(g) {
  466. proto[g[1]] = function(input) {
  467. return this.$g(input, g[0], g[1]);
  468. };
  469. });
  470. dayjs.extend = function(plugin, option) {
  471. if (!plugin.$i) {
  472. plugin(option, Dayjs, dayjs);
  473. plugin.$i = true;
  474. }
  475. return dayjs;
  476. };
  477. dayjs.locale = parseLocale;
  478. dayjs.isDayjs = isDayjs;
  479. dayjs.unix = function(timestamp) {
  480. return dayjs(timestamp * 1e3);
  481. };
  482. dayjs.en = Ls[L];
  483. dayjs.Ls = Ls;
  484. dayjs.p = {};
  485. var esm_default = dayjs;
  486. export {
  487. esm_default as default
  488. };
  489. //# sourceMappingURL=dayjs_esm_index.js.map