江西小程序管理端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

308 lines
11 KiB

1 year ago
  1. !(function (t, e) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = e() : typeof define === 'function'
  3. && define.amd ? define(e) : t.dayjs = e()
  4. }(this, () => {
  5. 'use strict'
  6. const t = 'millisecond'
  7. const e = 'second'
  8. const n = 'minute'
  9. const r = 'hour'
  10. const i = 'day'
  11. const s = 'week'
  12. const u = 'month'
  13. const a = 'quarter'
  14. const o = 'year'
  15. const f = 'date'
  16. const h = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?.?(\d+)?$/
  17. const c = /\[([^\]]+)]|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
  18. const d = {
  19. name: 'en',
  20. weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
  21. months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_')
  22. }
  23. const $ = function (t, e, n) {
  24. const r = String(t)
  25. return !r || r.length >= e ? t : `${Array(e + 1 - r.length).join(n)}${t}`
  26. }
  27. const l = {
  28. s: $,
  29. z(t) {
  30. const e = -t.utcOffset()
  31. const n = Math.abs(e)
  32. const r = Math.floor(n / 60)
  33. const i = n % 60
  34. return `${(e <= 0 ? '+' : '-') + $(r, 2, '0')}:${$(i, 2, '0')}`
  35. },
  36. m: function t(e, n) {
  37. if (e.date() < n.date()) return -t(n, e)
  38. const r = 12 * (n.year() - e.year()) + (n.month() - e.month())
  39. const i = e.clone().add(r, u)
  40. const s = n - i < 0
  41. const a = e.clone().add(r + (s ? -1 : 1), u)
  42. return +(-(r + (n - i) / (s ? i - a : a - i)) || 0)
  43. },
  44. a(t) {
  45. return t < 0 ? Math.ceil(t) || 0 : Math.floor(t)
  46. },
  47. p(h) {
  48. return {
  49. M: u,
  50. y: o,
  51. w: s,
  52. d: i,
  53. D: f,
  54. h: r,
  55. m: n,
  56. s: e,
  57. ms: t,
  58. Q: a
  59. }[h] || String(h || '').toLowerCase().replace(/s$/, '')
  60. },
  61. u(t) {
  62. return void 0 === t
  63. }
  64. }
  65. let y = 'en'
  66. const M = {}
  67. M[y] = d
  68. const m = function (t) {
  69. return t instanceof S
  70. }
  71. const D = function (t, e, n) {
  72. let r
  73. if (!t) return y
  74. if (typeof t === 'string') M[t] && (r = t), e && (M[t] = e, r = t)
  75. else {
  76. const i = t.name
  77. M[i] = t, r = i
  78. }
  79. return !n && r && (y = r), r || !n && y
  80. }
  81. const v = function (t, e) {
  82. if (m(t)) return t.clone()
  83. const n = typeof e === 'object' ? e : {}
  84. return n.date = t, n.args = arguments, new S(n)
  85. }
  86. const g = l
  87. g.l = D, g.i = m, g.w = function (t, e) {
  88. return v(t, {
  89. locale: e.$L,
  90. utc: e.$u,
  91. x: e.$x,
  92. $offset: e.$offset
  93. })
  94. }
  95. var S = (function () {
  96. function d(t) {
  97. this.$L = D(t.locale, null, !0), this.parse(t)
  98. }
  99. const $ = d.prototype
  100. return $.parse = function (t) {
  101. this.$d = (function (t) {
  102. const e = t.date
  103. const n = t.utc
  104. if (e === null) return new Date(NaN)
  105. if (g.u(e)) return new Date()
  106. if (e instanceof Date) return new Date(e)
  107. if (typeof e === 'string' && !/Z$/i.test(e)) {
  108. const r = e.match(h)
  109. if (r) {
  110. const i = r[2] - 1 || 0
  111. const s = (r[7] || '0').substring(0, 3)
  112. return n ? new Date(Date.UTC(r[1], i, r[3] || 1, r[4] || 0, r[5] || 0, r[6] || 0, s)) : new Date(r[1], i, r[3]
  113. || 1, r[4] || 0, r[5] || 0, r[6] || 0, s)
  114. }
  115. }
  116. return new Date(e)
  117. }(t)), this.$x = t.x || {}, this.init()
  118. }, $.init = function () {
  119. const t = this.$d
  120. this.$y = t.getFullYear(), this.$M = t.getMonth(), this.$D = t.getDate(), this.$W = t.getDay(), this.$H = t.getHours(),
  121. this.$m = t.getMinutes(), this.$s = t.getSeconds(), this.$ms = t.getMilliseconds()
  122. }, $.$utils = function () {
  123. return g
  124. }, $.isValid = function () {
  125. return !(this.$d.toString() === 'Invalid Date')
  126. }, $.isSame = function (t, e) {
  127. const n = v(t)
  128. return this.startOf(e) <= n && n <= this.endOf(e)
  129. }, $.isAfter = function (t, e) {
  130. return v(t) < this.startOf(e)
  131. }, $.isBefore = function (t, e) {
  132. return this.endOf(e) < v(t)
  133. }, $.$g = function (t, e, n) {
  134. return g.u(t) ? this[e] : this.set(n, t)
  135. }, $.unix = function () {
  136. return Math.floor(this.valueOf() / 1e3)
  137. }, $.valueOf = function () {
  138. return this.$d.getTime()
  139. }, $.startOf = function (t, a) {
  140. const h = this
  141. const c = !!g.u(a) || a
  142. const d = g.p(t)
  143. const $ = function (t, e) {
  144. const n = g.w(h.$u ? Date.UTC(h.$y, e, t) : new Date(h.$y, e, t), h)
  145. return c ? n : n.endOf(i)
  146. }
  147. const l = function (t, e) {
  148. return g.w(h.toDate()[t].apply(h.toDate('s'), (c ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e)), h)
  149. }
  150. const y = this.$W
  151. const M = this.$M
  152. const m = this.$D
  153. const D = `set${this.$u ? 'UTC' : ''}`
  154. switch (d) {
  155. case o:
  156. return c ? $(1, 0) : $(31, 11)
  157. case u:
  158. return c ? $(1, M) : $(0, M + 1)
  159. case s:
  160. var v = this.$locale().weekStart || 0
  161. var S = (y < v ? y + 7 : y) - v
  162. return $(c ? m - S : m + (6 - S), M)
  163. case i:
  164. case f:
  165. return l(`${D}Hours`, 0)
  166. case r:
  167. return l(`${D}Minutes`, 1)
  168. case n:
  169. return l(`${D}Seconds`, 2)
  170. case e:
  171. return l(`${D}Milliseconds`, 3)
  172. default:
  173. return this.clone()
  174. }
  175. }, $.endOf = function (t) {
  176. return this.startOf(t, !1)
  177. }, $.$set = function (s, a) {
  178. let h; const c = g.p(s)
  179. const d = `set${this.$u ? 'UTC' : ''}`
  180. const $ = (h = {}, h[i] = `${d}Date`, h[f] = `${d}Date`, h[u] = `${d}Month`, h[o] = `${d}FullYear`, h[r] = `${d}Hours`,
  181. h[n] = `${d}Minutes`, h[e] = `${d}Seconds`, h[t] = `${d}Milliseconds`, h)[c]
  182. const l = c === i ? this.$D + (a - this.$W) : a
  183. if (c === u || c === o) {
  184. const y = this.clone().set(f, 1)
  185. y.$d[$](l), y.init(), this.$d = y.set(f, Math.min(this.$D, y.daysInMonth())).$d
  186. } else $ && this.$d[$](l)
  187. return this.init(), this
  188. }, $.set = function (t, e) {
  189. return this.clone().$set(t, e)
  190. }, $.get = function (t) {
  191. return this[g.p(t)]()
  192. }, $.add = function (t, a) {
  193. let f; const
  194. h = this
  195. t = Number(t)
  196. const c = g.p(a)
  197. const d = function (e) {
  198. const n = v(h)
  199. return g.w(n.date(n.date() + Math.round(e * t)), h)
  200. }
  201. if (c === u) return this.set(u, this.$M + t)
  202. if (c === o) return this.set(o, this.$y + t)
  203. if (c === i) return d(1)
  204. if (c === s) return d(7)
  205. const $ = (f = {}, f[n] = 6e4, f[r] = 36e5, f[e] = 1e3, f)[c] || 1
  206. const l = this.$d.getTime() + t * $
  207. return g.w(l, this)
  208. }, $.subtract = function (t, e) {
  209. return this.add(-1 * t, e)
  210. }, $.format = function (t) {
  211. const e = this
  212. if (!this.isValid()) return 'Invalid Date'
  213. const n = t || 'YYYY-MM-DDTHH:mm:ssZ'
  214. const r = g.z(this)
  215. const i = this.$locale()
  216. const s = this.$H
  217. const u = this.$m
  218. const a = this.$M
  219. const o = i.weekdays
  220. const f = i.months
  221. const h = function (t, r, i, s) {
  222. return t && (t[r] || t(e, n)) || i[r].substr(0, s)
  223. }
  224. const d = function (t) {
  225. return g.s(s % 12 || 12, t, '0')
  226. }
  227. const $ = i.meridiem || function (t, e, n) {
  228. const r = t < 12 ? 'AM' : 'PM'
  229. return n ? r.toLowerCase() : r
  230. }
  231. const l = {
  232. YY: String(this.$y).slice(-2),
  233. YYYY: this.$y,
  234. M: a + 1,
  235. MM: g.s(a + 1, 2, '0'),
  236. MMM: h(i.monthsShort, a, f, 3),
  237. MMMM: h(f, a),
  238. D: this.$D,
  239. DD: g.s(this.$D, 2, '0'),
  240. d: String(this.$W),
  241. dd: h(i.weekdaysMin, this.$W, o, 2),
  242. ddd: h(i.weekdaysShort, this.$W, o, 3),
  243. dddd: o[this.$W],
  244. H: String(s),
  245. HH: g.s(s, 2, '0'),
  246. h: d(1),
  247. hh: d(2),
  248. a: $(s, u, !0),
  249. A: $(s, u, !1),
  250. m: String(u),
  251. mm: g.s(u, 2, '0'),
  252. s: String(this.$s),
  253. ss: g.s(this.$s, 2, '0'),
  254. SSS: g.s(this.$ms, 3, '0'),
  255. Z: r
  256. }
  257. return n.replace(c, (t, e) => e || l[t] || r.replace(':', ''))
  258. }, $.utcOffset = function () {
  259. return 15 * -Math.round(this.$d.getTimezoneOffset() / 15)
  260. }, $.diff = function (t, f, h) {
  261. let c; const d = g.p(f)
  262. const $ = v(t)
  263. const l = 6e4 * ($.utcOffset() - this.utcOffset())
  264. const y = this - $
  265. let M = g.m(this, $)
  266. return M = (c = {}, c[o] = M / 12, c[u] = M, c[a] = M / 3, c[s] = (y - l) / 6048e5, c[i] = (y - l) / 864e5, c[r] = y / 36e5, c[n] = y / 6e4, c[e] = y / 1e3, c)[d] || y, h ? M : g.a(M)
  267. }, $.daysInMonth = function () {
  268. return this.endOf(u).$D
  269. }, $.$locale = function () {
  270. return M[this.$L]
  271. }, $.locale = function (t, e) {
  272. if (!t) return this.$L
  273. const n = this.clone()
  274. const r = D(t, e, !0)
  275. return r && (n.$L = r), n
  276. }, $.clone = function () {
  277. return g.w(this.$d, this)
  278. }, $.toDate = function () {
  279. return new Date(this.valueOf())
  280. }, $.toJSON = function () {
  281. return this.isValid() ? this.toISOString() : null
  282. }, $.toISOString = function () {
  283. return this.$d.toISOString()
  284. }, $.toString = function () {
  285. return this.$d.toUTCString()
  286. }, d
  287. }())
  288. const p = S.prototype
  289. return v.prototype = p, [
  290. ['$ms', t],
  291. ['$s', e],
  292. ['$m', n],
  293. ['$H', r],
  294. ['$W', i],
  295. ['$M', u],
  296. ['$y', o],
  297. ['$D', f]
  298. ].forEach((t) => {
  299. p[t[1]] = function (e) {
  300. return this.$g(e, t[0], t[1])
  301. }
  302. }), v.extend = function (t, e) {
  303. return t.$i || (t(e, S, v), t.$i = !0), v
  304. }, v.locale = D, v.isDayjs = m, v.unix = function (t) {
  305. return v(1e3 * t)
  306. }, v.en = M[y], v.Ls = M, v.p = {}, v
  307. }))