dayjs.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. var __getOwnPropNames = Object.getOwnPropertyNames;
  2. var __commonJS = (cb, mod) => function __require() {
  3. return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
  4. };
  5. var require_dayjs_min = __commonJS({
  6. "uvuidayjs"(exports, module) {
  7. !function(t, e) {
  8. "object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).dayjs = e();
  9. }(exports, function() {
  10. "use strict";
  11. var t = 1e3, e = 6e4, n = 36e5, r = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", f = "month", h = "quarter", c = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|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, M = { 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(t2) {
  12. var e2 = ["th", "st", "nd", "rd"], n2 = t2 % 100;
  13. return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
  14. } }, m = function(t2, e2, n2) {
  15. var r2 = String(t2);
  16. return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n2) + t2;
  17. }, v = { s: m, z: function(t2) {
  18. var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r2 = Math.floor(n2 / 60), i2 = n2 % 60;
  19. return (e2 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i2, 2, "0");
  20. }, m: function t2(e2, n2) {
  21. if (e2.date() < n2.date())
  22. return -t2(n2, e2);
  23. var r2 = 12 * (n2.year() - e2.year()) + (n2.month() - e2.month()), i2 = e2.clone().add(r2, f), s2 = n2 - i2 < 0, u2 = e2.clone().add(r2 + (s2 ? -1 : 1), f);
  24. return +(-(r2 + (n2 - i2) / (s2 ? i2 - u2 : u2 - i2)) || 0);
  25. }, a: function(t2) {
  26. return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
  27. }, p: function(t2) {
  28. return { M: f, y: c, w: o, d: a, D: d, h: u, m: s, s: i, ms: r, Q: h }[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
  29. }, u: function(t2) {
  30. return void 0 === t2;
  31. } }, g = "en", D = {};
  32. D[g] = M;
  33. var p = function(t2) {
  34. return t2 instanceof _;
  35. }, S = function t2(e2, n2, r2) {
  36. var i2;
  37. if (!e2)
  38. return g;
  39. if ("string" == typeof e2) {
  40. var s2 = e2.toLowerCase();
  41. D[s2] && (i2 = s2), n2 && (D[s2] = n2, i2 = s2);
  42. var u2 = e2.split("-");
  43. if (!i2 && u2.length > 1)
  44. return t2(u2[0]);
  45. } else {
  46. var a2 = e2.name;
  47. D[a2] = e2, i2 = a2;
  48. }
  49. return !r2 && i2 && (g = i2), i2 || !r2 && g;
  50. }, w = function(t2, e2) {
  51. if (p(t2))
  52. return t2.clone();
  53. var n2 = "object" == typeof e2 ? e2 : {};
  54. return n2.date = t2, n2.args = arguments, new _(n2);
  55. }, O = v;
  56. O.l = S, O.i = p, O.w = function(t2, e2) {
  57. return w(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset });
  58. };
  59. var _ = function() {
  60. function M2(t2) {
  61. this.$L = S(t2.locale, null, true), this.parse(t2);
  62. }
  63. var m2 = M2.prototype;
  64. return m2.parse = function(t2) {
  65. this.$d = function(t3) {
  66. var e2 = t3.date, n2 = t3.utc;
  67. if (null === e2)
  68. return new Date(NaN);
  69. if (O.u(e2))
  70. return new Date();
  71. if (e2 instanceof Date)
  72. return new Date(e2);
  73. if ("string" == typeof e2 && !/Z$/i.test(e2)) {
  74. var r2 = e2.match($);
  75. if (r2) {
  76. var i2 = r2[2] - 1 || 0, s2 = (r2[7] || "0").substring(0, 3);
  77. return n2 ? new Date(Date.UTC(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2)) : new Date(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2);
  78. }
  79. }
  80. return new Date(e2);
  81. }(t2), this.$x = t2.x || {}, this.init();
  82. }, m2.init = function() {
  83. var t2 = this.$d;
  84. this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds();
  85. }, m2.$utils = function() {
  86. return O;
  87. }, m2.isValid = function() {
  88. return !(this.$d.toString() === l);
  89. }, m2.isSame = function(t2, e2) {
  90. var n2 = w(t2);
  91. return this.startOf(e2) <= n2 && n2 <= this.endOf(e2);
  92. }, m2.isAfter = function(t2, e2) {
  93. return w(t2) < this.startOf(e2);
  94. }, m2.isBefore = function(t2, e2) {
  95. return this.endOf(e2) < w(t2);
  96. }, m2.$g = function(t2, e2, n2) {
  97. return O.u(t2) ? this[e2] : this.set(n2, t2);
  98. }, m2.unix = function() {
  99. return Math.floor(this.valueOf() / 1e3);
  100. }, m2.valueOf = function() {
  101. return this.$d.getTime();
  102. }, m2.startOf = function(t2, e2) {
  103. var n2 = this, r2 = !!O.u(e2) || e2, h2 = O.p(t2), l2 = function(t3, e3) {
  104. var i2 = O.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2);
  105. return r2 ? i2 : i2.endOf(a);
  106. }, $2 = function(t3, e3) {
  107. return O.w(n2.toDate()[t3].apply(n2.toDate("s"), (r2 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e3)), n2);
  108. }, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : "");
  109. switch (h2) {
  110. case c:
  111. return r2 ? l2(1, 0) : l2(31, 11);
  112. case f:
  113. return r2 ? l2(1, M3) : l2(0, M3 + 1);
  114. case o:
  115. var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2;
  116. return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3);
  117. case a:
  118. case d:
  119. return $2(v2 + "Hours", 0);
  120. case u:
  121. return $2(v2 + "Minutes", 1);
  122. case s:
  123. return $2(v2 + "Seconds", 2);
  124. case i:
  125. return $2(v2 + "Milliseconds", 3);
  126. default:
  127. return this.clone();
  128. }
  129. }, m2.endOf = function(t2) {
  130. return this.startOf(t2, false);
  131. }, m2.$set = function(t2, e2) {
  132. var n2, o2 = O.p(t2), h2 = "set" + (this.$u ? "UTC" : ""), l2 = (n2 = {}, n2[a] = h2 + "Date", n2[d] = h2 + "Date", n2[f] = h2 + "Month", n2[c] = h2 + "FullYear", n2[u] = h2 + "Hours", n2[s] = h2 + "Minutes", n2[i] = h2 + "Seconds", n2[r] = h2 + "Milliseconds", n2)[o2], $2 = o2 === a ? this.$D + (e2 - this.$W) : e2;
  133. if (o2 === f || o2 === c) {
  134. var y2 = this.clone().set(d, 1);
  135. y2.$d[l2]($2), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d;
  136. } else
  137. l2 && this.$d[l2]($2);
  138. return this.init(), this;
  139. }, m2.set = function(t2, e2) {
  140. return this.clone().$set(t2, e2);
  141. }, m2.get = function(t2) {
  142. return this[O.p(t2)]();
  143. }, m2.add = function(r2, h2) {
  144. var d2, l2 = this;
  145. r2 = Number(r2);
  146. var $2 = O.p(h2), y2 = function(t2) {
  147. var e2 = w(l2);
  148. return O.w(e2.date(e2.date() + Math.round(t2 * r2)), l2);
  149. };
  150. if ($2 === f)
  151. return this.set(f, this.$M + r2);
  152. if ($2 === c)
  153. return this.set(c, this.$y + r2);
  154. if ($2 === a)
  155. return y2(1);
  156. if ($2 === o)
  157. return y2(7);
  158. var M3 = (d2 = {}, d2[s] = e, d2[u] = n, d2[i] = t, d2)[$2] || 1, m3 = this.$d.getTime() + r2 * M3;
  159. return O.w(m3, this);
  160. }, m2.subtract = function(t2, e2) {
  161. return this.add(-1 * t2, e2);
  162. }, m2.format = function(t2) {
  163. var e2 = this, n2 = this.$locale();
  164. if (!this.isValid())
  165. return n2.invalidDate || l;
  166. var r2 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i2 = O.z(this), s2 = this.$H, u2 = this.$m, a2 = this.$M, o2 = n2.weekdays, f2 = n2.months, h2 = function(t3, n3, i3, s3) {
  167. return t3 && (t3[n3] || t3(e2, r2)) || i3[n3].slice(0, s3);
  168. }, c2 = function(t3) {
  169. return O.s(s2 % 12 || 12, t3, "0");
  170. }, d2 = n2.meridiem || function(t3, e3, n3) {
  171. var r3 = t3 < 12 ? "AM" : "PM";
  172. return n3 ? r3.toLowerCase() : r3;
  173. }, $2 = { YY: String(this.$y).slice(-2), YYYY: this.$y, M: a2 + 1, MM: O.s(a2 + 1, 2, "0"), MMM: h2(n2.monthsShort, a2, f2, 3), MMMM: h2(f2, a2), D: this.$D, DD: O.s(this.$D, 2, "0"), d: String(this.$W), dd: h2(n2.weekdaysMin, this.$W, o2, 2), ddd: h2(n2.weekdaysShort, this.$W, o2, 3), dddd: o2[this.$W], H: String(s2), HH: O.s(s2, 2, "0"), h: c2(1), hh: c2(2), a: d2(s2, u2, true), A: d2(s2, u2, false), m: String(u2), mm: O.s(u2, 2, "0"), s: String(this.$s), ss: O.s(this.$s, 2, "0"), SSS: O.s(this.$ms, 3, "0"), Z: i2 };
  174. return r2.replace(y, function(t3, e3) {
  175. return e3 || $2[t3] || i2.replace(":", "");
  176. });
  177. }, m2.utcOffset = function() {
  178. return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
  179. }, m2.diff = function(r2, d2, l2) {
  180. var $2, y2 = O.p(d2), M3 = w(r2), m3 = (M3.utcOffset() - this.utcOffset()) * e, v2 = this - M3, g2 = O.m(this, M3);
  181. return g2 = ($2 = {}, $2[c] = g2 / 12, $2[f] = g2, $2[h] = g2 / 3, $2[o] = (v2 - m3) / 6048e5, $2[a] = (v2 - m3) / 864e5, $2[u] = v2 / n, $2[s] = v2 / e, $2[i] = v2 / t, $2)[y2] || v2, l2 ? g2 : O.a(g2);
  182. }, m2.daysInMonth = function() {
  183. return this.endOf(f).$D;
  184. }, m2.$locale = function() {
  185. return D[this.$L];
  186. }, m2.locale = function(t2, e2) {
  187. if (!t2)
  188. return this.$L;
  189. var n2 = this.clone(), r2 = S(t2, e2, true);
  190. return r2 && (n2.$L = r2), n2;
  191. }, m2.clone = function() {
  192. return O.w(this.$d, this);
  193. }, m2.toDate = function() {
  194. return new Date(this.valueOf());
  195. }, m2.toJSON = function() {
  196. return this.isValid() ? this.toISOString() : null;
  197. }, m2.toISOString = function() {
  198. return this.$d.toISOString();
  199. }, m2.toString = function() {
  200. return this.$d.toUTCString();
  201. }, M2;
  202. }(), T = _.prototype;
  203. return w.prototype = T, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", f], ["$y", c], ["$D", d]].forEach(function(t2) {
  204. T[t2[1]] = function(e2) {
  205. return this.$g(e2, t2[0], t2[1]);
  206. };
  207. }), w.extend = function(t2, e2) {
  208. return t2.$i || (t2(e2, _, w), t2.$i = true), w;
  209. }, w.locale = S, w.isDayjs = p, w.unix = function(t2) {
  210. return w(1e3 * t2);
  211. }, w.en = D[g], w.Ls = D, w.p = {}, w;
  212. });
  213. }
  214. });
  215. export default require_dayjs_min();