eoss 0.1.0-alpha.35 → 0.1.0-alpha.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/lib/0.js +1 -1
  2. package/lib/1.js +1 -1
  3. package/lib/10.js +1 -1
  4. package/lib/11.js +1 -1
  5. package/lib/12.js +1 -1
  6. package/lib/13.js +1 -1
  7. package/lib/14.js +1 -1
  8. package/lib/15.js +1 -1
  9. package/lib/16.js +1 -1
  10. package/lib/17.js +1 -1
  11. package/lib/18.js +1 -1
  12. package/lib/19.js +1 -1
  13. package/lib/20.js +1 -1
  14. package/lib/21.js +1 -1
  15. package/lib/22.js +1 -1
  16. package/lib/23.js +1 -1
  17. package/lib/24.js +1 -1
  18. package/lib/25.js +1 -1
  19. package/lib/26.js +1 -1
  20. package/lib/27.js +1 -1
  21. package/lib/28.js +1 -1
  22. package/lib/29.js +1 -1
  23. package/lib/3.js +1 -1
  24. package/lib/30.js +1 -1
  25. package/lib/31.js +1 -1
  26. package/lib/32.js +1 -1
  27. package/lib/33.js +1 -1
  28. package/lib/34.js +1 -1
  29. package/lib/35.js +1 -1
  30. package/lib/36.js +1 -1
  31. package/lib/37.js +1 -1
  32. package/lib/38.js +1 -1
  33. package/lib/39.js +1 -1
  34. package/lib/4.js +1 -1
  35. package/lib/40.js +1 -1
  36. package/lib/41.js +1 -1
  37. package/lib/42.js +1 -1
  38. package/lib/43.js +1 -1
  39. package/lib/44.js +1 -1
  40. package/lib/45.js +1 -1
  41. package/lib/46.js +1 -1
  42. package/lib/47.js +1 -1
  43. package/lib/48.js +1 -1
  44. package/lib/49.js +1 -1
  45. package/lib/5.js +1 -1
  46. package/lib/50.js +1 -1
  47. package/lib/51.js +1 -1
  48. package/lib/52.js +1 -1
  49. package/lib/53.js +1 -1
  50. package/lib/54.js +1 -1
  51. package/lib/55.js +1 -1
  52. package/lib/56.js +1 -1
  53. package/lib/57.js +1 -1
  54. package/lib/58.js +1 -1
  55. package/lib/59.js +1 -1
  56. package/lib/6.js +1 -1
  57. package/lib/60.js +1 -1
  58. package/lib/61.js +1 -1
  59. package/lib/62.js +1 -1
  60. package/lib/63.js +1 -1
  61. package/lib/64.js +1 -1
  62. package/lib/65.js +1 -1
  63. package/lib/66.js +1 -1
  64. package/lib/67.js +1 -1
  65. package/lib/68.js +1 -1
  66. package/lib/69.js +1 -1
  67. package/lib/7.js +1 -1
  68. package/lib/70.js +1 -1
  69. package/lib/71.js +1 -1
  70. package/lib/72.js +1 -1
  71. package/lib/73.js +1 -1
  72. package/lib/74.js +1 -1
  73. package/lib/75.js +1 -1
  74. package/lib/76.js +1 -1
  75. package/lib/77.js +1 -1
  76. package/lib/78.js +1 -1
  77. package/lib/79.js +1 -1
  78. package/lib/8.js +1 -1
  79. package/lib/80.js +1 -1
  80. package/lib/81.js +1 -1
  81. package/lib/9.js +1 -1
  82. package/lib/account-login.js +1101 -1035
  83. package/lib/alert.js +2 -2
  84. package/lib/aside.js +2 -2
  85. package/lib/audit-trajectory.js +150 -150
  86. package/lib/autocomplete.js +2095 -1871
  87. package/lib/avatar.js +2 -2
  88. package/lib/backtop.js +2 -2
  89. package/lib/badge.js +2 -2
  90. package/lib/breadcrumb-item.js +4 -4
  91. package/lib/breadcrumb.js +4 -4
  92. package/lib/button-group.js +4 -4
  93. package/lib/button.js +2 -2
  94. package/lib/ca-login.js +862 -837
  95. package/lib/calendar.js +864 -839
  96. package/lib/card.js +2 -2
  97. package/lib/carousel-item.js +864 -839
  98. package/lib/carousel.js +866 -841
  99. package/lib/cascader-panel.js +878 -853
  100. package/lib/cascader.js +2325 -2101
  101. package/lib/checkbox-button.js +4 -4
  102. package/lib/checkbox-group.js +1060 -1025
  103. package/lib/checkbox.js +6 -6
  104. package/lib/col.js +2 -2
  105. package/lib/collapse-item.js +920 -895
  106. package/lib/collapse.js +913 -888
  107. package/lib/color-picker.js +1155 -956
  108. package/lib/container.js +2 -2
  109. package/lib/cron.js +18 -18
  110. package/lib/data-table.js +1053 -1018
  111. package/lib/date-picker.js +2094 -1870
  112. package/lib/descriptions-item.js +144 -0
  113. package/lib/descriptions.js +561 -0
  114. package/lib/dialog.js +943 -918
  115. package/lib/divider.js +2 -2
  116. package/lib/drawer.js +12 -12
  117. package/lib/dropdown-item.js +6 -6
  118. package/lib/dropdown-menu.js +1157 -958
  119. package/lib/dropdown.js +870 -845
  120. package/lib/email-login.js +1047 -1012
  121. package/lib/empty.js +2 -2
  122. package/lib/eoss.common.js +3493 -2313
  123. package/lib/flip.js +2 -2
  124. package/lib/flow-group.js +876 -851
  125. package/lib/flow.js +1184 -1149
  126. package/lib/flows.js +1080 -1045
  127. package/lib/footer.js +2 -2
  128. package/lib/form-item.js +877 -852
  129. package/lib/form.js +1123 -1087
  130. package/lib/guide.js +2 -2
  131. package/lib/header.js +2 -2
  132. package/lib/icon.js +1009 -984
  133. package/lib/icons.js +6 -6
  134. package/lib/image-viewer.js +862 -837
  135. package/lib/image.js +4 -4
  136. package/lib/index.js +1 -1
  137. package/lib/infinite-scroll.js +2 -2
  138. package/lib/input-number.js +6 -6
  139. package/lib/input.js +870 -845
  140. package/lib/link.js +2 -2
  141. package/lib/loading.js +13 -13
  142. package/lib/login.js +1116 -1066
  143. package/lib/lowcode-view.js +1078 -1043
  144. package/lib/lowcode.js +1131 -1096
  145. package/lib/main.js +1185 -1148
  146. package/lib/marquee.js +862 -837
  147. package/lib/menu-item-group.js +20 -17
  148. package/lib/menu-item.js +8 -8
  149. package/lib/menu.js +2390 -2164
  150. package/lib/message-box.js +950 -925
  151. package/lib/message.js +941 -916
  152. package/lib/notification.js +962 -937
  153. package/lib/option-group.js +4 -4
  154. package/lib/option.js +871 -846
  155. package/lib/page-header.js +2 -2
  156. package/lib/pagination.js +866 -841
  157. package/lib/phone-login.js +1049 -1014
  158. package/lib/popconfirm.js +4 -4
  159. package/lib/popover.js +2100 -1876
  160. package/lib/process-config.js +1065 -1030
  161. package/lib/process-module.js +1053 -1018
  162. package/lib/process-rule.js +1062 -1027
  163. package/lib/progress.js +2 -2
  164. package/lib/qr-code.js +4 -4
  165. package/lib/qrcode-login.js +1052 -1017
  166. package/lib/radio-button.js +4 -4
  167. package/lib/radio-group.js +2608 -2573
  168. package/lib/radio.js +6 -6
  169. package/lib/rate.js +864 -839
  170. package/lib/retrial-auth.js +7063 -0
  171. package/lib/row.js +2 -2
  172. package/lib/scrollbar.js +868 -843
  173. package/lib/select.js +2591 -2357
  174. package/lib/selector-panel.js +2659 -2624
  175. package/lib/selector.js +1068 -1033
  176. package/lib/slider.js +6 -6
  177. package/lib/step.js +44 -44
  178. package/lib/steps.js +911 -886
  179. package/lib/submenu.js +1439 -1236
  180. package/lib/switch.js +866 -841
  181. package/lib/tab-pane.js +4 -4
  182. package/lib/table-column.js +936 -911
  183. package/lib/table.js +2318 -2084
  184. package/lib/tabs.js +866 -841
  185. package/lib/tag.js +2 -2
  186. package/lib/theme-chalk/base.css +1 -1
  187. package/lib/theme-chalk/descriptions.css +1 -1
  188. package/lib/theme-chalk/index.css +1 -1
  189. package/lib/theme-chalk/main.css +1 -1
  190. package/lib/theme-chalk/retrial-auth.css +1 -0
  191. package/lib/time-picker.js +2047 -1823
  192. package/lib/time-select.js +2041 -1817
  193. package/lib/timeline-item.js +2 -2
  194. package/lib/timeline.js +2 -2
  195. package/lib/tips.js +1047 -1012
  196. package/lib/toolbar.js +36 -17
  197. package/lib/tooltip.js +2080 -1856
  198. package/lib/transfer.js +881 -856
  199. package/lib/tree-group.js +1020 -995
  200. package/lib/tree.js +1062 -1027
  201. package/lib/update-history.js +151 -151
  202. package/lib/upload.js +1082 -1047
  203. package/lib/utils/ajax.js +5 -1
  204. package/lib/utils/popper.js +97 -48
  205. package/lib/wujie.js +866 -841
  206. package/package.json +1 -1
  207. package/packages/account-login/src/account-login.vue +29 -0
  208. package/packages/descriptions/index.js +8 -0
  209. package/packages/descriptions/src/index.js +181 -0
  210. package/packages/descriptions/src/item.js +30 -0
  211. package/packages/descriptions/src/row.js +120 -0
  212. package/packages/descriptions-item/index.js +8 -0
  213. package/packages/login/src/login.vue +8 -0
  214. package/packages/login/src/mixins.js +3 -1
  215. package/packages/main/src/minxs.js +1 -0
  216. package/packages/menu/src/menu.vue +0 -1
  217. package/packages/menu/src/mixins.js +4 -3
  218. package/packages/menu/src/submenu.vue +4 -4
  219. package/packages/retrial-auth/index.js +5 -0
  220. package/packages/retrial-auth/src/main.vue +300 -0
  221. package/packages/theme-chalk/src/base.scss +2 -1
  222. package/packages/theme-chalk/src/descriptions.scss +0 -1
  223. package/packages/theme-chalk/src/index.scss +3 -0
  224. package/packages/theme-chalk/src/retrial-auth.scss +38 -0
  225. package/packages/toolbar/src/toolbar.vue +5 -0
  226. package/src/index.js +336 -327
  227. package/src/utils/ajax.js +2 -1
  228. package/src/utils/popper.js +109 -70
package/lib/switch.js CHANGED
@@ -82,7 +82,7 @@ module.exports =
82
82
  /******/
83
83
  /******/
84
84
  /******/ // Load entry module and return exports
85
- /******/ return __webpack_require__(__webpack_require__.s = 255);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 259);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -3561,7 +3561,7 @@ module.exports = require("vue");
3561
3561
 
3562
3562
  /***/ }),
3563
3563
 
3564
- /***/ 255:
3564
+ /***/ 259:
3565
3565
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3566
3566
 
3567
3567
  "use strict";
@@ -3688,10 +3688,10 @@ render._withStripped = true
3688
3688
  var emitter = __webpack_require__(15);
3689
3689
 
3690
3690
  // EXTERNAL MODULE: ./src/mixins/focus.js
3691
- var mixins_focus = __webpack_require__(83);
3691
+ var mixins_focus = __webpack_require__(84);
3692
3692
 
3693
3693
  // EXTERNAL MODULE: ./src/mixins/migrating.js
3694
- var migrating = __webpack_require__(45);
3694
+ var migrating = __webpack_require__(46);
3695
3695
 
3696
3696
  // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/switch/src/switch.vue?vue&type=script&lang=js&
3697
3697
  //
@@ -4253,7 +4253,7 @@ function normalizeComponent(
4253
4253
 
4254
4254
  /***/ }),
4255
4255
 
4256
- /***/ 45:
4256
+ /***/ 46:
4257
4257
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4258
4258
 
4259
4259
  "use strict";
@@ -4375,736 +4375,759 @@ function normalizeComponent(
4375
4375
  /* unused harmony export getSecond */
4376
4376
  /* unused harmony export getWeekday */
4377
4377
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
4378
-
4379
-
4378
+ /* Modified from https://github.com/taylorhakes/fecha
4379
+ *
4380
+ * The MIT License (MIT)
4381
+ *
4382
+ * Copyright (c) 2015 Taylor Hakes
4383
+ *
4384
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
4385
+ * of this software and associated documentation files (the "Software"), to deal
4386
+ * in the Software without restriction, including without limitation the rights
4387
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4388
+ * copies of the Software, and to permit persons to whom the Software is
4389
+ * furnished to do so, subject to the following conditions:
4390
+ *
4391
+ * The above copyright notice and this permission notice shall be included in all
4392
+ * copies or substantial portions of the Software.
4393
+ *
4394
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4395
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4396
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4397
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4398
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4399
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4400
+ * SOFTWARE.
4401
+ */
4402
+
4403
+ /*eslint-disable*/
4404
+ // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
4405
+
4406
+
4380
4407
  /**
4381
4408
  * Parse or format dates
4382
4409
  * @class fecha
4383
- */
4384
- var fecha = {};
4385
- var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
4386
- var twoDigits = '\\d\\d?';
4387
- var threeDigits = '\\d{3}';
4388
- var fourDigits = '\\d{4}';
4389
- var word = '[^\\s]+';
4390
- var literal = /\[([^]*?)\]/gm;
4391
- var noop = function noop() {};
4392
-
4393
- function regexEscape(str) {
4394
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
4395
- }
4396
-
4397
- function shorten(arr, sLen) {
4398
- var newArr = [];
4399
- for (var i = 0, len = arr.length; i < len; i++) {
4400
- newArr.push(arr[i].substr(0, sLen));
4401
- }
4402
- return newArr;
4403
- }
4404
-
4405
- function monthUpdate() {
4406
- return function (d, v) {
4407
- var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
4408
- if (~index) {
4409
- d.month = index;
4410
- }
4411
- };
4412
- }
4413
-
4414
- function pad(val, len) {
4415
- val = String(val);
4416
- len = len || 2;
4417
- while (val.length < len) {
4418
- val = '0' + val;
4419
- }
4420
- return val;
4421
- }
4422
-
4423
- // 直接使用中文日期名称常量
4424
- var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
4425
- var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
4426
- var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
4427
- var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
4428
- var amPm = ['上午', '下午'];
4429
- var DoFn = function DoFn(D) {
4430
- return D + '日';
4431
- };
4432
-
4433
- var formatFlags = {
4434
- D: function D(dateObj) {
4435
- return dateObj.getDay();
4436
- },
4437
- DD: function DD(dateObj) {
4438
- return pad(dateObj.getDay());
4439
- },
4440
- Do: function Do(dateObj) {
4441
- return DoFn(dateObj.getDate());
4442
- },
4443
- d: function d(dateObj) {
4444
- return dateObj.getDate();
4445
- },
4446
- dd: function dd(dateObj) {
4447
- return pad(dateObj.getDate());
4448
- },
4449
- ddd: function ddd(dateObj) {
4450
- return dayNamesShort[dateObj.getDay()];
4451
- },
4452
- dddd: function dddd(dateObj) {
4453
- return dayNames[dateObj.getDay()];
4454
- },
4455
- M: function M(dateObj) {
4456
- return dateObj.getMonth() + 1;
4457
- },
4458
- MM: function MM(dateObj) {
4459
- return pad(dateObj.getMonth() + 1);
4460
- },
4461
- MMM: function MMM(dateObj) {
4462
- return monthNamesShort[dateObj.getMonth()];
4463
- },
4464
- MMMM: function MMMM(dateObj) {
4465
- return monthNames[dateObj.getMonth()];
4466
- },
4467
- yy: function yy(dateObj) {
4468
- return pad(String(dateObj.getFullYear()), 4).substr(2);
4469
- },
4470
- yyyy: function yyyy(dateObj) {
4471
- return pad(dateObj.getFullYear(), 4);
4472
- },
4473
- h: function h(dateObj) {
4474
- return dateObj.getHours() % 12 || 12;
4475
- },
4476
- hh: function hh(dateObj) {
4477
- return pad(dateObj.getHours() % 12 || 12);
4478
- },
4479
- H: function H(dateObj) {
4480
- return dateObj.getHours();
4481
- },
4482
- HH: function HH(dateObj) {
4483
- return pad(dateObj.getHours());
4484
- },
4485
- m: function m(dateObj) {
4486
- return dateObj.getMinutes();
4487
- },
4488
- mm: function mm(dateObj) {
4489
- return pad(dateObj.getMinutes());
4490
- },
4491
- s: function s(dateObj) {
4492
- return dateObj.getSeconds();
4493
- },
4494
- ss: function ss(dateObj) {
4495
- return pad(dateObj.getSeconds());
4496
- },
4497
- S: function S(dateObj) {
4498
- return Math.round(dateObj.getMilliseconds() / 100);
4499
- },
4500
- SS: function SS(dateObj) {
4501
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
4502
- },
4503
- SSS: function SSS(dateObj) {
4504
- return pad(dateObj.getMilliseconds(), 3);
4505
- },
4506
- a: function a(dateObj) {
4507
- return dateObj.getHours() < 12 ? '上午' : '下午';
4508
- },
4509
- A: function A(dateObj) {
4510
- return dateObj.getHours() < 12 ? '上午' : '下午';
4511
- },
4512
- ZZ: function ZZ(dateObj) {
4513
- var o = dateObj.getTimezoneOffset();
4514
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
4515
- }
4516
- };
4517
-
4518
- var parseFlags = {
4519
- d: [twoDigits, function (d, v) {
4520
- d.day = v;
4521
- }],
4522
- Do: [twoDigits + word, function (d, v) {
4523
- d.day = parseInt(v, 10);
4524
- }],
4525
- M: [twoDigits, function (d, v) {
4526
- d.month = v - 1;
4527
- }],
4528
- yy: [twoDigits, function (d, v) {
4529
- var da = new Date(),
4530
- cent = +('' + da.getFullYear()).substr(0, 2);
4531
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
4532
- }],
4533
- h: [twoDigits, function (d, v) {
4534
- d.hour = v;
4535
- }],
4536
- m: [twoDigits, function (d, v) {
4537
- d.minute = v;
4538
- }],
4539
- s: [twoDigits, function (d, v) {
4540
- d.second = v;
4541
- }],
4542
- yyyy: [fourDigits, function (d, v) {
4543
- d.year = v;
4544
- }],
4545
- S: ['\\d', function (d, v) {
4546
- d.millisecond = v * 100;
4547
- }],
4548
- SS: ['\\d{2}', function (d, v) {
4549
- d.millisecond = v * 10;
4550
- }],
4551
- SSS: [threeDigits, function (d, v) {
4552
- d.millisecond = v;
4553
- }],
4554
- D: [twoDigits, noop],
4555
- ddd: [word, noop],
4556
- MMM: [word, monthUpdate('monthNamesShort')],
4557
- MMMM: [word, monthUpdate('monthNames')],
4558
- a: [word, function (d, v) {
4559
- var val = v.toLowerCase();
4560
- if (val === '上午') {
4561
- d.isPm = false;
4562
- } else if (val === '下午') {
4563
- d.isPm = true;
4564
- }
4565
- }],
4566
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
4567
- var parts = (v + '').match(/([+-]|\d\d)/gi),
4568
- minutes = void 0;
4569
-
4570
- if (parts) {
4571
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
4572
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
4573
- }
4574
- }]
4575
- };
4576
- parseFlags.dd = parseFlags.d;
4577
- parseFlags.dddd = parseFlags.ddd;
4578
- parseFlags.DD = parseFlags.D;
4579
- parseFlags.mm = parseFlags.m;
4580
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
4581
- parseFlags.MM = parseFlags.M;
4582
- parseFlags.ss = parseFlags.s;
4583
- parseFlags.A = parseFlags.a;
4584
-
4585
- // Some common format strings
4586
- fecha.masks = {
4587
- default: 'ddd MMM dd yyyy HH:mm:ss',
4588
- shortDate: 'M/D/yy',
4589
- mediumDate: 'MMM d, yyyy',
4590
- longDate: 'MMMM d, yyyy',
4591
- fullDate: 'dddd, MMMM d, yyyy',
4592
- shortTime: 'HH:mm',
4593
- mediumTime: 'HH:mm:ss',
4594
- longTime: 'HH:mm:ss.SSS'
4595
- };
4596
-
4410
+ */
4411
+ const fecha = {};
4412
+ const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
4413
+ const twoDigits = '\\d\\d?';
4414
+ const threeDigits = '\\d{3}';
4415
+ const fourDigits = '\\d{4}';
4416
+ const word = '[^\\s]+';
4417
+ const literal = /\[([^]*?)\]/gm;
4418
+ const noop = function () {};
4419
+
4420
+ function regexEscape(str) {
4421
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
4422
+ }
4423
+
4424
+ function shorten(arr, sLen) {
4425
+ const newArr = [];
4426
+ for (let i = 0, len = arr.length; i < len; i++) {
4427
+ newArr.push(arr[i].substr(0, sLen));
4428
+ }
4429
+ return newArr;
4430
+ }
4431
+
4432
+ function monthUpdate() {
4433
+ return function (d, v) {
4434
+ const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
4435
+ if (~index) {
4436
+ d.month = index;
4437
+ }
4438
+ };
4439
+ }
4440
+
4441
+ function pad(val, len) {
4442
+ val = String(val);
4443
+ len = len || 2;
4444
+ while (val.length < len) {
4445
+ val = '0' + val;
4446
+ }
4447
+ return val;
4448
+ }
4449
+
4450
+ // 直接使用中文日期名称常量
4451
+ const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
4452
+ const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
4453
+ const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
4454
+ const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
4455
+ const amPm = ['上午', '下午'];
4456
+ const DoFn = function DoFn(D) {
4457
+ return D + '日';
4458
+ };
4459
+
4460
+ const formatFlags = {
4461
+ D: function(dateObj) {
4462
+ return dateObj.getDay();
4463
+ },
4464
+ DD: function(dateObj) {
4465
+ return pad(dateObj.getDay());
4466
+ },
4467
+ Do: function(dateObj) {
4468
+ return DoFn(dateObj.getDate());
4469
+ },
4470
+ d: function(dateObj) {
4471
+ return dateObj.getDate();
4472
+ },
4473
+ dd: function(dateObj) {
4474
+ return pad(dateObj.getDate());
4475
+ },
4476
+ ddd: function(dateObj) {
4477
+ return dayNamesShort[dateObj.getDay()];
4478
+ },
4479
+ dddd: function(dateObj) {
4480
+ return dayNames[dateObj.getDay()];
4481
+ },
4482
+ M: function(dateObj) {
4483
+ return dateObj.getMonth() + 1;
4484
+ },
4485
+ MM: function(dateObj) {
4486
+ return pad(dateObj.getMonth() + 1);
4487
+ },
4488
+ MMM: function(dateObj) {
4489
+ return monthNamesShort[dateObj.getMonth()];
4490
+ },
4491
+ MMMM: function(dateObj) {
4492
+ return monthNames[dateObj.getMonth()];
4493
+ },
4494
+ yy: function(dateObj) {
4495
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
4496
+ },
4497
+ yyyy: function(dateObj) {
4498
+ return pad(dateObj.getFullYear(), 4);
4499
+ },
4500
+ h: function(dateObj) {
4501
+ return dateObj.getHours() % 12 || 12;
4502
+ },
4503
+ hh: function(dateObj) {
4504
+ return pad(dateObj.getHours() % 12 || 12);
4505
+ },
4506
+ H: function(dateObj) {
4507
+ return dateObj.getHours();
4508
+ },
4509
+ HH: function(dateObj) {
4510
+ return pad(dateObj.getHours());
4511
+ },
4512
+ m: function(dateObj) {
4513
+ return dateObj.getMinutes();
4514
+ },
4515
+ mm: function(dateObj) {
4516
+ return pad(dateObj.getMinutes());
4517
+ },
4518
+ s: function(dateObj) {
4519
+ return dateObj.getSeconds();
4520
+ },
4521
+ ss: function(dateObj) {
4522
+ return pad(dateObj.getSeconds());
4523
+ },
4524
+ S: function(dateObj) {
4525
+ return Math.round(dateObj.getMilliseconds() / 100);
4526
+ },
4527
+ SS: function(dateObj) {
4528
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
4529
+ },
4530
+ SSS: function(dateObj) {
4531
+ return pad(dateObj.getMilliseconds(), 3);
4532
+ },
4533
+ a: function(dateObj) {
4534
+ return dateObj.getHours() < 12 ? '上午' : '下午';
4535
+ },
4536
+ A: function(dateObj) {
4537
+ return dateObj.getHours() < 12 ? '上午' : '下午';
4538
+ },
4539
+ ZZ: function(dateObj) {
4540
+ const o = dateObj.getTimezoneOffset();
4541
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
4542
+ }
4543
+ };
4544
+
4545
+ const parseFlags = {
4546
+ d: [twoDigits, function (d, v) {
4547
+ d.day = v;
4548
+ }],
4549
+ Do: [twoDigits + word, function (d, v) {
4550
+ d.day = parseInt(v, 10);
4551
+ }],
4552
+ M: [twoDigits, function (d, v) {
4553
+ d.month = v - 1;
4554
+ }],
4555
+ yy: [twoDigits, function (d, v) {
4556
+ const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
4557
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
4558
+ }],
4559
+ h: [twoDigits, function (d, v) {
4560
+ d.hour = v;
4561
+ }],
4562
+ m: [twoDigits, function (d, v) {
4563
+ d.minute = v;
4564
+ }],
4565
+ s: [twoDigits, function (d, v) {
4566
+ d.second = v;
4567
+ }],
4568
+ yyyy: [fourDigits, function (d, v) {
4569
+ d.year = v;
4570
+ }],
4571
+ S: ['\\d', function (d, v) {
4572
+ d.millisecond = v * 100;
4573
+ }],
4574
+ SS: ['\\d{2}', function (d, v) {
4575
+ d.millisecond = v * 10;
4576
+ }],
4577
+ SSS: [threeDigits, function (d, v) {
4578
+ d.millisecond = v;
4579
+ }],
4580
+ D: [twoDigits, noop],
4581
+ ddd: [word, noop],
4582
+ MMM: [word, monthUpdate('monthNamesShort')],
4583
+ MMMM: [word, monthUpdate('monthNames')],
4584
+ a: [word, function (d, v) {
4585
+ const val = v.toLowerCase();
4586
+ if (val === '上午') {
4587
+ d.isPm = false;
4588
+ } else if (val === '下午') {
4589
+ d.isPm = true;
4590
+ }
4591
+ }],
4592
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
4593
+ let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
4594
+
4595
+ if (parts) {
4596
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
4597
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
4598
+ }
4599
+ }]
4600
+ };
4601
+ parseFlags.dd = parseFlags.d;
4602
+ parseFlags.dddd = parseFlags.ddd;
4603
+ parseFlags.DD = parseFlags.D;
4604
+ parseFlags.mm = parseFlags.m;
4605
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
4606
+ parseFlags.MM = parseFlags.M;
4607
+ parseFlags.ss = parseFlags.s;
4608
+ parseFlags.A = parseFlags.a;
4609
+
4610
+
4611
+ // Some common format strings
4612
+ fecha.masks = {
4613
+ default: 'ddd MMM dd yyyy HH:mm:ss',
4614
+ shortDate: 'M/D/yy',
4615
+ mediumDate: 'MMM d, yyyy',
4616
+ longDate: 'MMMM d, yyyy',
4617
+ fullDate: 'dddd, MMMM d, yyyy',
4618
+ shortTime: 'HH:mm',
4619
+ mediumTime: 'HH:mm:ss',
4620
+ longTime: 'HH:mm:ss.SSS'
4621
+ };
4622
+
4597
4623
  /***
4598
4624
  * Format a date
4599
4625
  * @method format
4600
4626
  * @param {Date|number} dateObj
4601
4627
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
4602
- */
4603
- fecha.format = function (dateObj, mask) {
4604
- if (typeof dateObj === 'number') {
4605
- dateObj = new Date(dateObj);
4606
- }
4607
-
4608
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
4609
- throw new Error('Invalid Date in fecha.format');
4610
- }
4611
-
4612
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
4613
-
4614
- var literals = [];
4615
-
4616
- // Make literals inactive by replacing them with ??
4617
- mask = mask.replace(literal, function ($0, $1) {
4618
- literals.push($1);
4619
- return '@@@';
4620
- });
4621
- // Apply formatting rules
4622
- mask = mask.replace(token, function ($0) {
4623
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
4624
- });
4625
- // Inline literal values back into the formatted value
4626
- return mask.replace(/@@@/g, function () {
4627
- return literals.shift();
4628
- });
4629
- };
4630
-
4628
+ */
4629
+ fecha.format = function (dateObj, mask) {
4630
+ if (typeof dateObj === 'number') {
4631
+ dateObj = new Date(dateObj);
4632
+ }
4633
+
4634
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
4635
+ throw new Error('Invalid Date in fecha.format');
4636
+ }
4637
+
4638
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
4639
+
4640
+ const literals = [];
4641
+
4642
+ // Make literals inactive by replacing them with ??
4643
+ mask = mask.replace(literal, function($0, $1) {
4644
+ literals.push($1);
4645
+ return '@@@';
4646
+ });
4647
+ // Apply formatting rules
4648
+ mask = mask.replace(token, function ($0) {
4649
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
4650
+ });
4651
+ // Inline literal values back into the formatted value
4652
+ return mask.replace(/@@@/g, function() {
4653
+ return literals.shift();
4654
+ });
4655
+ };
4656
+
4631
4657
  /**
4632
4658
  * Parse a date string into an object, changes - into /
4633
4659
  * @method parse
4634
4660
  * @param {string} dateStr Date string
4635
4661
  * @param {string} format Date parse format
4636
4662
  * @returns {Date|boolean}
4637
- */
4638
- fecha.parse = function (dateStr, format) {
4639
- if (typeof format !== 'string') {
4640
- throw new Error('Invalid format in fecha.parse');
4641
- }
4642
-
4643
- format = fecha.masks[format] || format;
4644
-
4645
- // Avoid regular expression denial of service, fail early for really long strings
4646
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
4647
- if (dateStr.length > 1000) {
4648
- return null;
4649
- }
4650
-
4651
- var dateInfo = {};
4652
- var parseInfo = [];
4653
- var literals = [];
4654
- format = format.replace(literal, function ($0, $1) {
4655
- literals.push($1);
4656
- return '@@@';
4657
- });
4658
- var newFormat = regexEscape(format).replace(token, function ($0) {
4659
- if (parseFlags[$0]) {
4660
- var info = parseFlags[$0];
4661
- parseInfo.push(info[1]);
4662
- return '(' + info[0] + ')';
4663
- }
4664
-
4665
- return $0;
4666
- });
4667
- newFormat = newFormat.replace(/@@@/g, function () {
4668
- return literals.shift();
4669
- });
4670
- var matches = dateStr.match(new RegExp(newFormat, 'i'));
4671
- if (!matches) {
4672
- return null;
4673
- }
4674
-
4675
- for (var i = 1; i < matches.length; i++) {
4676
- parseInfo[i - 1](dateInfo, matches[i]);
4677
- }
4678
-
4679
- var today = new Date();
4680
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
4681
- dateInfo.hour = +dateInfo.hour + 12;
4682
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
4683
- dateInfo.hour = 0;
4684
- }
4685
-
4686
- var date = void 0;
4687
- if (dateInfo.timezoneOffset != null) {
4688
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
4689
- date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
4690
- } else {
4691
- date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
4692
- }
4693
- return date;
4694
- };
4695
-
4696
- // 导出fecha对象
4697
-
4698
-
4699
- // 以下是从date-util.js合并的函数
4700
- var newArray = function newArray(start, end) {
4701
- var result = [];
4702
- for (var i = start; i <= end; i++) {
4703
- result.push(i);
4704
- }
4705
- return result;
4706
- };
4707
-
4708
- var getSettings = function getSettings() {
4709
- return {
4710
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
4711
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
4712
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
4713
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
4714
- amPm: ['上午', '下午']
4715
- };
4716
- };
4717
-
4718
- var toDate = function toDate(date) {
4719
- return isDate(date) ? new Date(date) : null;
4720
- };
4721
-
4722
- var isDate = function isDate(date) {
4723
- if (date === null || date === undefined) return false;
4724
- if (isNaN(new Date(date).getTime())) return false;
4725
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
4726
- return true;
4727
- };
4728
-
4729
- var isDateObject = function isDateObject(val) {
4730
- return val instanceof Date;
4731
- };
4732
-
4733
- var formatDate = function formatDate(date) {
4734
- var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
4735
-
4736
- // 处理多种输入类型
4737
- if (!date) return '';
4738
-
4739
- // 如果是时间戳,转成日期对象
4740
- if (typeof date === 'number') {
4741
- date = new Date(date);
4742
- }
4743
- // 如果是字符串,转成日期对象
4744
- if (typeof date === 'string') {
4745
- date = new Date(date);
4746
- }
4747
-
4748
- // 调用toDate进一步验证和转换
4749
- date = toDate(date);
4750
- if (!date) return '';
4751
-
4752
- // 兼容大写和小写的格式标记
4753
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
4754
- var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
4755
-
4756
- // 使用fecha库进行格式化,支持中文配置
4757
- var str = fecha.format(date, lowercaseFormat, getSettings());
4758
- return str;
4759
- };
4760
-
4761
- var parseDate = function parseDate(string, format) {
4762
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
4763
- };
4764
-
4765
- var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
4766
- if (month === 3 || month === 5 || month === 8 || month === 10) {
4767
- return 30;
4768
- }
4769
-
4770
- if (month === 1) {
4771
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
4772
- return 29;
4773
- } else {
4774
- return 28;
4775
- }
4776
- }
4777
-
4778
- return 31;
4779
- };
4780
-
4781
- var getDayCountOfYear = function getDayCountOfYear(year) {
4782
- var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
4783
- return isLeapYear ? 366 : 365;
4784
- };
4785
-
4786
- var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
4787
- var temp = new Date(date.getTime());
4788
- temp.setDate(1);
4789
- return temp.getDay();
4790
- };
4791
-
4792
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
4793
- // {prev, next} Date should work for Daylight Saving Time
4794
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
4795
- var prevDate = function prevDate(date) {
4796
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4797
-
4798
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
4799
- };
4800
-
4801
- var nextDate = function nextDate(date) {
4802
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4803
-
4804
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
4805
- };
4806
-
4807
- var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
4808
- var result = new Date(year, month, 1);
4809
- var day = result.getDay();
4810
-
4811
- if (day === 0) {
4812
- return prevDate(result, 7);
4813
- } else {
4814
- return prevDate(result, day);
4815
- }
4816
- };
4817
-
4818
- var getWeekNumber = function getWeekNumber(date) {
4819
- // 支持多种输入类型
4820
- if (!date || !isDate(date)) {
4821
- date = new Date();
4822
- }
4823
- if (typeof date === 'string') {
4824
- date = new Date(date);
4825
- }
4826
-
4827
- // 验证日期有效性
4828
- if (!isDate(date)) return null;
4829
-
4830
- var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
4831
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
4832
- // 将星期日的星期数设为7
4833
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
4834
- // 获取当年的第一天
4835
- var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
4836
- // 计算到最近的星期四的完整周数
4837
- var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
4838
- // 返回周数
4839
- return weekNo;
4840
- };
4841
-
4842
- var getRangeHours = function getRangeHours(ranges) {
4843
- var hours = [];
4844
- var disabledHours = [];
4845
-
4846
- (ranges || []).forEach(function (range) {
4847
- var value = range.map(function (date) {
4848
- return date.getHours();
4849
- });
4850
-
4851
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
4852
- });
4853
-
4854
- if (disabledHours.length) {
4855
- for (var i = 0; i < 24; i++) {
4856
- hours[i] = disabledHours.indexOf(i) === -1;
4857
- }
4858
- } else {
4859
- for (var _i = 0; _i < 24; _i++) {
4860
- hours[_i] = false;
4861
- }
4862
- }
4863
-
4864
- return hours;
4865
- };
4866
-
4867
- var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
4868
- if (amount <= 0) return [];
4869
- var temp = new Date(date.getTime());
4870
- temp.setDate(0);
4871
- var lastDay = temp.getDate();
4872
- return range(amount).map(function (_, index) {
4873
- return lastDay - (amount - index - 1);
4874
- });
4875
- };
4876
-
4877
- var getMonthDays = function getMonthDays(date) {
4878
- var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
4879
- var days = temp.getDate();
4880
- return range(days).map(function (_, index) {
4881
- return index + 1;
4882
- });
4883
- };
4884
-
4885
- function setRangeData(arr, start, end, value) {
4886
- for (var i = start; i < end; i++) {
4887
- arr[i] = value;
4888
- }
4889
- }
4890
-
4891
- var getRangeMinutes = function getRangeMinutes(ranges, hour) {
4892
- var minutes = new Array(60);
4893
-
4894
- if (ranges.length > 0) {
4895
- ranges.forEach(function (range) {
4896
- var start = range[0];
4897
- var end = range[1];
4898
- var startHour = start.getHours();
4899
- var startMinute = start.getMinutes();
4900
- var endHour = end.getHours();
4901
- var endMinute = end.getMinutes();
4902
- if (startHour === hour && endHour !== hour) {
4903
- setRangeData(minutes, startMinute, 60, true);
4904
- } else if (startHour === hour && endHour === hour) {
4905
- setRangeData(minutes, startMinute, endMinute + 1, true);
4906
- } else if (startHour !== hour && endHour === hour) {
4907
- setRangeData(minutes, 0, endMinute + 1, true);
4908
- } else if (startHour < hour && endHour > hour) {
4909
- setRangeData(minutes, 0, 60, true);
4910
- }
4911
- });
4912
- } else {
4913
- setRangeData(minutes, 0, 60, true);
4914
- }
4915
- return minutes;
4916
- };
4917
-
4918
- var range = function range(n) {
4919
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
4920
- return Array.apply(null, { length: n }).map(function (_, n) {
4921
- return n;
4922
- });
4923
- };
4924
-
4925
- var modifyDate = function modifyDate(date, y, m, d) {
4926
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
4927
- };
4928
-
4929
- var modifyTime = function modifyTime(date, h, m, s) {
4930
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
4931
- };
4932
-
4933
- var modifyWithTimeString = function modifyWithTimeString(date, time) {
4934
- if (date == null || !time) {
4935
- return date;
4936
- }
4937
- time = parseDate(time, 'HH:mm:ss');
4938
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
4939
- };
4940
-
4941
- var clearTime = function clearTime(date) {
4942
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
4943
- };
4944
-
4945
- var clearMilliseconds = function clearMilliseconds(date) {
4946
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
4947
- };
4948
-
4949
- var limitTimeRange = function limitTimeRange(date, ranges) {
4950
- var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
4951
-
4952
- // TODO: refactory a more elegant solution
4953
- if (ranges.length === 0) return date;
4954
- var normalizeDate = function normalizeDate(date) {
4955
- return fecha.parse(fecha.format(date, format), format);
4956
- };
4957
- var ndate = normalizeDate(date);
4958
- var nranges = ranges.map(function (range) {
4959
- return range.map(normalizeDate);
4960
- });
4961
- if (nranges.some(function (nrange) {
4962
- return ndate >= nrange[0] && ndate <= nrange[1];
4963
- })) return date;
4964
-
4965
- var minDate = nranges[0][0];
4966
- var maxDate = nranges[0][0];
4967
-
4968
- nranges.forEach(function (nrange) {
4969
- minDate = new Date(Math.min(nrange[0], minDate));
4970
- maxDate = new Date(Math.max(nrange[1], minDate));
4971
- });
4972
-
4973
- var ret = ndate < minDate ? minDate : maxDate;
4974
- // preserve Year/Month/Date
4975
- return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
4976
- };
4977
-
4978
- var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
4979
- var limitedDate = limitTimeRange(date, selectableRange, format);
4980
- return limitedDate.getTime() === date.getTime();
4981
- };
4982
-
4983
- var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
4984
- // clamp date to the number of days in `year`, `month`
4985
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
4986
- var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
4987
- return modifyDate(date, year, month, monthDate);
4988
- };
4989
-
4990
- var prevMonth = function prevMonth(date) {
4991
- var year = date.getFullYear();
4992
- var month = date.getMonth();
4993
- return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
4994
- };
4995
-
4996
- var nextMonth = function nextMonth(date) {
4997
- var year = date.getFullYear();
4998
- var month = date.getMonth();
4999
- return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
5000
- };
5001
-
5002
- var prevYear = function prevYear(date) {
5003
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5004
-
5005
- var year = date.getFullYear();
5006
- var month = date.getMonth();
5007
- return changeYearMonthAndClampDate(date, year - amount, month);
5008
- };
5009
-
5010
- var nextYear = function nextYear(date) {
5011
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5012
-
5013
- var year = date.getFullYear();
5014
- var month = date.getMonth();
5015
- return changeYearMonthAndClampDate(date, year + amount, month);
5016
- };
5017
-
5018
- var extractDateFormat = function extractDateFormat(format) {
5019
- return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
5020
- };
5021
-
5022
- var extractTimeFormat = function extractTimeFormat(format) {
5023
- return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
5024
- };
5025
-
5026
- var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
5027
- return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
5028
- };
5029
-
4663
+ */
4664
+ fecha.parse = function (dateStr, format) {
4665
+ if (typeof format !== 'string') {
4666
+ throw new Error('Invalid format in fecha.parse');
4667
+ }
4668
+
4669
+ format = fecha.masks[format] || format;
4670
+
4671
+ // Avoid regular expression denial of service, fail early for really long strings
4672
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
4673
+ if (dateStr.length > 1000) {
4674
+ return null;
4675
+ }
4676
+
4677
+ const dateInfo = {};
4678
+ const parseInfo = [];
4679
+ const literals = [];
4680
+ format = format.replace(literal, function($0, $1) {
4681
+ literals.push($1);
4682
+ return '@@@';
4683
+ });
4684
+ let newFormat = regexEscape(format).replace(token, function ($0) {
4685
+ if (parseFlags[$0]) {
4686
+ const info = parseFlags[$0];
4687
+ parseInfo.push(info[1]);
4688
+ return '(' + info[0] + ')';
4689
+ }
4690
+
4691
+ return $0;
4692
+ });
4693
+ newFormat = newFormat.replace(/@@@/g, function() {
4694
+ return literals.shift();
4695
+ });
4696
+ const matches = dateStr.match(new RegExp(newFormat, 'i'));
4697
+ if (!matches) {
4698
+ return null;
4699
+ }
4700
+
4701
+ for (let i = 1; i < matches.length; i++) {
4702
+ parseInfo[i - 1](dateInfo, matches[i]);
4703
+ }
4704
+
4705
+ const today = new Date();
4706
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
4707
+ dateInfo.hour = +dateInfo.hour + 12;
4708
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
4709
+ dateInfo.hour = 0;
4710
+ }
4711
+
4712
+ let date;
4713
+ if (dateInfo.timezoneOffset != null) {
4714
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
4715
+ date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
4716
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
4717
+ } else {
4718
+ date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
4719
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
4720
+ }
4721
+ return date;
4722
+ };
4723
+
4724
+ // 导出fecha对象
4725
+
4726
+
4727
+ // 以下是从date-util.js合并的函数
4728
+ const newArray = function(start, end) {
4729
+ let result = [];
4730
+ for (let i = start; i <= end; i++) {
4731
+ result.push(i);
4732
+ }
4733
+ return result;
4734
+ };
4735
+
4736
+ const getSettings = () => {
4737
+ return {
4738
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
4739
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
4740
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
4741
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
4742
+ amPm: ['上午', '下午']
4743
+ };
4744
+ };
4745
+
4746
+ const toDate = function(date) {
4747
+ return isDate(date) ? new Date(date) : null;
4748
+ };
4749
+
4750
+ const isDate = function(date) {
4751
+ if (date === null || date === undefined) return false;
4752
+ if (isNaN(new Date(date).getTime())) return false;
4753
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
4754
+ return true;
4755
+ };
4756
+
4757
+ const isDateObject = function(val) {
4758
+ return val instanceof Date;
4759
+ };
4760
+
4761
+ const formatDate = function (date, format = 'yyyy-MM-dd') {
4762
+ // 处理多种输入类型
4763
+ if (!date) return '';
4764
+
4765
+ // 如果是时间戳,转成日期对象
4766
+ if (typeof date === 'number') {
4767
+ date = new Date(date);
4768
+ }
4769
+ // 如果是字符串,转成日期对象
4770
+ if (typeof date === 'string') {
4771
+ date = new Date(date);
4772
+ }
4773
+
4774
+ // 调用toDate进一步验证和转换
4775
+ date = toDate(date);
4776
+ if (!date) return '';
4777
+
4778
+ // 兼容大写和小写的格式标记
4779
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
4780
+ const lowercaseFormat = format
4781
+ .replace(/YYYY/g, 'yyyy')
4782
+ .replace(/D/g, 'd')
4783
+
4784
+ // 使用fecha库进行格式化,支持中文配置
4785
+ const str = fecha.format(date, lowercaseFormat, getSettings());
4786
+ return str;
4787
+ };
4788
+
4789
+ const parseDate = function(string, format) {
4790
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
4791
+ };
4792
+
4793
+ const getDayCountOfMonth = function(year, month) {
4794
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
4795
+ return 30;
4796
+ }
4797
+
4798
+ if (month === 1) {
4799
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
4800
+ return 29;
4801
+ } else {
4802
+ return 28;
4803
+ }
4804
+ }
4805
+
4806
+ return 31;
4807
+ };
4808
+
4809
+ const getDayCountOfYear = function(year) {
4810
+ const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
4811
+ return isLeapYear ? 366 : 365;
4812
+ };
4813
+
4814
+ const getFirstDayOfMonth = function(date) {
4815
+ const temp = new Date(date.getTime());
4816
+ temp.setDate(1);
4817
+ return temp.getDay();
4818
+ };
4819
+
4820
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
4821
+ // {prev, next} Date should work for Daylight Saving Time
4822
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
4823
+ const prevDate = function(date, amount = 1) {
4824
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
4825
+ };
4826
+
4827
+ const nextDate = function(date, amount = 1) {
4828
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
4829
+ };
4830
+
4831
+ const getStartDateOfMonth = function(year, month) {
4832
+ const result = new Date(year, month, 1);
4833
+ const day = result.getDay();
4834
+
4835
+ if (day === 0) {
4836
+ return prevDate(result, 7);
4837
+ } else {
4838
+ return prevDate(result, day);
4839
+ }
4840
+ };
4841
+
4842
+ const getWeekNumber = function(date) {
4843
+ // 支持多种输入类型
4844
+ if (!date||!isDate(date)) {
4845
+ date = new Date();
4846
+ }
4847
+ if (typeof date === 'string') {
4848
+ date = new Date(date);
4849
+ }
4850
+
4851
+ // 验证日期有效性
4852
+ if (!isDate(date)) return null;
4853
+
4854
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
4855
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
4856
+ // 将星期日的星期数设为7
4857
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
4858
+ // 获取当年的第一天
4859
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
4860
+ // 计算到最近的星期四的完整周数
4861
+ const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
4862
+ // 返回周数
4863
+ return weekNo;
4864
+ };
4865
+
4866
+ const getRangeHours = function(ranges) {
4867
+ const hours = [];
4868
+ let disabledHours = [];
4869
+
4870
+ (ranges || []).forEach(range => {
4871
+ const value = range.map(date => date.getHours());
4872
+
4873
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
4874
+ });
4875
+
4876
+ if (disabledHours.length) {
4877
+ for (let i = 0; i < 24; i++) {
4878
+ hours[i] = disabledHours.indexOf(i) === -1;
4879
+ }
4880
+ } else {
4881
+ for (let i = 0; i < 24; i++) {
4882
+ hours[i] = false;
4883
+ }
4884
+ }
4885
+
4886
+ return hours;
4887
+ };
4888
+
4889
+ const getPrevMonthLastDays = (date, amount) => {
4890
+ if (amount <= 0) return [];
4891
+ const temp = new Date(date.getTime());
4892
+ temp.setDate(0);
4893
+ const lastDay = temp.getDate();
4894
+ return range(amount).map((_, index) => lastDay - (amount - index - 1));
4895
+ };
4896
+
4897
+ const getMonthDays = (date) => {
4898
+ const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
4899
+ const days = temp.getDate();
4900
+ return range(days).map((_, index) => index + 1);
4901
+ };
4902
+
4903
+ function setRangeData(arr, start, end, value) {
4904
+ for (let i = start; i < end; i++) {
4905
+ arr[i] = value;
4906
+ }
4907
+ }
4908
+
4909
+ const getRangeMinutes = function(ranges, hour) {
4910
+ const minutes = new Array(60);
4911
+
4912
+ if (ranges.length > 0) {
4913
+ ranges.forEach(range => {
4914
+ const start = range[0];
4915
+ const end = range[1];
4916
+ const startHour = start.getHours();
4917
+ const startMinute = start.getMinutes();
4918
+ const endHour = end.getHours();
4919
+ const endMinute = end.getMinutes();
4920
+ if (startHour === hour && endHour !== hour) {
4921
+ setRangeData(minutes, startMinute, 60, true);
4922
+ } else if (startHour === hour && endHour === hour) {
4923
+ setRangeData(minutes, startMinute, endMinute + 1, true);
4924
+ } else if (startHour !== hour && endHour === hour) {
4925
+ setRangeData(minutes, 0, endMinute + 1, true);
4926
+ } else if (startHour < hour && endHour > hour) {
4927
+ setRangeData(minutes, 0, 60, true);
4928
+ }
4929
+ });
4930
+ } else {
4931
+ setRangeData(minutes, 0, 60, true);
4932
+ }
4933
+ return minutes;
4934
+ };
4935
+
4936
+ const range = function(n) {
4937
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
4938
+ return Array.apply(null, {length: n}).map((_, n) => n);
4939
+ };
4940
+
4941
+ const modifyDate = function(date, y, m, d) {
4942
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
4943
+ };
4944
+
4945
+ const modifyTime = function(date, h, m, s) {
4946
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
4947
+ };
4948
+
4949
+ const modifyWithTimeString = (date, time) => {
4950
+ if (date == null || !time) {
4951
+ return date;
4952
+ }
4953
+ time = parseDate(time, 'HH:mm:ss');
4954
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
4955
+ };
4956
+
4957
+ const clearTime = function(date) {
4958
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
4959
+ };
4960
+
4961
+ const clearMilliseconds = function(date) {
4962
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
4963
+ };
4964
+
4965
+ const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
4966
+ // TODO: refactory a more elegant solution
4967
+ if (ranges.length === 0) return date;
4968
+ const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
4969
+ const ndate = normalizeDate(date);
4970
+ const nranges = ranges.map(range => range.map(normalizeDate));
4971
+ if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
4972
+
4973
+ let minDate = nranges[0][0];
4974
+ let maxDate = nranges[0][0];
4975
+
4976
+ nranges.forEach(nrange => {
4977
+ minDate = new Date(Math.min(nrange[0], minDate));
4978
+ maxDate = new Date(Math.max(nrange[1], minDate));
4979
+ });
4980
+
4981
+ const ret = ndate < minDate ? minDate : maxDate;
4982
+ // preserve Year/Month/Date
4983
+ return modifyDate(
4984
+ ret,
4985
+ date.getFullYear(),
4986
+ date.getMonth(),
4987
+ date.getDate()
4988
+ );
4989
+ };
4990
+
4991
+ const timeWithinRange = function(date, selectableRange, format) {
4992
+ const limitedDate = limitTimeRange(date, selectableRange, format);
4993
+ return limitedDate.getTime() === date.getTime();
4994
+ };
4995
+
4996
+ const changeYearMonthAndClampDate = function(date, year, month) {
4997
+ // clamp date to the number of days in `year`, `month`
4998
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
4999
+ const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
5000
+ return modifyDate(date, year, month, monthDate);
5001
+ };
5002
+
5003
+ const prevMonth = function(date) {
5004
+ const year = date.getFullYear();
5005
+ const month = date.getMonth();
5006
+ return month === 0
5007
+ ? changeYearMonthAndClampDate(date, year - 1, 11)
5008
+ : changeYearMonthAndClampDate(date, year, month - 1);
5009
+ };
5010
+
5011
+ const nextMonth = function(date) {
5012
+ const year = date.getFullYear();
5013
+ const month = date.getMonth();
5014
+ return month === 11
5015
+ ? changeYearMonthAndClampDate(date, year + 1, 0)
5016
+ : changeYearMonthAndClampDate(date, year, month + 1);
5017
+ };
5018
+
5019
+ const prevYear = function(date, amount = 1) {
5020
+ const year = date.getFullYear();
5021
+ const month = date.getMonth();
5022
+ return changeYearMonthAndClampDate(date, year - amount, month);
5023
+ };
5024
+
5025
+ const nextYear = function(date, amount = 1) {
5026
+ const year = date.getFullYear();
5027
+ const month = date.getMonth();
5028
+ return changeYearMonthAndClampDate(date, year + amount, month);
5029
+ };
5030
+
5031
+ const extractDateFormat = function(format) {
5032
+ return format
5033
+ .replace(/\W?m{1,2}|\W?ZZ/g, '')
5034
+ .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
5035
+ .trim();
5036
+ };
5037
+
5038
+ const extractTimeFormat = function(format) {
5039
+ return format
5040
+ .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
5041
+ .trim();
5042
+ };
5043
+
5044
+ const validateRangeInOneMonth = function(start, end) {
5045
+ return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
5046
+ };
5047
+
5030
5048
  /**
5031
5049
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
5032
5050
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
5033
5051
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
5034
5052
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
5035
5053
  * @returns {number} 工作日数量
5036
- */
5037
- var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
5038
- var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
5039
-
5040
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
5041
- throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
5042
- }
5043
-
5044
- var startDateObj = new Date(start_date);
5045
- var endDateObj = new Date(end_date);
5046
-
5047
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
5048
- throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
5049
- }
5050
-
5051
- if (startDateObj > endDateObj) {
5052
- throw new Error('Start date should be earlier than or equal to end date.');
5053
- }
5054
-
5055
- var workdays = 0;
5056
-
5057
- // Iterate through each day in the date range
5058
-
5059
- var _loop = function _loop(currentDate) {
5060
- // Check if the current day is a weekend (Saturday or Sunday)
5061
- var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
5062
-
5063
- // Check if the current day is a holiday
5064
- var isHoliday = holidays.some(function (holiday) {
5065
- var holidayDate = new Date(holiday);
5066
- return currentDate.toDateString() === holidayDate.toDateString();
5067
- });
5068
-
5069
- // If it's a workday (not a weekend or holiday), increment the workdays count
5070
- if (!isWeekend && !isHoliday) {
5071
- workdays++;
5072
- }
5073
- };
5074
-
5075
- for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
5076
- _loop(currentDate);
5077
- }
5078
-
5079
- return workdays;
5080
- };
5081
-
5054
+ */
5055
+ const calculateNetworkDays = function (start_date, end_date, holidays = []) {
5056
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
5057
+ throw new Error(
5058
+ "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
5059
+ );
5060
+ }
5061
+
5062
+ const startDateObj = new Date(start_date);
5063
+ const endDateObj = new Date(end_date);
5064
+
5065
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
5066
+ throw new Error(
5067
+ "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
5068
+ );
5069
+ }
5070
+
5071
+ if (startDateObj > endDateObj) {
5072
+ throw new Error('Start date should be earlier than or equal to end date.');
5073
+ }
5074
+
5075
+ let workdays = 0;
5076
+
5077
+ // Iterate through each day in the date range
5078
+ for (
5079
+ let currentDate = new Date(startDateObj);
5080
+ currentDate <= endDateObj;
5081
+ currentDate.setDate(currentDate.getDate() + 1)
5082
+ ) {
5083
+ // Check if the current day is a weekend (Saturday or Sunday)
5084
+ const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
5085
+
5086
+ // Check if the current day is a holiday
5087
+ const isHoliday = holidays.some((holiday) => {
5088
+ const holidayDate = new Date(holiday);
5089
+ return currentDate.toDateString() === holidayDate.toDateString();
5090
+ });
5091
+
5092
+ // If it's a workday (not a weekend or holiday), increment the workdays count
5093
+ if (!isWeekend && !isHoliday) {
5094
+ workdays++;
5095
+ }
5096
+ }
5097
+
5098
+ return workdays;
5099
+ };
5100
+
5082
5101
  /**
5083
5102
  * 日期加减天数
5084
5103
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
5085
5104
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
5086
5105
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
5087
- */
5088
- var dateAddDays = function dateAddDays(start_date, days) {
5089
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
5090
- throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days.");
5091
- }
5092
-
5093
- var startDateObj = new Date(start_date);
5094
- if (isNaN(startDateObj.getTime())) {
5095
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5096
- }
5097
-
5098
- var resultDateObj = new Date(startDateObj);
5099
- resultDateObj.setDate(resultDateObj.getDate() + days);
5100
-
5101
- var resultYear = resultDateObj.getFullYear();
5102
- var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
5103
- var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
5104
-
5105
- return resultYear + '-' + resultMonth + '-' + resultDay;
5106
- };
5107
-
5106
+ */
5107
+ const dateAddDays = function (start_date, days) {
5108
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
5109
+ throw new Error(
5110
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
5111
+ );
5112
+ }
5113
+
5114
+ const startDateObj = new Date(start_date);
5115
+ if (isNaN(startDateObj.getTime())) {
5116
+ throw new Error(
5117
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
5118
+ );
5119
+ }
5120
+
5121
+ const resultDateObj = new Date(startDateObj);
5122
+ resultDateObj.setDate(resultDateObj.getDate() + days);
5123
+
5124
+ const resultYear = resultDateObj.getFullYear();
5125
+ const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
5126
+ const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
5127
+
5128
+ return `${resultYear}-${resultMonth}-${resultDay}`;
5129
+ };
5130
+
5108
5131
  /**
5109
5132
  * 计算两个日期之间的差值
5110
5133
  * @date 2023年12月14日
@@ -5112,180 +5135,182 @@ var dateAddDays = function dateAddDays(start_date, days) {
5112
5135
  * @param {String} end_date - 结束日期字符串
5113
5136
  * @param {String} unit - 单位:year/month/day
5114
5137
  * @returns {Number} 差值
5115
- */
5116
- var dateDiff = function dateDiff(start_date, end_date) {
5117
- var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
5118
-
5119
- // Assuming date strings are in "YYYY-MM-DD" format
5120
- var startDate = new Date(start_date);
5121
- var endDate = new Date(end_date);
5122
-
5123
- // If the date is invalid, return 0
5124
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
5125
- return 0;
5126
- }
5127
-
5128
- if (unit === 'year') {
5129
- return endDate.getFullYear() - startDate.getFullYear();
5130
- } else if (unit === 'month') {
5131
- return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
5132
- } else {
5133
- // Default to day
5134
- var timeDifference = endDate - startDate;
5135
- // Calculate days (86400000 milliseconds per day)
5136
- return Math.floor(timeDifference / 86400000);
5137
- }
5138
- };
5139
-
5138
+ */
5139
+ const dateDiff = function (start_date, end_date, unit = 'day') {
5140
+ // Assuming date strings are in "YYYY-MM-DD" format
5141
+ var startDate = new Date(start_date);
5142
+ var endDate = new Date(end_date);
5143
+
5144
+ // If the date is invalid, return 0
5145
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
5146
+ return 0;
5147
+ }
5148
+
5149
+ if (unit === 'year') {
5150
+ return endDate.getFullYear() - startDate.getFullYear();
5151
+ } else if (unit === 'month') {
5152
+ return (
5153
+ (endDate.getFullYear() - startDate.getFullYear()) * 12 +
5154
+ (endDate.getMonth() - startDate.getMonth())
5155
+ );
5156
+ } else {
5157
+ // Default to day
5158
+ var timeDifference = endDate - startDate;
5159
+ // Calculate days (86400000 milliseconds per day)
5160
+ return Math.floor(timeDifference / 86400000);
5161
+ }
5162
+ };
5163
+
5140
5164
  /**
5141
5165
  * 获取月份中的日期
5142
5166
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
5143
5167
  * @returns {number} 月份中的日期(1-31)
5144
- */
5145
- var dayOfMonth = function dayOfMonth(date) {
5146
- if (typeof date !== 'string') {
5147
- throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5148
- }
5149
-
5150
- var dateObj = new Date(date);
5151
- if (isNaN(dateObj.getTime())) {
5152
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5153
- }
5154
-
5155
- return dateObj.getDate();
5156
- };
5157
-
5168
+ */
5169
+ const dayOfMonth = function (date) {
5170
+ if (typeof date !== 'string') {
5171
+ throw new Error(
5172
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
5173
+ );
5174
+ }
5175
+
5176
+ const dateObj = new Date(date);
5177
+ if (isNaN(dateObj.getTime())) {
5178
+ throw new Error(
5179
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
5180
+ );
5181
+ }
5182
+
5183
+ return dateObj.getDate();
5184
+ };
5185
+
5158
5186
  /**
5159
5187
  * 获取当前日期
5160
5188
  * @date 2022年5月7日
5161
5189
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
5162
5190
  * @returns {string} 当前日期的格式化字符串
5163
- */
5164
- var getCurrentDate = function getCurrentDate() {
5165
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
5166
-
5167
- return formatDate(new Date(), format);
5168
- };
5169
-
5191
+ */
5192
+ const getCurrentDate = function (format = 'YYYY-MM-DD') {
5193
+ return formatDate(new Date(), format);
5194
+ };
5195
+
5170
5196
  /**
5171
5197
  * 获取当前日期时间
5172
5198
  * @date 2022年5月7日
5173
5199
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
5174
5200
  * @returns {string} 当前日期时间的格式化字符串
5175
- */
5176
- var getCurrentDateTime = function getCurrentDateTime() {
5177
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
5178
-
5179
- return formatDate(new Date(), format);
5180
- };
5181
-
5201
+ */
5202
+ const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
5203
+ return formatDate(new Date(), format);
5204
+ };
5205
+
5182
5206
  /**
5183
5207
  * 获取小时
5184
5208
  * @date 2022年5月7日
5185
5209
  * @param {Date|string} [date] - 日期对象或日期字符串
5186
5210
  * @returns {number} 小时数(0-23)
5187
- */
5188
- var getHour = function getHour(date) {
5189
- if (!date) {
5190
- return new Date().getHours();
5191
- }
5192
- if (typeof date === 'string') {
5193
- date = new Date(date);
5194
- }
5195
- return date.getHours();
5196
- };
5197
-
5211
+ */
5212
+ const getHour = function (date) {
5213
+ if (!date) {
5214
+ return new Date().getHours();
5215
+ }
5216
+ if (typeof date === 'string') {
5217
+ date = new Date(date);
5218
+ }
5219
+ return date.getHours();
5220
+ };
5221
+
5198
5222
  /**
5199
5223
  * 获取分钟
5200
5224
  * @date 2022年5月7日
5201
5225
  * @param {Date|string} [date] - 日期对象或日期字符串
5202
5226
  * @returns {number} 分钟数(0-59)
5203
- */
5204
- var getMinute = function getMinute(date) {
5205
- if (!date) {
5206
- return new Date().getMinutes();
5207
- }
5208
- if (typeof date === 'string') {
5209
- date = new Date(date);
5210
- }
5211
- return date.getMinutes();
5212
- };
5213
-
5227
+ */
5228
+ const getMinute = function (date) {
5229
+ if (!date) {
5230
+ return new Date().getMinutes();
5231
+ }
5232
+ if (typeof date === 'string') {
5233
+ date = new Date(date);
5234
+ }
5235
+ return date.getMinutes();
5236
+ };
5237
+
5214
5238
  /**
5215
5239
  * 获取月份
5216
5240
  * @date 2022年5月7日
5217
5241
  * @param {Date|string} [date] - 日期对象或日期字符串
5218
5242
  * @returns {number} 月份数(1-12)
5219
- */
5220
- var getMonth = function getMonth(date) {
5221
- if (!date) {
5222
- return new Date().getMonth() + 1;
5223
- }
5224
- if (typeof date === 'string') {
5225
- date = new Date(date);
5226
- }
5227
- return date.getMonth() + 1;
5228
- };
5229
-
5243
+ */
5244
+ const getMonth = function (date) {
5245
+ if (!date) {
5246
+ return new Date().getMonth() + 1;
5247
+ }
5248
+ if (typeof date === 'string') {
5249
+ date = new Date(date);
5250
+ }
5251
+ return date.getMonth() + 1;
5252
+ };
5253
+
5230
5254
  /**
5231
5255
  * 获取秒
5232
5256
  * @date 2022年5月7日
5233
5257
  * @param {Date|string} [date] - 日期对象或日期字符串
5234
5258
  * @returns {number} 秒数(0-59)
5235
- */
5236
- var getSecond = function getSecond(date) {
5237
- if (!date) {
5238
- return new Date().getSeconds();
5239
- }
5240
- if (typeof date === 'string') {
5241
- date = new Date(date);
5242
- }
5243
- return date.getSeconds();
5244
- };
5245
-
5259
+ */
5260
+ const getSecond = function (date) {
5261
+ if (!date) {
5262
+ return new Date().getSeconds();
5263
+ }
5264
+ if (typeof date === 'string') {
5265
+ date = new Date(date);
5266
+ }
5267
+ return date.getSeconds();
5268
+ };
5269
+
5246
5270
  /**
5247
5271
  * 获取星期几
5248
5272
  * @date 2022年5月7日
5249
5273
  * @param {Date|string} [date] - 日期对象或日期字符串
5250
5274
  * @returns {number} 星期几(0-6,0表示星期日)
5251
- */
5252
- var getWeekday = function getWeekday(date) {
5253
- if (!date) {
5254
- return new Date().getDay();
5255
- }
5256
- if (typeof date === 'string') {
5257
- date = new Date(date);
5258
- }
5259
- return date.getDay();
5260
- };
5261
-
5275
+ */
5276
+ const getWeekday = function (date) {
5277
+ if (!date) {
5278
+ return new Date().getDay();
5279
+ }
5280
+ if (typeof date === 'string') {
5281
+ date = new Date(date);
5282
+ }
5283
+ return date.getDay();
5284
+ };
5285
+
5286
+
5262
5287
  /**
5263
5288
  * @desc 获取上午/下午/晚上
5264
5289
  * @author huangbo
5265
5290
  * @date 2022年5月7日
5266
5291
  * @param {String} [time] - 时间
5267
- **/
5268
- var timeCycle = function timeCycle(time) {
5269
- var hour = 0;
5270
- if (!time) {
5271
- hour = new Date().getHours();
5272
- } else if (typeof time === 'string') {
5273
- // 从时间字符串中提取小时
5274
- var match = time.match(/^(\d{1,2})/);
5275
- if (match) {
5276
- hour = parseInt(match[1], 10);
5277
- }
5278
- } else if (typeof time === 'number') {
5279
- hour = time;
5280
- }
5281
- // 判断时间段
5282
- if (hour >= 5 && hour < 12) {
5283
- return '上午';
5284
- } else if (hour >= 12 && hour < 18) {
5285
- return '下午';
5286
- } else {
5287
- return '晚上';
5288
- }
5292
+ **/
5293
+ const timeCycle = function (time) {
5294
+ let hour = 0;
5295
+ if (!time) {
5296
+ hour = new Date().getHours();
5297
+ } else if (typeof time === 'string') {
5298
+ // 从时间字符串中提取小时
5299
+ const match = time.match(/^(\d{1,2})/);
5300
+ if (match) {
5301
+ hour = parseInt(match[1], 10);
5302
+ }
5303
+ } else if (typeof time === 'number') {
5304
+ hour = time;
5305
+ }
5306
+ // 判断时间段
5307
+ if (hour >= 5 && hour < 12) {
5308
+ return '上午';
5309
+ } else if (hour >= 12 && hour < 18) {
5310
+ return '下午';
5311
+ } else {
5312
+ return '晚上';
5313
+ }
5289
5314
  };
5290
5315
 
5291
5316
  /***/ }),
@@ -5297,7 +5322,7 @@ module.exports = require("eoss/lib/message-box");
5297
5322
 
5298
5323
  /***/ }),
5299
5324
 
5300
- /***/ 83:
5325
+ /***/ 84:
5301
5326
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
5302
5327
 
5303
5328
  "use strict";