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/input.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 = 208);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 211);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -3568,7 +3568,7 @@ module.exports = require("vue");
3568
3568
 
3569
3569
  /***/ }),
3570
3570
 
3571
- /***/ 208:
3571
+ /***/ 211:
3572
3572
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3573
3573
 
3574
3574
  "use strict";
@@ -3884,7 +3884,7 @@ render._withStripped = true
3884
3884
  var emitter = __webpack_require__(15);
3885
3885
 
3886
3886
  // EXTERNAL MODULE: ./src/mixins/migrating.js
3887
- var migrating = __webpack_require__(45);
3887
+ var migrating = __webpack_require__(46);
3888
3888
 
3889
3889
  // CONCATENATED MODULE: ./packages/input/src/calcTextareaHeight.js
3890
3890
  var hiddenTextarea = void 0;
@@ -3960,17 +3960,17 @@ function calcTextareaHeight(targetElement) {
3960
3960
  return result;
3961
3961
  };
3962
3962
  // EXTERNAL MODULE: ./src/utils/merge.js
3963
- var merge = __webpack_require__(21);
3963
+ var merge = __webpack_require__(22);
3964
3964
 
3965
3965
  // EXTERNAL MODULE: ./src/utils/shared.js
3966
- var shared = __webpack_require__(80);
3966
+ var shared = __webpack_require__(81);
3967
3967
 
3968
3968
  // EXTERNAL MODULE: external "eoss/lib/button"
3969
3969
  var button_ = __webpack_require__(13);
3970
3970
  var button_default = /*#__PURE__*/__webpack_require__.n(button_);
3971
3971
 
3972
3972
  // EXTERNAL MODULE: ./src/utils/resize-event.js
3973
- var resize_event = __webpack_require__(37);
3973
+ var resize_event = __webpack_require__(38);
3974
3974
 
3975
3975
  // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/input/src/input.vue?vue&type=script&lang=js&
3976
3976
  //
@@ -4774,7 +4774,7 @@ input.install = function (Vue) {
4774
4774
 
4775
4775
  /***/ }),
4776
4776
 
4777
- /***/ 21:
4777
+ /***/ 22:
4778
4778
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4779
4779
 
4780
4780
  "use strict";
@@ -4863,7 +4863,7 @@ function isDefined(val) {
4863
4863
 
4864
4864
  /***/ }),
4865
4865
 
4866
- /***/ 37:
4866
+ /***/ 38:
4867
4867
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4868
4868
 
4869
4869
  "use strict";
@@ -5181,7 +5181,7 @@ function normalizeComponent(
5181
5181
 
5182
5182
  /***/ }),
5183
5183
 
5184
- /***/ 45:
5184
+ /***/ 46:
5185
5185
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
5186
5186
 
5187
5187
  "use strict";
@@ -5303,736 +5303,759 @@ function normalizeComponent(
5303
5303
  /* unused harmony export getSecond */
5304
5304
  /* unused harmony export getWeekday */
5305
5305
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
5306
-
5307
-
5306
+ /* Modified from https://github.com/taylorhakes/fecha
5307
+ *
5308
+ * The MIT License (MIT)
5309
+ *
5310
+ * Copyright (c) 2015 Taylor Hakes
5311
+ *
5312
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5313
+ * of this software and associated documentation files (the "Software"), to deal
5314
+ * in the Software without restriction, including without limitation the rights
5315
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5316
+ * copies of the Software, and to permit persons to whom the Software is
5317
+ * furnished to do so, subject to the following conditions:
5318
+ *
5319
+ * The above copyright notice and this permission notice shall be included in all
5320
+ * copies or substantial portions of the Software.
5321
+ *
5322
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5323
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5324
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5325
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5326
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5327
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
5328
+ * SOFTWARE.
5329
+ */
5330
+
5331
+ /*eslint-disable*/
5332
+ // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
5333
+
5334
+
5308
5335
  /**
5309
5336
  * Parse or format dates
5310
5337
  * @class fecha
5311
- */
5312
- var fecha = {};
5313
- var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
5314
- var twoDigits = '\\d\\d?';
5315
- var threeDigits = '\\d{3}';
5316
- var fourDigits = '\\d{4}';
5317
- var word = '[^\\s]+';
5318
- var literal = /\[([^]*?)\]/gm;
5319
- var noop = function noop() {};
5320
-
5321
- function regexEscape(str) {
5322
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
5323
- }
5324
-
5325
- function shorten(arr, sLen) {
5326
- var newArr = [];
5327
- for (var i = 0, len = arr.length; i < len; i++) {
5328
- newArr.push(arr[i].substr(0, sLen));
5329
- }
5330
- return newArr;
5331
- }
5332
-
5333
- function monthUpdate() {
5334
- return function (d, v) {
5335
- var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
5336
- if (~index) {
5337
- d.month = index;
5338
- }
5339
- };
5340
- }
5341
-
5342
- function pad(val, len) {
5343
- val = String(val);
5344
- len = len || 2;
5345
- while (val.length < len) {
5346
- val = '0' + val;
5347
- }
5348
- return val;
5349
- }
5350
-
5351
- // 直接使用中文日期名称常量
5352
- var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
5353
- var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
5354
- var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
5355
- var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
5356
- var amPm = ['上午', '下午'];
5357
- var DoFn = function DoFn(D) {
5358
- return D + '日';
5359
- };
5360
-
5361
- var formatFlags = {
5362
- D: function D(dateObj) {
5363
- return dateObj.getDay();
5364
- },
5365
- DD: function DD(dateObj) {
5366
- return pad(dateObj.getDay());
5367
- },
5368
- Do: function Do(dateObj) {
5369
- return DoFn(dateObj.getDate());
5370
- },
5371
- d: function d(dateObj) {
5372
- return dateObj.getDate();
5373
- },
5374
- dd: function dd(dateObj) {
5375
- return pad(dateObj.getDate());
5376
- },
5377
- ddd: function ddd(dateObj) {
5378
- return dayNamesShort[dateObj.getDay()];
5379
- },
5380
- dddd: function dddd(dateObj) {
5381
- return dayNames[dateObj.getDay()];
5382
- },
5383
- M: function M(dateObj) {
5384
- return dateObj.getMonth() + 1;
5385
- },
5386
- MM: function MM(dateObj) {
5387
- return pad(dateObj.getMonth() + 1);
5388
- },
5389
- MMM: function MMM(dateObj) {
5390
- return monthNamesShort[dateObj.getMonth()];
5391
- },
5392
- MMMM: function MMMM(dateObj) {
5393
- return monthNames[dateObj.getMonth()];
5394
- },
5395
- yy: function yy(dateObj) {
5396
- return pad(String(dateObj.getFullYear()), 4).substr(2);
5397
- },
5398
- yyyy: function yyyy(dateObj) {
5399
- return pad(dateObj.getFullYear(), 4);
5400
- },
5401
- h: function h(dateObj) {
5402
- return dateObj.getHours() % 12 || 12;
5403
- },
5404
- hh: function hh(dateObj) {
5405
- return pad(dateObj.getHours() % 12 || 12);
5406
- },
5407
- H: function H(dateObj) {
5408
- return dateObj.getHours();
5409
- },
5410
- HH: function HH(dateObj) {
5411
- return pad(dateObj.getHours());
5412
- },
5413
- m: function m(dateObj) {
5414
- return dateObj.getMinutes();
5415
- },
5416
- mm: function mm(dateObj) {
5417
- return pad(dateObj.getMinutes());
5418
- },
5419
- s: function s(dateObj) {
5420
- return dateObj.getSeconds();
5421
- },
5422
- ss: function ss(dateObj) {
5423
- return pad(dateObj.getSeconds());
5424
- },
5425
- S: function S(dateObj) {
5426
- return Math.round(dateObj.getMilliseconds() / 100);
5427
- },
5428
- SS: function SS(dateObj) {
5429
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
5430
- },
5431
- SSS: function SSS(dateObj) {
5432
- return pad(dateObj.getMilliseconds(), 3);
5433
- },
5434
- a: function a(dateObj) {
5435
- return dateObj.getHours() < 12 ? '上午' : '下午';
5436
- },
5437
- A: function A(dateObj) {
5438
- return dateObj.getHours() < 12 ? '上午' : '下午';
5439
- },
5440
- ZZ: function ZZ(dateObj) {
5441
- var o = dateObj.getTimezoneOffset();
5442
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
5443
- }
5444
- };
5445
-
5446
- var parseFlags = {
5447
- d: [twoDigits, function (d, v) {
5448
- d.day = v;
5449
- }],
5450
- Do: [twoDigits + word, function (d, v) {
5451
- d.day = parseInt(v, 10);
5452
- }],
5453
- M: [twoDigits, function (d, v) {
5454
- d.month = v - 1;
5455
- }],
5456
- yy: [twoDigits, function (d, v) {
5457
- var da = new Date(),
5458
- cent = +('' + da.getFullYear()).substr(0, 2);
5459
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
5460
- }],
5461
- h: [twoDigits, function (d, v) {
5462
- d.hour = v;
5463
- }],
5464
- m: [twoDigits, function (d, v) {
5465
- d.minute = v;
5466
- }],
5467
- s: [twoDigits, function (d, v) {
5468
- d.second = v;
5469
- }],
5470
- yyyy: [fourDigits, function (d, v) {
5471
- d.year = v;
5472
- }],
5473
- S: ['\\d', function (d, v) {
5474
- d.millisecond = v * 100;
5475
- }],
5476
- SS: ['\\d{2}', function (d, v) {
5477
- d.millisecond = v * 10;
5478
- }],
5479
- SSS: [threeDigits, function (d, v) {
5480
- d.millisecond = v;
5481
- }],
5482
- D: [twoDigits, noop],
5483
- ddd: [word, noop],
5484
- MMM: [word, monthUpdate('monthNamesShort')],
5485
- MMMM: [word, monthUpdate('monthNames')],
5486
- a: [word, function (d, v) {
5487
- var val = v.toLowerCase();
5488
- if (val === '上午') {
5489
- d.isPm = false;
5490
- } else if (val === '下午') {
5491
- d.isPm = true;
5492
- }
5493
- }],
5494
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
5495
- var parts = (v + '').match(/([+-]|\d\d)/gi),
5496
- minutes = void 0;
5497
-
5498
- if (parts) {
5499
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
5500
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
5501
- }
5502
- }]
5503
- };
5504
- parseFlags.dd = parseFlags.d;
5505
- parseFlags.dddd = parseFlags.ddd;
5506
- parseFlags.DD = parseFlags.D;
5507
- parseFlags.mm = parseFlags.m;
5508
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
5509
- parseFlags.MM = parseFlags.M;
5510
- parseFlags.ss = parseFlags.s;
5511
- parseFlags.A = parseFlags.a;
5512
-
5513
- // Some common format strings
5514
- fecha.masks = {
5515
- default: 'ddd MMM dd yyyy HH:mm:ss',
5516
- shortDate: 'M/D/yy',
5517
- mediumDate: 'MMM d, yyyy',
5518
- longDate: 'MMMM d, yyyy',
5519
- fullDate: 'dddd, MMMM d, yyyy',
5520
- shortTime: 'HH:mm',
5521
- mediumTime: 'HH:mm:ss',
5522
- longTime: 'HH:mm:ss.SSS'
5523
- };
5524
-
5338
+ */
5339
+ const fecha = {};
5340
+ const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
5341
+ const twoDigits = '\\d\\d?';
5342
+ const threeDigits = '\\d{3}';
5343
+ const fourDigits = '\\d{4}';
5344
+ const word = '[^\\s]+';
5345
+ const literal = /\[([^]*?)\]/gm;
5346
+ const noop = function () {};
5347
+
5348
+ function regexEscape(str) {
5349
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
5350
+ }
5351
+
5352
+ function shorten(arr, sLen) {
5353
+ const newArr = [];
5354
+ for (let i = 0, len = arr.length; i < len; i++) {
5355
+ newArr.push(arr[i].substr(0, sLen));
5356
+ }
5357
+ return newArr;
5358
+ }
5359
+
5360
+ function monthUpdate() {
5361
+ return function (d, v) {
5362
+ const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
5363
+ if (~index) {
5364
+ d.month = index;
5365
+ }
5366
+ };
5367
+ }
5368
+
5369
+ function pad(val, len) {
5370
+ val = String(val);
5371
+ len = len || 2;
5372
+ while (val.length < len) {
5373
+ val = '0' + val;
5374
+ }
5375
+ return val;
5376
+ }
5377
+
5378
+ // 直接使用中文日期名称常量
5379
+ const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
5380
+ const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
5381
+ const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
5382
+ const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
5383
+ const amPm = ['上午', '下午'];
5384
+ const DoFn = function DoFn(D) {
5385
+ return D + '日';
5386
+ };
5387
+
5388
+ const formatFlags = {
5389
+ D: function(dateObj) {
5390
+ return dateObj.getDay();
5391
+ },
5392
+ DD: function(dateObj) {
5393
+ return pad(dateObj.getDay());
5394
+ },
5395
+ Do: function(dateObj) {
5396
+ return DoFn(dateObj.getDate());
5397
+ },
5398
+ d: function(dateObj) {
5399
+ return dateObj.getDate();
5400
+ },
5401
+ dd: function(dateObj) {
5402
+ return pad(dateObj.getDate());
5403
+ },
5404
+ ddd: function(dateObj) {
5405
+ return dayNamesShort[dateObj.getDay()];
5406
+ },
5407
+ dddd: function(dateObj) {
5408
+ return dayNames[dateObj.getDay()];
5409
+ },
5410
+ M: function(dateObj) {
5411
+ return dateObj.getMonth() + 1;
5412
+ },
5413
+ MM: function(dateObj) {
5414
+ return pad(dateObj.getMonth() + 1);
5415
+ },
5416
+ MMM: function(dateObj) {
5417
+ return monthNamesShort[dateObj.getMonth()];
5418
+ },
5419
+ MMMM: function(dateObj) {
5420
+ return monthNames[dateObj.getMonth()];
5421
+ },
5422
+ yy: function(dateObj) {
5423
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
5424
+ },
5425
+ yyyy: function(dateObj) {
5426
+ return pad(dateObj.getFullYear(), 4);
5427
+ },
5428
+ h: function(dateObj) {
5429
+ return dateObj.getHours() % 12 || 12;
5430
+ },
5431
+ hh: function(dateObj) {
5432
+ return pad(dateObj.getHours() % 12 || 12);
5433
+ },
5434
+ H: function(dateObj) {
5435
+ return dateObj.getHours();
5436
+ },
5437
+ HH: function(dateObj) {
5438
+ return pad(dateObj.getHours());
5439
+ },
5440
+ m: function(dateObj) {
5441
+ return dateObj.getMinutes();
5442
+ },
5443
+ mm: function(dateObj) {
5444
+ return pad(dateObj.getMinutes());
5445
+ },
5446
+ s: function(dateObj) {
5447
+ return dateObj.getSeconds();
5448
+ },
5449
+ ss: function(dateObj) {
5450
+ return pad(dateObj.getSeconds());
5451
+ },
5452
+ S: function(dateObj) {
5453
+ return Math.round(dateObj.getMilliseconds() / 100);
5454
+ },
5455
+ SS: function(dateObj) {
5456
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
5457
+ },
5458
+ SSS: function(dateObj) {
5459
+ return pad(dateObj.getMilliseconds(), 3);
5460
+ },
5461
+ a: function(dateObj) {
5462
+ return dateObj.getHours() < 12 ? '上午' : '下午';
5463
+ },
5464
+ A: function(dateObj) {
5465
+ return dateObj.getHours() < 12 ? '上午' : '下午';
5466
+ },
5467
+ ZZ: function(dateObj) {
5468
+ const o = dateObj.getTimezoneOffset();
5469
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
5470
+ }
5471
+ };
5472
+
5473
+ const parseFlags = {
5474
+ d: [twoDigits, function (d, v) {
5475
+ d.day = v;
5476
+ }],
5477
+ Do: [twoDigits + word, function (d, v) {
5478
+ d.day = parseInt(v, 10);
5479
+ }],
5480
+ M: [twoDigits, function (d, v) {
5481
+ d.month = v - 1;
5482
+ }],
5483
+ yy: [twoDigits, function (d, v) {
5484
+ const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
5485
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
5486
+ }],
5487
+ h: [twoDigits, function (d, v) {
5488
+ d.hour = v;
5489
+ }],
5490
+ m: [twoDigits, function (d, v) {
5491
+ d.minute = v;
5492
+ }],
5493
+ s: [twoDigits, function (d, v) {
5494
+ d.second = v;
5495
+ }],
5496
+ yyyy: [fourDigits, function (d, v) {
5497
+ d.year = v;
5498
+ }],
5499
+ S: ['\\d', function (d, v) {
5500
+ d.millisecond = v * 100;
5501
+ }],
5502
+ SS: ['\\d{2}', function (d, v) {
5503
+ d.millisecond = v * 10;
5504
+ }],
5505
+ SSS: [threeDigits, function (d, v) {
5506
+ d.millisecond = v;
5507
+ }],
5508
+ D: [twoDigits, noop],
5509
+ ddd: [word, noop],
5510
+ MMM: [word, monthUpdate('monthNamesShort')],
5511
+ MMMM: [word, monthUpdate('monthNames')],
5512
+ a: [word, function (d, v) {
5513
+ const val = v.toLowerCase();
5514
+ if (val === '上午') {
5515
+ d.isPm = false;
5516
+ } else if (val === '下午') {
5517
+ d.isPm = true;
5518
+ }
5519
+ }],
5520
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
5521
+ let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
5522
+
5523
+ if (parts) {
5524
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
5525
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
5526
+ }
5527
+ }]
5528
+ };
5529
+ parseFlags.dd = parseFlags.d;
5530
+ parseFlags.dddd = parseFlags.ddd;
5531
+ parseFlags.DD = parseFlags.D;
5532
+ parseFlags.mm = parseFlags.m;
5533
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
5534
+ parseFlags.MM = parseFlags.M;
5535
+ parseFlags.ss = parseFlags.s;
5536
+ parseFlags.A = parseFlags.a;
5537
+
5538
+
5539
+ // Some common format strings
5540
+ fecha.masks = {
5541
+ default: 'ddd MMM dd yyyy HH:mm:ss',
5542
+ shortDate: 'M/D/yy',
5543
+ mediumDate: 'MMM d, yyyy',
5544
+ longDate: 'MMMM d, yyyy',
5545
+ fullDate: 'dddd, MMMM d, yyyy',
5546
+ shortTime: 'HH:mm',
5547
+ mediumTime: 'HH:mm:ss',
5548
+ longTime: 'HH:mm:ss.SSS'
5549
+ };
5550
+
5525
5551
  /***
5526
5552
  * Format a date
5527
5553
  * @method format
5528
5554
  * @param {Date|number} dateObj
5529
5555
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
5530
- */
5531
- fecha.format = function (dateObj, mask) {
5532
- if (typeof dateObj === 'number') {
5533
- dateObj = new Date(dateObj);
5534
- }
5535
-
5536
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
5537
- throw new Error('Invalid Date in fecha.format');
5538
- }
5539
-
5540
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
5541
-
5542
- var literals = [];
5543
-
5544
- // Make literals inactive by replacing them with ??
5545
- mask = mask.replace(literal, function ($0, $1) {
5546
- literals.push($1);
5547
- return '@@@';
5548
- });
5549
- // Apply formatting rules
5550
- mask = mask.replace(token, function ($0) {
5551
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
5552
- });
5553
- // Inline literal values back into the formatted value
5554
- return mask.replace(/@@@/g, function () {
5555
- return literals.shift();
5556
- });
5557
- };
5558
-
5556
+ */
5557
+ fecha.format = function (dateObj, mask) {
5558
+ if (typeof dateObj === 'number') {
5559
+ dateObj = new Date(dateObj);
5560
+ }
5561
+
5562
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
5563
+ throw new Error('Invalid Date in fecha.format');
5564
+ }
5565
+
5566
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
5567
+
5568
+ const literals = [];
5569
+
5570
+ // Make literals inactive by replacing them with ??
5571
+ mask = mask.replace(literal, function($0, $1) {
5572
+ literals.push($1);
5573
+ return '@@@';
5574
+ });
5575
+ // Apply formatting rules
5576
+ mask = mask.replace(token, function ($0) {
5577
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
5578
+ });
5579
+ // Inline literal values back into the formatted value
5580
+ return mask.replace(/@@@/g, function() {
5581
+ return literals.shift();
5582
+ });
5583
+ };
5584
+
5559
5585
  /**
5560
5586
  * Parse a date string into an object, changes - into /
5561
5587
  * @method parse
5562
5588
  * @param {string} dateStr Date string
5563
5589
  * @param {string} format Date parse format
5564
5590
  * @returns {Date|boolean}
5565
- */
5566
- fecha.parse = function (dateStr, format) {
5567
- if (typeof format !== 'string') {
5568
- throw new Error('Invalid format in fecha.parse');
5569
- }
5570
-
5571
- format = fecha.masks[format] || format;
5572
-
5573
- // Avoid regular expression denial of service, fail early for really long strings
5574
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
5575
- if (dateStr.length > 1000) {
5576
- return null;
5577
- }
5578
-
5579
- var dateInfo = {};
5580
- var parseInfo = [];
5581
- var literals = [];
5582
- format = format.replace(literal, function ($0, $1) {
5583
- literals.push($1);
5584
- return '@@@';
5585
- });
5586
- var newFormat = regexEscape(format).replace(token, function ($0) {
5587
- if (parseFlags[$0]) {
5588
- var info = parseFlags[$0];
5589
- parseInfo.push(info[1]);
5590
- return '(' + info[0] + ')';
5591
- }
5592
-
5593
- return $0;
5594
- });
5595
- newFormat = newFormat.replace(/@@@/g, function () {
5596
- return literals.shift();
5597
- });
5598
- var matches = dateStr.match(new RegExp(newFormat, 'i'));
5599
- if (!matches) {
5600
- return null;
5601
- }
5602
-
5603
- for (var i = 1; i < matches.length; i++) {
5604
- parseInfo[i - 1](dateInfo, matches[i]);
5605
- }
5606
-
5607
- var today = new Date();
5608
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
5609
- dateInfo.hour = +dateInfo.hour + 12;
5610
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
5611
- dateInfo.hour = 0;
5612
- }
5613
-
5614
- var date = void 0;
5615
- if (dateInfo.timezoneOffset != null) {
5616
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
5617
- 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));
5618
- } else {
5619
- 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);
5620
- }
5621
- return date;
5622
- };
5623
-
5624
- // 导出fecha对象
5625
-
5626
-
5627
- // 以下是从date-util.js合并的函数
5628
- var newArray = function newArray(start, end) {
5629
- var result = [];
5630
- for (var i = start; i <= end; i++) {
5631
- result.push(i);
5632
- }
5633
- return result;
5634
- };
5635
-
5636
- var getSettings = function getSettings() {
5637
- return {
5638
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
5639
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
5640
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
5641
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
5642
- amPm: ['上午', '下午']
5643
- };
5644
- };
5645
-
5646
- var toDate = function toDate(date) {
5647
- return isDate(date) ? new Date(date) : null;
5648
- };
5649
-
5650
- var isDate = function isDate(date) {
5651
- if (date === null || date === undefined) return false;
5652
- if (isNaN(new Date(date).getTime())) return false;
5653
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
5654
- return true;
5655
- };
5656
-
5657
- var isDateObject = function isDateObject(val) {
5658
- return val instanceof Date;
5659
- };
5660
-
5661
- var formatDate = function formatDate(date) {
5662
- var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
5663
-
5664
- // 处理多种输入类型
5665
- if (!date) return '';
5666
-
5667
- // 如果是时间戳,转成日期对象
5668
- if (typeof date === 'number') {
5669
- date = new Date(date);
5670
- }
5671
- // 如果是字符串,转成日期对象
5672
- if (typeof date === 'string') {
5673
- date = new Date(date);
5674
- }
5675
-
5676
- // 调用toDate进一步验证和转换
5677
- date = toDate(date);
5678
- if (!date) return '';
5679
-
5680
- // 兼容大写和小写的格式标记
5681
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
5682
- var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
5683
-
5684
- // 使用fecha库进行格式化,支持中文配置
5685
- var str = fecha.format(date, lowercaseFormat, getSettings());
5686
- return str;
5687
- };
5688
-
5689
- var parseDate = function parseDate(string, format) {
5690
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
5691
- };
5692
-
5693
- var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
5694
- if (month === 3 || month === 5 || month === 8 || month === 10) {
5695
- return 30;
5696
- }
5697
-
5698
- if (month === 1) {
5699
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
5700
- return 29;
5701
- } else {
5702
- return 28;
5703
- }
5704
- }
5705
-
5706
- return 31;
5707
- };
5708
-
5709
- var getDayCountOfYear = function getDayCountOfYear(year) {
5710
- var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
5711
- return isLeapYear ? 366 : 365;
5712
- };
5713
-
5714
- var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
5715
- var temp = new Date(date.getTime());
5716
- temp.setDate(1);
5717
- return temp.getDay();
5718
- };
5719
-
5720
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
5721
- // {prev, next} Date should work for Daylight Saving Time
5722
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
5723
- var prevDate = function prevDate(date) {
5724
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5725
-
5726
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
5727
- };
5728
-
5729
- var nextDate = function nextDate(date) {
5730
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5731
-
5732
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
5733
- };
5734
-
5735
- var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
5736
- var result = new Date(year, month, 1);
5737
- var day = result.getDay();
5738
-
5739
- if (day === 0) {
5740
- return prevDate(result, 7);
5741
- } else {
5742
- return prevDate(result, day);
5743
- }
5744
- };
5745
-
5746
- var getWeekNumber = function getWeekNumber(date) {
5747
- // 支持多种输入类型
5748
- if (!date || !isDate(date)) {
5749
- date = new Date();
5750
- }
5751
- if (typeof date === 'string') {
5752
- date = new Date(date);
5753
- }
5754
-
5755
- // 验证日期有效性
5756
- if (!isDate(date)) return null;
5757
-
5758
- var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
5759
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
5760
- // 将星期日的星期数设为7
5761
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
5762
- // 获取当年的第一天
5763
- var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
5764
- // 计算到最近的星期四的完整周数
5765
- var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
5766
- // 返回周数
5767
- return weekNo;
5768
- };
5769
-
5770
- var getRangeHours = function getRangeHours(ranges) {
5771
- var hours = [];
5772
- var disabledHours = [];
5773
-
5774
- (ranges || []).forEach(function (range) {
5775
- var value = range.map(function (date) {
5776
- return date.getHours();
5777
- });
5778
-
5779
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
5780
- });
5781
-
5782
- if (disabledHours.length) {
5783
- for (var i = 0; i < 24; i++) {
5784
- hours[i] = disabledHours.indexOf(i) === -1;
5785
- }
5786
- } else {
5787
- for (var _i = 0; _i < 24; _i++) {
5788
- hours[_i] = false;
5789
- }
5790
- }
5791
-
5792
- return hours;
5793
- };
5794
-
5795
- var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
5796
- if (amount <= 0) return [];
5797
- var temp = new Date(date.getTime());
5798
- temp.setDate(0);
5799
- var lastDay = temp.getDate();
5800
- return range(amount).map(function (_, index) {
5801
- return lastDay - (amount - index - 1);
5802
- });
5803
- };
5804
-
5805
- var getMonthDays = function getMonthDays(date) {
5806
- var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
5807
- var days = temp.getDate();
5808
- return range(days).map(function (_, index) {
5809
- return index + 1;
5810
- });
5811
- };
5812
-
5813
- function setRangeData(arr, start, end, value) {
5814
- for (var i = start; i < end; i++) {
5815
- arr[i] = value;
5816
- }
5817
- }
5818
-
5819
- var getRangeMinutes = function getRangeMinutes(ranges, hour) {
5820
- var minutes = new Array(60);
5821
-
5822
- if (ranges.length > 0) {
5823
- ranges.forEach(function (range) {
5824
- var start = range[0];
5825
- var end = range[1];
5826
- var startHour = start.getHours();
5827
- var startMinute = start.getMinutes();
5828
- var endHour = end.getHours();
5829
- var endMinute = end.getMinutes();
5830
- if (startHour === hour && endHour !== hour) {
5831
- setRangeData(minutes, startMinute, 60, true);
5832
- } else if (startHour === hour && endHour === hour) {
5833
- setRangeData(minutes, startMinute, endMinute + 1, true);
5834
- } else if (startHour !== hour && endHour === hour) {
5835
- setRangeData(minutes, 0, endMinute + 1, true);
5836
- } else if (startHour < hour && endHour > hour) {
5837
- setRangeData(minutes, 0, 60, true);
5838
- }
5839
- });
5840
- } else {
5841
- setRangeData(minutes, 0, 60, true);
5842
- }
5843
- return minutes;
5844
- };
5845
-
5846
- var range = function range(n) {
5847
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
5848
- return Array.apply(null, { length: n }).map(function (_, n) {
5849
- return n;
5850
- });
5851
- };
5852
-
5853
- var modifyDate = function modifyDate(date, y, m, d) {
5854
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
5855
- };
5856
-
5857
- var modifyTime = function modifyTime(date, h, m, s) {
5858
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
5859
- };
5860
-
5861
- var modifyWithTimeString = function modifyWithTimeString(date, time) {
5862
- if (date == null || !time) {
5863
- return date;
5864
- }
5865
- time = parseDate(time, 'HH:mm:ss');
5866
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
5867
- };
5868
-
5869
- var clearTime = function clearTime(date) {
5870
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
5871
- };
5872
-
5873
- var clearMilliseconds = function clearMilliseconds(date) {
5874
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
5875
- };
5876
-
5877
- var limitTimeRange = function limitTimeRange(date, ranges) {
5878
- var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
5879
-
5880
- // TODO: refactory a more elegant solution
5881
- if (ranges.length === 0) return date;
5882
- var normalizeDate = function normalizeDate(date) {
5883
- return fecha.parse(fecha.format(date, format), format);
5884
- };
5885
- var ndate = normalizeDate(date);
5886
- var nranges = ranges.map(function (range) {
5887
- return range.map(normalizeDate);
5888
- });
5889
- if (nranges.some(function (nrange) {
5890
- return ndate >= nrange[0] && ndate <= nrange[1];
5891
- })) return date;
5892
-
5893
- var minDate = nranges[0][0];
5894
- var maxDate = nranges[0][0];
5895
-
5896
- nranges.forEach(function (nrange) {
5897
- minDate = new Date(Math.min(nrange[0], minDate));
5898
- maxDate = new Date(Math.max(nrange[1], minDate));
5899
- });
5900
-
5901
- var ret = ndate < minDate ? minDate : maxDate;
5902
- // preserve Year/Month/Date
5903
- return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
5904
- };
5905
-
5906
- var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
5907
- var limitedDate = limitTimeRange(date, selectableRange, format);
5908
- return limitedDate.getTime() === date.getTime();
5909
- };
5910
-
5911
- var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
5912
- // clamp date to the number of days in `year`, `month`
5913
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
5914
- var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
5915
- return modifyDate(date, year, month, monthDate);
5916
- };
5917
-
5918
- var prevMonth = function prevMonth(date) {
5919
- var year = date.getFullYear();
5920
- var month = date.getMonth();
5921
- return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
5922
- };
5923
-
5924
- var nextMonth = function nextMonth(date) {
5925
- var year = date.getFullYear();
5926
- var month = date.getMonth();
5927
- return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
5928
- };
5929
-
5930
- var prevYear = function prevYear(date) {
5931
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5932
-
5933
- var year = date.getFullYear();
5934
- var month = date.getMonth();
5935
- return changeYearMonthAndClampDate(date, year - amount, month);
5936
- };
5937
-
5938
- var nextYear = function nextYear(date) {
5939
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5940
-
5941
- var year = date.getFullYear();
5942
- var month = date.getMonth();
5943
- return changeYearMonthAndClampDate(date, year + amount, month);
5944
- };
5945
-
5946
- var extractDateFormat = function extractDateFormat(format) {
5947
- return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
5948
- };
5949
-
5950
- var extractTimeFormat = function extractTimeFormat(format) {
5951
- return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
5952
- };
5953
-
5954
- var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
5955
- return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
5956
- };
5957
-
5591
+ */
5592
+ fecha.parse = function (dateStr, format) {
5593
+ if (typeof format !== 'string') {
5594
+ throw new Error('Invalid format in fecha.parse');
5595
+ }
5596
+
5597
+ format = fecha.masks[format] || format;
5598
+
5599
+ // Avoid regular expression denial of service, fail early for really long strings
5600
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
5601
+ if (dateStr.length > 1000) {
5602
+ return null;
5603
+ }
5604
+
5605
+ const dateInfo = {};
5606
+ const parseInfo = [];
5607
+ const literals = [];
5608
+ format = format.replace(literal, function($0, $1) {
5609
+ literals.push($1);
5610
+ return '@@@';
5611
+ });
5612
+ let newFormat = regexEscape(format).replace(token, function ($0) {
5613
+ if (parseFlags[$0]) {
5614
+ const info = parseFlags[$0];
5615
+ parseInfo.push(info[1]);
5616
+ return '(' + info[0] + ')';
5617
+ }
5618
+
5619
+ return $0;
5620
+ });
5621
+ newFormat = newFormat.replace(/@@@/g, function() {
5622
+ return literals.shift();
5623
+ });
5624
+ const matches = dateStr.match(new RegExp(newFormat, 'i'));
5625
+ if (!matches) {
5626
+ return null;
5627
+ }
5628
+
5629
+ for (let i = 1; i < matches.length; i++) {
5630
+ parseInfo[i - 1](dateInfo, matches[i]);
5631
+ }
5632
+
5633
+ const today = new Date();
5634
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
5635
+ dateInfo.hour = +dateInfo.hour + 12;
5636
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
5637
+ dateInfo.hour = 0;
5638
+ }
5639
+
5640
+ let date;
5641
+ if (dateInfo.timezoneOffset != null) {
5642
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
5643
+ date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
5644
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
5645
+ } else {
5646
+ date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
5647
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
5648
+ }
5649
+ return date;
5650
+ };
5651
+
5652
+ // 导出fecha对象
5653
+
5654
+
5655
+ // 以下是从date-util.js合并的函数
5656
+ const newArray = function(start, end) {
5657
+ let result = [];
5658
+ for (let i = start; i <= end; i++) {
5659
+ result.push(i);
5660
+ }
5661
+ return result;
5662
+ };
5663
+
5664
+ const getSettings = () => {
5665
+ return {
5666
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
5667
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
5668
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
5669
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
5670
+ amPm: ['上午', '下午']
5671
+ };
5672
+ };
5673
+
5674
+ const toDate = function(date) {
5675
+ return isDate(date) ? new Date(date) : null;
5676
+ };
5677
+
5678
+ const isDate = function(date) {
5679
+ if (date === null || date === undefined) return false;
5680
+ if (isNaN(new Date(date).getTime())) return false;
5681
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
5682
+ return true;
5683
+ };
5684
+
5685
+ const isDateObject = function(val) {
5686
+ return val instanceof Date;
5687
+ };
5688
+
5689
+ const formatDate = function (date, format = 'yyyy-MM-dd') {
5690
+ // 处理多种输入类型
5691
+ if (!date) return '';
5692
+
5693
+ // 如果是时间戳,转成日期对象
5694
+ if (typeof date === 'number') {
5695
+ date = new Date(date);
5696
+ }
5697
+ // 如果是字符串,转成日期对象
5698
+ if (typeof date === 'string') {
5699
+ date = new Date(date);
5700
+ }
5701
+
5702
+ // 调用toDate进一步验证和转换
5703
+ date = toDate(date);
5704
+ if (!date) return '';
5705
+
5706
+ // 兼容大写和小写的格式标记
5707
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
5708
+ const lowercaseFormat = format
5709
+ .replace(/YYYY/g, 'yyyy')
5710
+ .replace(/D/g, 'd')
5711
+
5712
+ // 使用fecha库进行格式化,支持中文配置
5713
+ const str = fecha.format(date, lowercaseFormat, getSettings());
5714
+ return str;
5715
+ };
5716
+
5717
+ const parseDate = function(string, format) {
5718
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
5719
+ };
5720
+
5721
+ const getDayCountOfMonth = function(year, month) {
5722
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
5723
+ return 30;
5724
+ }
5725
+
5726
+ if (month === 1) {
5727
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
5728
+ return 29;
5729
+ } else {
5730
+ return 28;
5731
+ }
5732
+ }
5733
+
5734
+ return 31;
5735
+ };
5736
+
5737
+ const getDayCountOfYear = function(year) {
5738
+ const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
5739
+ return isLeapYear ? 366 : 365;
5740
+ };
5741
+
5742
+ const getFirstDayOfMonth = function(date) {
5743
+ const temp = new Date(date.getTime());
5744
+ temp.setDate(1);
5745
+ return temp.getDay();
5746
+ };
5747
+
5748
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
5749
+ // {prev, next} Date should work for Daylight Saving Time
5750
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
5751
+ const prevDate = function(date, amount = 1) {
5752
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
5753
+ };
5754
+
5755
+ const nextDate = function(date, amount = 1) {
5756
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
5757
+ };
5758
+
5759
+ const getStartDateOfMonth = function(year, month) {
5760
+ const result = new Date(year, month, 1);
5761
+ const day = result.getDay();
5762
+
5763
+ if (day === 0) {
5764
+ return prevDate(result, 7);
5765
+ } else {
5766
+ return prevDate(result, day);
5767
+ }
5768
+ };
5769
+
5770
+ const getWeekNumber = function(date) {
5771
+ // 支持多种输入类型
5772
+ if (!date||!isDate(date)) {
5773
+ date = new Date();
5774
+ }
5775
+ if (typeof date === 'string') {
5776
+ date = new Date(date);
5777
+ }
5778
+
5779
+ // 验证日期有效性
5780
+ if (!isDate(date)) return null;
5781
+
5782
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
5783
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
5784
+ // 将星期日的星期数设为7
5785
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
5786
+ // 获取当年的第一天
5787
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
5788
+ // 计算到最近的星期四的完整周数
5789
+ const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
5790
+ // 返回周数
5791
+ return weekNo;
5792
+ };
5793
+
5794
+ const getRangeHours = function(ranges) {
5795
+ const hours = [];
5796
+ let disabledHours = [];
5797
+
5798
+ (ranges || []).forEach(range => {
5799
+ const value = range.map(date => date.getHours());
5800
+
5801
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
5802
+ });
5803
+
5804
+ if (disabledHours.length) {
5805
+ for (let i = 0; i < 24; i++) {
5806
+ hours[i] = disabledHours.indexOf(i) === -1;
5807
+ }
5808
+ } else {
5809
+ for (let i = 0; i < 24; i++) {
5810
+ hours[i] = false;
5811
+ }
5812
+ }
5813
+
5814
+ return hours;
5815
+ };
5816
+
5817
+ const getPrevMonthLastDays = (date, amount) => {
5818
+ if (amount <= 0) return [];
5819
+ const temp = new Date(date.getTime());
5820
+ temp.setDate(0);
5821
+ const lastDay = temp.getDate();
5822
+ return range(amount).map((_, index) => lastDay - (amount - index - 1));
5823
+ };
5824
+
5825
+ const getMonthDays = (date) => {
5826
+ const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
5827
+ const days = temp.getDate();
5828
+ return range(days).map((_, index) => index + 1);
5829
+ };
5830
+
5831
+ function setRangeData(arr, start, end, value) {
5832
+ for (let i = start; i < end; i++) {
5833
+ arr[i] = value;
5834
+ }
5835
+ }
5836
+
5837
+ const getRangeMinutes = function(ranges, hour) {
5838
+ const minutes = new Array(60);
5839
+
5840
+ if (ranges.length > 0) {
5841
+ ranges.forEach(range => {
5842
+ const start = range[0];
5843
+ const end = range[1];
5844
+ const startHour = start.getHours();
5845
+ const startMinute = start.getMinutes();
5846
+ const endHour = end.getHours();
5847
+ const endMinute = end.getMinutes();
5848
+ if (startHour === hour && endHour !== hour) {
5849
+ setRangeData(minutes, startMinute, 60, true);
5850
+ } else if (startHour === hour && endHour === hour) {
5851
+ setRangeData(minutes, startMinute, endMinute + 1, true);
5852
+ } else if (startHour !== hour && endHour === hour) {
5853
+ setRangeData(minutes, 0, endMinute + 1, true);
5854
+ } else if (startHour < hour && endHour > hour) {
5855
+ setRangeData(minutes, 0, 60, true);
5856
+ }
5857
+ });
5858
+ } else {
5859
+ setRangeData(minutes, 0, 60, true);
5860
+ }
5861
+ return minutes;
5862
+ };
5863
+
5864
+ const range = function(n) {
5865
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
5866
+ return Array.apply(null, {length: n}).map((_, n) => n);
5867
+ };
5868
+
5869
+ const modifyDate = function(date, y, m, d) {
5870
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
5871
+ };
5872
+
5873
+ const modifyTime = function(date, h, m, s) {
5874
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
5875
+ };
5876
+
5877
+ const modifyWithTimeString = (date, time) => {
5878
+ if (date == null || !time) {
5879
+ return date;
5880
+ }
5881
+ time = parseDate(time, 'HH:mm:ss');
5882
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
5883
+ };
5884
+
5885
+ const clearTime = function(date) {
5886
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
5887
+ };
5888
+
5889
+ const clearMilliseconds = function(date) {
5890
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
5891
+ };
5892
+
5893
+ const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
5894
+ // TODO: refactory a more elegant solution
5895
+ if (ranges.length === 0) return date;
5896
+ const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
5897
+ const ndate = normalizeDate(date);
5898
+ const nranges = ranges.map(range => range.map(normalizeDate));
5899
+ if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
5900
+
5901
+ let minDate = nranges[0][0];
5902
+ let maxDate = nranges[0][0];
5903
+
5904
+ nranges.forEach(nrange => {
5905
+ minDate = new Date(Math.min(nrange[0], minDate));
5906
+ maxDate = new Date(Math.max(nrange[1], minDate));
5907
+ });
5908
+
5909
+ const ret = ndate < minDate ? minDate : maxDate;
5910
+ // preserve Year/Month/Date
5911
+ return modifyDate(
5912
+ ret,
5913
+ date.getFullYear(),
5914
+ date.getMonth(),
5915
+ date.getDate()
5916
+ );
5917
+ };
5918
+
5919
+ const timeWithinRange = function(date, selectableRange, format) {
5920
+ const limitedDate = limitTimeRange(date, selectableRange, format);
5921
+ return limitedDate.getTime() === date.getTime();
5922
+ };
5923
+
5924
+ const changeYearMonthAndClampDate = function(date, year, month) {
5925
+ // clamp date to the number of days in `year`, `month`
5926
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
5927
+ const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
5928
+ return modifyDate(date, year, month, monthDate);
5929
+ };
5930
+
5931
+ const prevMonth = function(date) {
5932
+ const year = date.getFullYear();
5933
+ const month = date.getMonth();
5934
+ return month === 0
5935
+ ? changeYearMonthAndClampDate(date, year - 1, 11)
5936
+ : changeYearMonthAndClampDate(date, year, month - 1);
5937
+ };
5938
+
5939
+ const nextMonth = function(date) {
5940
+ const year = date.getFullYear();
5941
+ const month = date.getMonth();
5942
+ return month === 11
5943
+ ? changeYearMonthAndClampDate(date, year + 1, 0)
5944
+ : changeYearMonthAndClampDate(date, year, month + 1);
5945
+ };
5946
+
5947
+ const prevYear = function(date, amount = 1) {
5948
+ const year = date.getFullYear();
5949
+ const month = date.getMonth();
5950
+ return changeYearMonthAndClampDate(date, year - amount, month);
5951
+ };
5952
+
5953
+ const nextYear = function(date, amount = 1) {
5954
+ const year = date.getFullYear();
5955
+ const month = date.getMonth();
5956
+ return changeYearMonthAndClampDate(date, year + amount, month);
5957
+ };
5958
+
5959
+ const extractDateFormat = function(format) {
5960
+ return format
5961
+ .replace(/\W?m{1,2}|\W?ZZ/g, '')
5962
+ .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
5963
+ .trim();
5964
+ };
5965
+
5966
+ const extractTimeFormat = function(format) {
5967
+ return format
5968
+ .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
5969
+ .trim();
5970
+ };
5971
+
5972
+ const validateRangeInOneMonth = function(start, end) {
5973
+ return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
5974
+ };
5975
+
5958
5976
  /**
5959
5977
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
5960
5978
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
5961
5979
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
5962
5980
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
5963
5981
  * @returns {number} 工作日数量
5964
- */
5965
- var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
5966
- var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
5967
-
5968
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
5969
- throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
5970
- }
5971
-
5972
- var startDateObj = new Date(start_date);
5973
- var endDateObj = new Date(end_date);
5974
-
5975
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
5976
- throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
5977
- }
5978
-
5979
- if (startDateObj > endDateObj) {
5980
- throw new Error('Start date should be earlier than or equal to end date.');
5981
- }
5982
-
5983
- var workdays = 0;
5984
-
5985
- // Iterate through each day in the date range
5986
-
5987
- var _loop = function _loop(currentDate) {
5988
- // Check if the current day is a weekend (Saturday or Sunday)
5989
- var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
5990
-
5991
- // Check if the current day is a holiday
5992
- var isHoliday = holidays.some(function (holiday) {
5993
- var holidayDate = new Date(holiday);
5994
- return currentDate.toDateString() === holidayDate.toDateString();
5995
- });
5996
-
5997
- // If it's a workday (not a weekend or holiday), increment the workdays count
5998
- if (!isWeekend && !isHoliday) {
5999
- workdays++;
6000
- }
6001
- };
6002
-
6003
- for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
6004
- _loop(currentDate);
6005
- }
6006
-
6007
- return workdays;
6008
- };
6009
-
5982
+ */
5983
+ const calculateNetworkDays = function (start_date, end_date, holidays = []) {
5984
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
5985
+ throw new Error(
5986
+ "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
5987
+ );
5988
+ }
5989
+
5990
+ const startDateObj = new Date(start_date);
5991
+ const endDateObj = new Date(end_date);
5992
+
5993
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
5994
+ throw new Error(
5995
+ "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
5996
+ );
5997
+ }
5998
+
5999
+ if (startDateObj > endDateObj) {
6000
+ throw new Error('Start date should be earlier than or equal to end date.');
6001
+ }
6002
+
6003
+ let workdays = 0;
6004
+
6005
+ // Iterate through each day in the date range
6006
+ for (
6007
+ let currentDate = new Date(startDateObj);
6008
+ currentDate <= endDateObj;
6009
+ currentDate.setDate(currentDate.getDate() + 1)
6010
+ ) {
6011
+ // Check if the current day is a weekend (Saturday or Sunday)
6012
+ const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
6013
+
6014
+ // Check if the current day is a holiday
6015
+ const isHoliday = holidays.some((holiday) => {
6016
+ const holidayDate = new Date(holiday);
6017
+ return currentDate.toDateString() === holidayDate.toDateString();
6018
+ });
6019
+
6020
+ // If it's a workday (not a weekend or holiday), increment the workdays count
6021
+ if (!isWeekend && !isHoliday) {
6022
+ workdays++;
6023
+ }
6024
+ }
6025
+
6026
+ return workdays;
6027
+ };
6028
+
6010
6029
  /**
6011
6030
  * 日期加减天数
6012
6031
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
6013
6032
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
6014
6033
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
6015
- */
6016
- var dateAddDays = function dateAddDays(start_date, days) {
6017
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
6018
- 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.");
6019
- }
6020
-
6021
- var startDateObj = new Date(start_date);
6022
- if (isNaN(startDateObj.getTime())) {
6023
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6024
- }
6025
-
6026
- var resultDateObj = new Date(startDateObj);
6027
- resultDateObj.setDate(resultDateObj.getDate() + days);
6028
-
6029
- var resultYear = resultDateObj.getFullYear();
6030
- var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
6031
- var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
6032
-
6033
- return resultYear + '-' + resultMonth + '-' + resultDay;
6034
- };
6035
-
6034
+ */
6035
+ const dateAddDays = function (start_date, days) {
6036
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
6037
+ throw new Error(
6038
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
6039
+ );
6040
+ }
6041
+
6042
+ const startDateObj = new Date(start_date);
6043
+ if (isNaN(startDateObj.getTime())) {
6044
+ throw new Error(
6045
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
6046
+ );
6047
+ }
6048
+
6049
+ const resultDateObj = new Date(startDateObj);
6050
+ resultDateObj.setDate(resultDateObj.getDate() + days);
6051
+
6052
+ const resultYear = resultDateObj.getFullYear();
6053
+ const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
6054
+ const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
6055
+
6056
+ return `${resultYear}-${resultMonth}-${resultDay}`;
6057
+ };
6058
+
6036
6059
  /**
6037
6060
  * 计算两个日期之间的差值
6038
6061
  * @date 2023年12月14日
@@ -6040,180 +6063,182 @@ var dateAddDays = function dateAddDays(start_date, days) {
6040
6063
  * @param {String} end_date - 结束日期字符串
6041
6064
  * @param {String} unit - 单位:year/month/day
6042
6065
  * @returns {Number} 差值
6043
- */
6044
- var dateDiff = function dateDiff(start_date, end_date) {
6045
- var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
6046
-
6047
- // Assuming date strings are in "YYYY-MM-DD" format
6048
- var startDate = new Date(start_date);
6049
- var endDate = new Date(end_date);
6050
-
6051
- // If the date is invalid, return 0
6052
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
6053
- return 0;
6054
- }
6055
-
6056
- if (unit === 'year') {
6057
- return endDate.getFullYear() - startDate.getFullYear();
6058
- } else if (unit === 'month') {
6059
- return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
6060
- } else {
6061
- // Default to day
6062
- var timeDifference = endDate - startDate;
6063
- // Calculate days (86400000 milliseconds per day)
6064
- return Math.floor(timeDifference / 86400000);
6065
- }
6066
- };
6067
-
6066
+ */
6067
+ const dateDiff = function (start_date, end_date, unit = 'day') {
6068
+ // Assuming date strings are in "YYYY-MM-DD" format
6069
+ var startDate = new Date(start_date);
6070
+ var endDate = new Date(end_date);
6071
+
6072
+ // If the date is invalid, return 0
6073
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
6074
+ return 0;
6075
+ }
6076
+
6077
+ if (unit === 'year') {
6078
+ return endDate.getFullYear() - startDate.getFullYear();
6079
+ } else if (unit === 'month') {
6080
+ return (
6081
+ (endDate.getFullYear() - startDate.getFullYear()) * 12 +
6082
+ (endDate.getMonth() - startDate.getMonth())
6083
+ );
6084
+ } else {
6085
+ // Default to day
6086
+ var timeDifference = endDate - startDate;
6087
+ // Calculate days (86400000 milliseconds per day)
6088
+ return Math.floor(timeDifference / 86400000);
6089
+ }
6090
+ };
6091
+
6068
6092
  /**
6069
6093
  * 获取月份中的日期
6070
6094
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
6071
6095
  * @returns {number} 月份中的日期(1-31)
6072
- */
6073
- var dayOfMonth = function dayOfMonth(date) {
6074
- if (typeof date !== 'string') {
6075
- throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6076
- }
6077
-
6078
- var dateObj = new Date(date);
6079
- if (isNaN(dateObj.getTime())) {
6080
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6081
- }
6082
-
6083
- return dateObj.getDate();
6084
- };
6085
-
6096
+ */
6097
+ const dayOfMonth = function (date) {
6098
+ if (typeof date !== 'string') {
6099
+ throw new Error(
6100
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
6101
+ );
6102
+ }
6103
+
6104
+ const dateObj = new Date(date);
6105
+ if (isNaN(dateObj.getTime())) {
6106
+ throw new Error(
6107
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
6108
+ );
6109
+ }
6110
+
6111
+ return dateObj.getDate();
6112
+ };
6113
+
6086
6114
  /**
6087
6115
  * 获取当前日期
6088
6116
  * @date 2022年5月7日
6089
6117
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
6090
6118
  * @returns {string} 当前日期的格式化字符串
6091
- */
6092
- var getCurrentDate = function getCurrentDate() {
6093
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
6094
-
6095
- return formatDate(new Date(), format);
6096
- };
6097
-
6119
+ */
6120
+ const getCurrentDate = function (format = 'YYYY-MM-DD') {
6121
+ return formatDate(new Date(), format);
6122
+ };
6123
+
6098
6124
  /**
6099
6125
  * 获取当前日期时间
6100
6126
  * @date 2022年5月7日
6101
6127
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
6102
6128
  * @returns {string} 当前日期时间的格式化字符串
6103
- */
6104
- var getCurrentDateTime = function getCurrentDateTime() {
6105
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
6106
-
6107
- return formatDate(new Date(), format);
6108
- };
6109
-
6129
+ */
6130
+ const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
6131
+ return formatDate(new Date(), format);
6132
+ };
6133
+
6110
6134
  /**
6111
6135
  * 获取小时
6112
6136
  * @date 2022年5月7日
6113
6137
  * @param {Date|string} [date] - 日期对象或日期字符串
6114
6138
  * @returns {number} 小时数(0-23)
6115
- */
6116
- var getHour = function getHour(date) {
6117
- if (!date) {
6118
- return new Date().getHours();
6119
- }
6120
- if (typeof date === 'string') {
6121
- date = new Date(date);
6122
- }
6123
- return date.getHours();
6124
- };
6125
-
6139
+ */
6140
+ const getHour = function (date) {
6141
+ if (!date) {
6142
+ return new Date().getHours();
6143
+ }
6144
+ if (typeof date === 'string') {
6145
+ date = new Date(date);
6146
+ }
6147
+ return date.getHours();
6148
+ };
6149
+
6126
6150
  /**
6127
6151
  * 获取分钟
6128
6152
  * @date 2022年5月7日
6129
6153
  * @param {Date|string} [date] - 日期对象或日期字符串
6130
6154
  * @returns {number} 分钟数(0-59)
6131
- */
6132
- var getMinute = function getMinute(date) {
6133
- if (!date) {
6134
- return new Date().getMinutes();
6135
- }
6136
- if (typeof date === 'string') {
6137
- date = new Date(date);
6138
- }
6139
- return date.getMinutes();
6140
- };
6141
-
6155
+ */
6156
+ const getMinute = function (date) {
6157
+ if (!date) {
6158
+ return new Date().getMinutes();
6159
+ }
6160
+ if (typeof date === 'string') {
6161
+ date = new Date(date);
6162
+ }
6163
+ return date.getMinutes();
6164
+ };
6165
+
6142
6166
  /**
6143
6167
  * 获取月份
6144
6168
  * @date 2022年5月7日
6145
6169
  * @param {Date|string} [date] - 日期对象或日期字符串
6146
6170
  * @returns {number} 月份数(1-12)
6147
- */
6148
- var getMonth = function getMonth(date) {
6149
- if (!date) {
6150
- return new Date().getMonth() + 1;
6151
- }
6152
- if (typeof date === 'string') {
6153
- date = new Date(date);
6154
- }
6155
- return date.getMonth() + 1;
6156
- };
6157
-
6171
+ */
6172
+ const getMonth = function (date) {
6173
+ if (!date) {
6174
+ return new Date().getMonth() + 1;
6175
+ }
6176
+ if (typeof date === 'string') {
6177
+ date = new Date(date);
6178
+ }
6179
+ return date.getMonth() + 1;
6180
+ };
6181
+
6158
6182
  /**
6159
6183
  * 获取秒
6160
6184
  * @date 2022年5月7日
6161
6185
  * @param {Date|string} [date] - 日期对象或日期字符串
6162
6186
  * @returns {number} 秒数(0-59)
6163
- */
6164
- var getSecond = function getSecond(date) {
6165
- if (!date) {
6166
- return new Date().getSeconds();
6167
- }
6168
- if (typeof date === 'string') {
6169
- date = new Date(date);
6170
- }
6171
- return date.getSeconds();
6172
- };
6173
-
6187
+ */
6188
+ const getSecond = function (date) {
6189
+ if (!date) {
6190
+ return new Date().getSeconds();
6191
+ }
6192
+ if (typeof date === 'string') {
6193
+ date = new Date(date);
6194
+ }
6195
+ return date.getSeconds();
6196
+ };
6197
+
6174
6198
  /**
6175
6199
  * 获取星期几
6176
6200
  * @date 2022年5月7日
6177
6201
  * @param {Date|string} [date] - 日期对象或日期字符串
6178
6202
  * @returns {number} 星期几(0-6,0表示星期日)
6179
- */
6180
- var getWeekday = function getWeekday(date) {
6181
- if (!date) {
6182
- return new Date().getDay();
6183
- }
6184
- if (typeof date === 'string') {
6185
- date = new Date(date);
6186
- }
6187
- return date.getDay();
6188
- };
6189
-
6203
+ */
6204
+ const getWeekday = function (date) {
6205
+ if (!date) {
6206
+ return new Date().getDay();
6207
+ }
6208
+ if (typeof date === 'string') {
6209
+ date = new Date(date);
6210
+ }
6211
+ return date.getDay();
6212
+ };
6213
+
6214
+
6190
6215
  /**
6191
6216
  * @desc 获取上午/下午/晚上
6192
6217
  * @author huangbo
6193
6218
  * @date 2022年5月7日
6194
6219
  * @param {String} [time] - 时间
6195
- **/
6196
- var timeCycle = function timeCycle(time) {
6197
- var hour = 0;
6198
- if (!time) {
6199
- hour = new Date().getHours();
6200
- } else if (typeof time === 'string') {
6201
- // 从时间字符串中提取小时
6202
- var match = time.match(/^(\d{1,2})/);
6203
- if (match) {
6204
- hour = parseInt(match[1], 10);
6205
- }
6206
- } else if (typeof time === 'number') {
6207
- hour = time;
6208
- }
6209
- // 判断时间段
6210
- if (hour >= 5 && hour < 12) {
6211
- return '上午';
6212
- } else if (hour >= 12 && hour < 18) {
6213
- return '下午';
6214
- } else {
6215
- return '晚上';
6216
- }
6220
+ **/
6221
+ const timeCycle = function (time) {
6222
+ let hour = 0;
6223
+ if (!time) {
6224
+ hour = new Date().getHours();
6225
+ } else if (typeof time === 'string') {
6226
+ // 从时间字符串中提取小时
6227
+ const match = time.match(/^(\d{1,2})/);
6228
+ if (match) {
6229
+ hour = parseInt(match[1], 10);
6230
+ }
6231
+ } else if (typeof time === 'number') {
6232
+ hour = time;
6233
+ }
6234
+ // 判断时间段
6235
+ if (hour >= 5 && hour < 12) {
6236
+ return '上午';
6237
+ } else if (hour >= 12 && hour < 18) {
6238
+ return '下午';
6239
+ } else {
6240
+ return '晚上';
6241
+ }
6217
6242
  };
6218
6243
 
6219
6244
  /***/ }),
@@ -6225,7 +6250,7 @@ module.exports = require("eoss/lib/message-box");
6225
6250
 
6226
6251
  /***/ }),
6227
6252
 
6228
- /***/ 80:
6253
+ /***/ 81:
6229
6254
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
6230
6255
 
6231
6256
  "use strict";