eoss 0.1.0-alpha.39 → 0.1.0-alpha.40

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 (233) 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 +837 -862
  83. package/lib/alert.js +2 -2
  84. package/lib/aside.js +2 -2
  85. package/lib/audit-trajectory.js +4 -4
  86. package/lib/autocomplete.js +1813 -1988
  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 +837 -862
  95. package/lib/calendar.js +839 -864
  96. package/lib/card.js +2 -2
  97. package/lib/carousel-item.js +846 -871
  98. package/lib/carousel.js +839 -864
  99. package/lib/cascader-panel.js +852 -877
  100. package/lib/cascader.js +2048 -2223
  101. package/lib/checkbox-button.js +4 -4
  102. package/lib/checkbox-group.js +859 -884
  103. package/lib/checkbox.js +4 -4
  104. package/lib/col.js +2 -2
  105. package/lib/collapse-item.js +1040 -1065
  106. package/lib/collapse.js +1040 -1065
  107. package/lib/color-picker.js +972 -1122
  108. package/lib/container.js +2 -2
  109. package/lib/cron.js +12 -12
  110. package/lib/data-table.js +843 -868
  111. package/lib/date-picker.js +10520 -10695
  112. package/lib/descriptions-item.js +4 -4
  113. package/lib/descriptions.js +4 -4
  114. package/lib/dialog.js +837 -862
  115. package/lib/divider.js +2 -2
  116. package/lib/drawer.js +2 -2
  117. package/lib/dropdown-item.js +4 -4
  118. package/lib/dropdown-menu.js +974 -1124
  119. package/lib/dropdown.js +841 -866
  120. package/lib/email-login.js +837 -862
  121. package/lib/empty.js +2 -2
  122. package/lib/eoss.common.js +4023 -2668
  123. package/lib/flip.js +2 -2
  124. package/lib/flow-group.js +853 -878
  125. package/lib/flow.js +868 -893
  126. package/lib/flows.js +854 -879
  127. package/lib/footer.js +2 -2
  128. package/lib/form-item.js +860 -885
  129. package/lib/form.js +933 -950
  130. package/lib/guide.js +2 -2
  131. package/lib/header.js +2 -2
  132. package/lib/icon.js +837 -862
  133. package/lib/icons.js +2 -2
  134. package/lib/image-viewer.js +837 -862
  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 +839 -864
  140. package/lib/link.js +2 -2
  141. package/lib/loading.js +2 -2
  142. package/lib/login.js +867 -891
  143. package/lib/lowcode-view.js +1843 -1185
  144. package/lib/lowcode.js +3050 -1569
  145. package/lib/main.js +970 -988
  146. package/lib/marquee.js +837 -862
  147. package/lib/menu-item-group.js +15 -15
  148. package/lib/menu-item.js +6 -6
  149. package/lib/menu.js +2227 -2368
  150. package/lib/message-box.js +843 -868
  151. package/lib/message.js +839 -864
  152. package/lib/notification.js +861 -886
  153. package/lib/option-group.js +4 -4
  154. package/lib/option.js +839 -864
  155. package/lib/page-header.js +2 -2
  156. package/lib/pagination.js +839 -864
  157. package/lib/phone-login.js +847 -866
  158. package/lib/popconfirm.js +4 -4
  159. package/lib/popover.js +1831 -2006
  160. package/lib/process-config.js +839 -864
  161. package/lib/process-module.js +846 -871
  162. package/lib/process-rule.js +905 -930
  163. package/lib/progress.js +2 -2
  164. package/lib/qr-code.js +4 -4
  165. package/lib/qrcode-login.js +839 -864
  166. package/lib/radio-button.js +4 -4
  167. package/lib/radio-group.js +850 -875
  168. package/lib/radio.js +4 -4
  169. package/lib/rate.js +837 -862
  170. package/lib/retrial-auth.js +837 -862
  171. package/lib/row.js +2 -2
  172. package/lib/scrollbar.js +839 -864
  173. package/lib/select.js +2139 -2314
  174. package/lib/selector-panel.js +940 -965
  175. package/lib/selector.js +852 -877
  176. package/lib/slider.js +4 -4
  177. package/lib/step.js +32 -32
  178. package/lib/steps.js +874 -899
  179. package/lib/submenu.js +1269 -1385
  180. package/lib/switch.js +839 -864
  181. package/lib/tab-pane.js +4 -4
  182. package/lib/table-column.js +840 -865
  183. package/lib/table.js +1825 -2000
  184. package/lib/tabs.js +846 -871
  185. package/lib/tag.js +2 -2
  186. package/lib/theme-chalk/fonts/iconfont.ttf +0 -0
  187. package/lib/theme-chalk/fonts/iconfont.woff +0 -0
  188. package/lib/theme-chalk/index.css +1 -1
  189. package/lib/theme-chalk/lowcode.css +1 -1
  190. package/lib/time-picker.js +6471 -6646
  191. package/lib/time-select.js +5039 -5214
  192. package/lib/timeline-item.js +2 -2
  193. package/lib/timeline.js +2 -2
  194. package/lib/tips.js +837 -862
  195. package/lib/toolbar.js +4 -4
  196. package/lib/tooltip.js +1813 -1988
  197. package/lib/transfer.js +837 -862
  198. package/lib/tree-group.js +853 -878
  199. package/lib/tree.js +1026 -1051
  200. package/lib/update-history.js +4 -4
  201. package/lib/upload.js +859 -884
  202. package/lib/wujie.js +841 -866
  203. package/package.json +1 -1
  204. package/packages/flow-group/src/main.vue +2 -2
  205. package/packages/form/src/form-item-render.vue +1 -0
  206. package/packages/form/src/form-item.vue +12 -6
  207. package/packages/form/src/form.vue +5 -5
  208. package/packages/login/src/login.vue +1 -0
  209. package/packages/lowcode/src/attribute/function.vue +28 -9
  210. package/packages/lowcode/src/attribute/props.vue +202 -0
  211. package/packages/lowcode/src/attribute/styles.vue +79 -5
  212. package/packages/lowcode/src/attribute.vue +61 -4
  213. package/packages/lowcode/src/canvas.vue +159 -2
  214. package/packages/lowcode/src/form-render.vue +305 -0
  215. package/packages/lowcode/src/lowcode.vue +33 -13
  216. package/packages/lowcode/src/modules.vue +53 -37
  217. package/packages/lowcode/src/render.vue +80 -25
  218. package/packages/lowcode/src/util/components.js +100 -0
  219. package/packages/lowcode/src/util/props-util.js +67 -0
  220. package/packages/lowcode/src/util/source-generator.js +69 -9
  221. package/packages/lowcode/src/util/source-parser.js +64 -10
  222. package/packages/lowcode-view/src/render.vue +48 -18
  223. package/packages/main/src/components/userinfo.vue +0 -1
  224. package/packages/menu/src/menu-item-group.vue +1 -1
  225. package/packages/menu/src/mixins.js +8 -4
  226. package/packages/menu/src/submenu.vue +35 -5
  227. package/packages/phone-login/src/phone-login.vue +5 -2
  228. package/packages/theme-chalk/dist/fonts/iconfont.ttf +0 -0
  229. package/packages/theme-chalk/dist/fonts/iconfont.woff +0 -0
  230. package/packages/theme-chalk/src/fonts/iconfont.ttf +0 -0
  231. package/packages/theme-chalk/src/fonts/iconfont.woff +0 -0
  232. package/packages/theme-chalk/src/lowcode.scss +21 -2
  233. package/src/index.js +336 -336
@@ -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 = 215);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -3755,7 +3755,7 @@ module.exports = require("vue");
3755
3755
 
3756
3756
  /***/ }),
3757
3757
 
3758
- /***/ 208:
3758
+ /***/ 215:
3759
3759
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3760
3760
 
3761
3761
  "use strict";
@@ -4199,7 +4199,7 @@ var button_default = /*#__PURE__*/__webpack_require__.n(button_);
4199
4199
  var dom = __webpack_require__(5);
4200
4200
 
4201
4201
  // EXTERNAL MODULE: ./src/utils/aria-utils.js
4202
- var aria_utils = __webpack_require__(61);
4202
+ var aria_utils = __webpack_require__(62);
4203
4203
 
4204
4204
  // CONCATENATED MODULE: ./src/utils/aria-dialog.js
4205
4205
  var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
@@ -4299,7 +4299,7 @@ aria.Dialog.prototype.trapFocus = function (event) {
4299
4299
 
4300
4300
  /* harmony default export */ var aria_dialog = (aria.Dialog);
4301
4301
  // EXTERNAL MODULE: external "eoss/lib/option"
4302
- var option_ = __webpack_require__(51);
4302
+ var option_ = __webpack_require__(52);
4303
4303
  var option_default = /*#__PURE__*/__webpack_require__.n(option_);
4304
4304
 
4305
4305
  // EXTERNAL MODULE: external "eoss/lib/select"
@@ -4849,7 +4849,7 @@ var component = Object(componentNormalizer["a" /* default */])(
4849
4849
  var merge = __webpack_require__(22);
4850
4850
 
4851
4851
  // EXTERNAL MODULE: ./src/utils/vdom.js
4852
- var vdom = __webpack_require__(94);
4852
+ var vdom = __webpack_require__(96);
4853
4853
 
4854
4854
  // CONCATENATED MODULE: ./packages/message-box/src/main.js
4855
4855
  var main_typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
@@ -6065,14 +6065,14 @@ function insertAfter(newEl, targetEl) {
6065
6065
 
6066
6066
  /***/ }),
6067
6067
 
6068
- /***/ 51:
6068
+ /***/ 52:
6069
6069
  /***/ (function(module, exports) {
6070
6070
 
6071
6071
  module.exports = require("eoss/lib/option");
6072
6072
 
6073
6073
  /***/ }),
6074
6074
 
6075
- /***/ 61:
6075
+ /***/ 62:
6076
6076
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
6077
6077
 
6078
6078
  "use strict";
@@ -6252,759 +6252,736 @@ aria.Utils.keys = {
6252
6252
  /* unused harmony export getSecond */
6253
6253
  /* unused harmony export getWeekday */
6254
6254
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
6255
- /* Modified from https://github.com/taylorhakes/fecha
6256
- *
6257
- * The MIT License (MIT)
6258
- *
6259
- * Copyright (c) 2015 Taylor Hakes
6260
- *
6261
- * Permission is hereby granted, free of charge, to any person obtaining a copy
6262
- * of this software and associated documentation files (the "Software"), to deal
6263
- * in the Software without restriction, including without limitation the rights
6264
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6265
- * copies of the Software, and to permit persons to whom the Software is
6266
- * furnished to do so, subject to the following conditions:
6267
- *
6268
- * The above copyright notice and this permission notice shall be included in all
6269
- * copies or substantial portions of the Software.
6270
- *
6271
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6272
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6273
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6274
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6275
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
6276
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
6277
- * SOFTWARE.
6278
- */
6279
-
6280
- /*eslint-disable*/
6281
- // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
6282
-
6283
-
6255
+
6256
+
6284
6257
  /**
6285
6258
  * Parse or format dates
6286
6259
  * @class fecha
6287
- */
6288
- const fecha = {};
6289
- const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
6290
- const twoDigits = '\\d\\d?';
6291
- const threeDigits = '\\d{3}';
6292
- const fourDigits = '\\d{4}';
6293
- const word = '[^\\s]+';
6294
- const literal = /\[([^]*?)\]/gm;
6295
- const noop = function () {};
6296
-
6297
- function regexEscape(str) {
6298
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
6299
- }
6300
-
6301
- function shorten(arr, sLen) {
6302
- const newArr = [];
6303
- for (let i = 0, len = arr.length; i < len; i++) {
6304
- newArr.push(arr[i].substr(0, sLen));
6305
- }
6306
- return newArr;
6307
- }
6308
-
6309
- function monthUpdate() {
6310
- return function (d, v) {
6311
- const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
6312
- if (~index) {
6313
- d.month = index;
6314
- }
6315
- };
6316
- }
6317
-
6318
- function pad(val, len) {
6319
- val = String(val);
6320
- len = len || 2;
6321
- while (val.length < len) {
6322
- val = '0' + val;
6323
- }
6324
- return val;
6325
- }
6326
-
6327
- // 直接使用中文日期名称常量
6328
- const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
6329
- const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
6330
- const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
6331
- const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
6332
- const amPm = ['上午', '下午'];
6333
- const DoFn = function DoFn(D) {
6334
- return D + '日';
6335
- };
6336
-
6337
- const formatFlags = {
6338
- D: function(dateObj) {
6339
- return dateObj.getDay();
6340
- },
6341
- DD: function(dateObj) {
6342
- return pad(dateObj.getDay());
6343
- },
6344
- Do: function(dateObj) {
6345
- return DoFn(dateObj.getDate());
6346
- },
6347
- d: function(dateObj) {
6348
- return dateObj.getDate();
6349
- },
6350
- dd: function(dateObj) {
6351
- return pad(dateObj.getDate());
6352
- },
6353
- ddd: function(dateObj) {
6354
- return dayNamesShort[dateObj.getDay()];
6355
- },
6356
- dddd: function(dateObj) {
6357
- return dayNames[dateObj.getDay()];
6358
- },
6359
- M: function(dateObj) {
6360
- return dateObj.getMonth() + 1;
6361
- },
6362
- MM: function(dateObj) {
6363
- return pad(dateObj.getMonth() + 1);
6364
- },
6365
- MMM: function(dateObj) {
6366
- return monthNamesShort[dateObj.getMonth()];
6367
- },
6368
- MMMM: function(dateObj) {
6369
- return monthNames[dateObj.getMonth()];
6370
- },
6371
- yy: function(dateObj) {
6372
- return pad(String(dateObj.getFullYear()), 4).substr(2);
6373
- },
6374
- yyyy: function(dateObj) {
6375
- return pad(dateObj.getFullYear(), 4);
6376
- },
6377
- h: function(dateObj) {
6378
- return dateObj.getHours() % 12 || 12;
6379
- },
6380
- hh: function(dateObj) {
6381
- return pad(dateObj.getHours() % 12 || 12);
6382
- },
6383
- H: function(dateObj) {
6384
- return dateObj.getHours();
6385
- },
6386
- HH: function(dateObj) {
6387
- return pad(dateObj.getHours());
6388
- },
6389
- m: function(dateObj) {
6390
- return dateObj.getMinutes();
6391
- },
6392
- mm: function(dateObj) {
6393
- return pad(dateObj.getMinutes());
6394
- },
6395
- s: function(dateObj) {
6396
- return dateObj.getSeconds();
6397
- },
6398
- ss: function(dateObj) {
6399
- return pad(dateObj.getSeconds());
6400
- },
6401
- S: function(dateObj) {
6402
- return Math.round(dateObj.getMilliseconds() / 100);
6403
- },
6404
- SS: function(dateObj) {
6405
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
6406
- },
6407
- SSS: function(dateObj) {
6408
- return pad(dateObj.getMilliseconds(), 3);
6409
- },
6410
- a: function(dateObj) {
6411
- return dateObj.getHours() < 12 ? '上午' : '下午';
6412
- },
6413
- A: function(dateObj) {
6414
- return dateObj.getHours() < 12 ? '上午' : '下午';
6415
- },
6416
- ZZ: function(dateObj) {
6417
- const o = dateObj.getTimezoneOffset();
6418
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
6419
- }
6420
- };
6421
-
6422
- const parseFlags = {
6423
- d: [twoDigits, function (d, v) {
6424
- d.day = v;
6425
- }],
6426
- Do: [twoDigits + word, function (d, v) {
6427
- d.day = parseInt(v, 10);
6428
- }],
6429
- M: [twoDigits, function (d, v) {
6430
- d.month = v - 1;
6431
- }],
6432
- yy: [twoDigits, function (d, v) {
6433
- const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
6434
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
6435
- }],
6436
- h: [twoDigits, function (d, v) {
6437
- d.hour = v;
6438
- }],
6439
- m: [twoDigits, function (d, v) {
6440
- d.minute = v;
6441
- }],
6442
- s: [twoDigits, function (d, v) {
6443
- d.second = v;
6444
- }],
6445
- yyyy: [fourDigits, function (d, v) {
6446
- d.year = v;
6447
- }],
6448
- S: ['\\d', function (d, v) {
6449
- d.millisecond = v * 100;
6450
- }],
6451
- SS: ['\\d{2}', function (d, v) {
6452
- d.millisecond = v * 10;
6453
- }],
6454
- SSS: [threeDigits, function (d, v) {
6455
- d.millisecond = v;
6456
- }],
6457
- D: [twoDigits, noop],
6458
- ddd: [word, noop],
6459
- MMM: [word, monthUpdate('monthNamesShort')],
6460
- MMMM: [word, monthUpdate('monthNames')],
6461
- a: [word, function (d, v) {
6462
- const val = v.toLowerCase();
6463
- if (val === '上午') {
6464
- d.isPm = false;
6465
- } else if (val === '下午') {
6466
- d.isPm = true;
6467
- }
6468
- }],
6469
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
6470
- let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
6471
-
6472
- if (parts) {
6473
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
6474
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
6475
- }
6476
- }]
6477
- };
6478
- parseFlags.dd = parseFlags.d;
6479
- parseFlags.dddd = parseFlags.ddd;
6480
- parseFlags.DD = parseFlags.D;
6481
- parseFlags.mm = parseFlags.m;
6482
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
6483
- parseFlags.MM = parseFlags.M;
6484
- parseFlags.ss = parseFlags.s;
6485
- parseFlags.A = parseFlags.a;
6486
-
6487
-
6488
- // Some common format strings
6489
- fecha.masks = {
6490
- default: 'ddd MMM dd yyyy HH:mm:ss',
6491
- shortDate: 'M/D/yy',
6492
- mediumDate: 'MMM d, yyyy',
6493
- longDate: 'MMMM d, yyyy',
6494
- fullDate: 'dddd, MMMM d, yyyy',
6495
- shortTime: 'HH:mm',
6496
- mediumTime: 'HH:mm:ss',
6497
- longTime: 'HH:mm:ss.SSS'
6498
- };
6499
-
6260
+ */
6261
+ var fecha = {};
6262
+ var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
6263
+ var twoDigits = '\\d\\d?';
6264
+ var threeDigits = '\\d{3}';
6265
+ var fourDigits = '\\d{4}';
6266
+ var word = '[^\\s]+';
6267
+ var literal = /\[([^]*?)\]/gm;
6268
+ var noop = function noop() {};
6269
+
6270
+ function regexEscape(str) {
6271
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
6272
+ }
6273
+
6274
+ function shorten(arr, sLen) {
6275
+ var newArr = [];
6276
+ for (var i = 0, len = arr.length; i < len; i++) {
6277
+ newArr.push(arr[i].substr(0, sLen));
6278
+ }
6279
+ return newArr;
6280
+ }
6281
+
6282
+ function monthUpdate() {
6283
+ return function (d, v) {
6284
+ var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
6285
+ if (~index) {
6286
+ d.month = index;
6287
+ }
6288
+ };
6289
+ }
6290
+
6291
+ function pad(val, len) {
6292
+ val = String(val);
6293
+ len = len || 2;
6294
+ while (val.length < len) {
6295
+ val = '0' + val;
6296
+ }
6297
+ return val;
6298
+ }
6299
+
6300
+ // 直接使用中文日期名称常量
6301
+ var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
6302
+ var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
6303
+ var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
6304
+ var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
6305
+ var amPm = ['上午', '下午'];
6306
+ var DoFn = function DoFn(D) {
6307
+ return D + '日';
6308
+ };
6309
+
6310
+ var formatFlags = {
6311
+ D: function D(dateObj) {
6312
+ return dateObj.getDay();
6313
+ },
6314
+ DD: function DD(dateObj) {
6315
+ return pad(dateObj.getDay());
6316
+ },
6317
+ Do: function Do(dateObj) {
6318
+ return DoFn(dateObj.getDate());
6319
+ },
6320
+ d: function d(dateObj) {
6321
+ return dateObj.getDate();
6322
+ },
6323
+ dd: function dd(dateObj) {
6324
+ return pad(dateObj.getDate());
6325
+ },
6326
+ ddd: function ddd(dateObj) {
6327
+ return dayNamesShort[dateObj.getDay()];
6328
+ },
6329
+ dddd: function dddd(dateObj) {
6330
+ return dayNames[dateObj.getDay()];
6331
+ },
6332
+ M: function M(dateObj) {
6333
+ return dateObj.getMonth() + 1;
6334
+ },
6335
+ MM: function MM(dateObj) {
6336
+ return pad(dateObj.getMonth() + 1);
6337
+ },
6338
+ MMM: function MMM(dateObj) {
6339
+ return monthNamesShort[dateObj.getMonth()];
6340
+ },
6341
+ MMMM: function MMMM(dateObj) {
6342
+ return monthNames[dateObj.getMonth()];
6343
+ },
6344
+ yy: function yy(dateObj) {
6345
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
6346
+ },
6347
+ yyyy: function yyyy(dateObj) {
6348
+ return pad(dateObj.getFullYear(), 4);
6349
+ },
6350
+ h: function h(dateObj) {
6351
+ return dateObj.getHours() % 12 || 12;
6352
+ },
6353
+ hh: function hh(dateObj) {
6354
+ return pad(dateObj.getHours() % 12 || 12);
6355
+ },
6356
+ H: function H(dateObj) {
6357
+ return dateObj.getHours();
6358
+ },
6359
+ HH: function HH(dateObj) {
6360
+ return pad(dateObj.getHours());
6361
+ },
6362
+ m: function m(dateObj) {
6363
+ return dateObj.getMinutes();
6364
+ },
6365
+ mm: function mm(dateObj) {
6366
+ return pad(dateObj.getMinutes());
6367
+ },
6368
+ s: function s(dateObj) {
6369
+ return dateObj.getSeconds();
6370
+ },
6371
+ ss: function ss(dateObj) {
6372
+ return pad(dateObj.getSeconds());
6373
+ },
6374
+ S: function S(dateObj) {
6375
+ return Math.round(dateObj.getMilliseconds() / 100);
6376
+ },
6377
+ SS: function SS(dateObj) {
6378
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
6379
+ },
6380
+ SSS: function SSS(dateObj) {
6381
+ return pad(dateObj.getMilliseconds(), 3);
6382
+ },
6383
+ a: function a(dateObj) {
6384
+ return dateObj.getHours() < 12 ? '上午' : '下午';
6385
+ },
6386
+ A: function A(dateObj) {
6387
+ return dateObj.getHours() < 12 ? '上午' : '下午';
6388
+ },
6389
+ ZZ: function ZZ(dateObj) {
6390
+ var o = dateObj.getTimezoneOffset();
6391
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
6392
+ }
6393
+ };
6394
+
6395
+ var parseFlags = {
6396
+ d: [twoDigits, function (d, v) {
6397
+ d.day = v;
6398
+ }],
6399
+ Do: [twoDigits + word, function (d, v) {
6400
+ d.day = parseInt(v, 10);
6401
+ }],
6402
+ M: [twoDigits, function (d, v) {
6403
+ d.month = v - 1;
6404
+ }],
6405
+ yy: [twoDigits, function (d, v) {
6406
+ var da = new Date(),
6407
+ cent = +('' + da.getFullYear()).substr(0, 2);
6408
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
6409
+ }],
6410
+ h: [twoDigits, function (d, v) {
6411
+ d.hour = v;
6412
+ }],
6413
+ m: [twoDigits, function (d, v) {
6414
+ d.minute = v;
6415
+ }],
6416
+ s: [twoDigits, function (d, v) {
6417
+ d.second = v;
6418
+ }],
6419
+ yyyy: [fourDigits, function (d, v) {
6420
+ d.year = v;
6421
+ }],
6422
+ S: ['\\d', function (d, v) {
6423
+ d.millisecond = v * 100;
6424
+ }],
6425
+ SS: ['\\d{2}', function (d, v) {
6426
+ d.millisecond = v * 10;
6427
+ }],
6428
+ SSS: [threeDigits, function (d, v) {
6429
+ d.millisecond = v;
6430
+ }],
6431
+ D: [twoDigits, noop],
6432
+ ddd: [word, noop],
6433
+ MMM: [word, monthUpdate('monthNamesShort')],
6434
+ MMMM: [word, monthUpdate('monthNames')],
6435
+ a: [word, function (d, v) {
6436
+ var val = v.toLowerCase();
6437
+ if (val === '上午') {
6438
+ d.isPm = false;
6439
+ } else if (val === '下午') {
6440
+ d.isPm = true;
6441
+ }
6442
+ }],
6443
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
6444
+ var parts = (v + '').match(/([+-]|\d\d)/gi),
6445
+ minutes = void 0;
6446
+
6447
+ if (parts) {
6448
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
6449
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
6450
+ }
6451
+ }]
6452
+ };
6453
+ parseFlags.dd = parseFlags.d;
6454
+ parseFlags.dddd = parseFlags.ddd;
6455
+ parseFlags.DD = parseFlags.D;
6456
+ parseFlags.mm = parseFlags.m;
6457
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
6458
+ parseFlags.MM = parseFlags.M;
6459
+ parseFlags.ss = parseFlags.s;
6460
+ parseFlags.A = parseFlags.a;
6461
+
6462
+ // Some common format strings
6463
+ fecha.masks = {
6464
+ default: 'ddd MMM dd yyyy HH:mm:ss',
6465
+ shortDate: 'M/D/yy',
6466
+ mediumDate: 'MMM d, yyyy',
6467
+ longDate: 'MMMM d, yyyy',
6468
+ fullDate: 'dddd, MMMM d, yyyy',
6469
+ shortTime: 'HH:mm',
6470
+ mediumTime: 'HH:mm:ss',
6471
+ longTime: 'HH:mm:ss.SSS'
6472
+ };
6473
+
6500
6474
  /***
6501
6475
  * Format a date
6502
6476
  * @method format
6503
6477
  * @param {Date|number} dateObj
6504
6478
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
6505
- */
6506
- fecha.format = function (dateObj, mask) {
6507
- if (typeof dateObj === 'number') {
6508
- dateObj = new Date(dateObj);
6509
- }
6510
-
6511
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
6512
- throw new Error('Invalid Date in fecha.format');
6513
- }
6514
-
6515
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
6516
-
6517
- const literals = [];
6518
-
6519
- // Make literals inactive by replacing them with ??
6520
- mask = mask.replace(literal, function($0, $1) {
6521
- literals.push($1);
6522
- return '@@@';
6523
- });
6524
- // Apply formatting rules
6525
- mask = mask.replace(token, function ($0) {
6526
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
6527
- });
6528
- // Inline literal values back into the formatted value
6529
- return mask.replace(/@@@/g, function() {
6530
- return literals.shift();
6531
- });
6532
- };
6533
-
6479
+ */
6480
+ fecha.format = function (dateObj, mask) {
6481
+ if (typeof dateObj === 'number') {
6482
+ dateObj = new Date(dateObj);
6483
+ }
6484
+
6485
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
6486
+ throw new Error('Invalid Date in fecha.format');
6487
+ }
6488
+
6489
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
6490
+
6491
+ var literals = [];
6492
+
6493
+ // Make literals inactive by replacing them with ??
6494
+ mask = mask.replace(literal, function ($0, $1) {
6495
+ literals.push($1);
6496
+ return '@@@';
6497
+ });
6498
+ // Apply formatting rules
6499
+ mask = mask.replace(token, function ($0) {
6500
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
6501
+ });
6502
+ // Inline literal values back into the formatted value
6503
+ return mask.replace(/@@@/g, function () {
6504
+ return literals.shift();
6505
+ });
6506
+ };
6507
+
6534
6508
  /**
6535
6509
  * Parse a date string into an object, changes - into /
6536
6510
  * @method parse
6537
6511
  * @param {string} dateStr Date string
6538
6512
  * @param {string} format Date parse format
6539
6513
  * @returns {Date|boolean}
6540
- */
6541
- fecha.parse = function (dateStr, format) {
6542
- if (typeof format !== 'string') {
6543
- throw new Error('Invalid format in fecha.parse');
6544
- }
6545
-
6546
- format = fecha.masks[format] || format;
6547
-
6548
- // Avoid regular expression denial of service, fail early for really long strings
6549
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
6550
- if (dateStr.length > 1000) {
6551
- return null;
6552
- }
6553
-
6554
- const dateInfo = {};
6555
- const parseInfo = [];
6556
- const literals = [];
6557
- format = format.replace(literal, function($0, $1) {
6558
- literals.push($1);
6559
- return '@@@';
6560
- });
6561
- let newFormat = regexEscape(format).replace(token, function ($0) {
6562
- if (parseFlags[$0]) {
6563
- const info = parseFlags[$0];
6564
- parseInfo.push(info[1]);
6565
- return '(' + info[0] + ')';
6566
- }
6567
-
6568
- return $0;
6569
- });
6570
- newFormat = newFormat.replace(/@@@/g, function() {
6571
- return literals.shift();
6572
- });
6573
- const matches = dateStr.match(new RegExp(newFormat, 'i'));
6574
- if (!matches) {
6575
- return null;
6576
- }
6577
-
6578
- for (let i = 1; i < matches.length; i++) {
6579
- parseInfo[i - 1](dateInfo, matches[i]);
6580
- }
6581
-
6582
- const today = new Date();
6583
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
6584
- dateInfo.hour = +dateInfo.hour + 12;
6585
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
6586
- dateInfo.hour = 0;
6587
- }
6588
-
6589
- let date;
6590
- if (dateInfo.timezoneOffset != null) {
6591
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
6592
- date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
6593
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
6594
- } else {
6595
- date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
6596
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
6597
- }
6598
- return date;
6599
- };
6600
-
6601
- // 导出fecha对象
6602
-
6603
-
6604
- // 以下是从date-util.js合并的函数
6605
- const newArray = function(start, end) {
6606
- let result = [];
6607
- for (let i = start; i <= end; i++) {
6608
- result.push(i);
6609
- }
6610
- return result;
6611
- };
6612
-
6613
- const getSettings = () => {
6614
- return {
6615
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
6616
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
6617
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
6618
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
6619
- amPm: ['上午', '下午']
6620
- };
6621
- };
6622
-
6623
- const toDate = function(date) {
6624
- return isDate(date) ? new Date(date) : null;
6625
- };
6626
-
6627
- const isDate = function(date) {
6628
- if (date === null || date === undefined) return false;
6629
- if (isNaN(new Date(date).getTime())) return false;
6630
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
6631
- return true;
6632
- };
6633
-
6634
- const isDateObject = function(val) {
6635
- return val instanceof Date;
6636
- };
6637
-
6638
- const formatDate = function (date, format = 'yyyy-MM-dd') {
6639
- // 处理多种输入类型
6640
- if (!date) return '';
6641
-
6642
- // 如果是时间戳,转成日期对象
6643
- if (typeof date === 'number') {
6644
- date = new Date(date);
6645
- }
6646
- // 如果是字符串,转成日期对象
6647
- if (typeof date === 'string') {
6648
- date = new Date(date);
6649
- }
6650
-
6651
- // 调用toDate进一步验证和转换
6652
- date = toDate(date);
6653
- if (!date) return '';
6654
-
6655
- // 兼容大写和小写的格式标记
6656
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
6657
- const lowercaseFormat = format
6658
- .replace(/YYYY/g, 'yyyy')
6659
- .replace(/D/g, 'd')
6660
-
6661
- // 使用fecha库进行格式化,支持中文配置
6662
- const str = fecha.format(date, lowercaseFormat, getSettings());
6663
- return str;
6664
- };
6665
-
6666
- const parseDate = function(string, format) {
6667
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
6668
- };
6669
-
6670
- const getDayCountOfMonth = function(year, month) {
6671
- if (month === 3 || month === 5 || month === 8 || month === 10) {
6672
- return 30;
6673
- }
6674
-
6675
- if (month === 1) {
6676
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
6677
- return 29;
6678
- } else {
6679
- return 28;
6680
- }
6681
- }
6682
-
6683
- return 31;
6684
- };
6685
-
6686
- const getDayCountOfYear = function(year) {
6687
- const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
6688
- return isLeapYear ? 366 : 365;
6689
- };
6690
-
6691
- const getFirstDayOfMonth = function(date) {
6692
- const temp = new Date(date.getTime());
6693
- temp.setDate(1);
6694
- return temp.getDay();
6695
- };
6696
-
6697
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
6698
- // {prev, next} Date should work for Daylight Saving Time
6699
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
6700
- const prevDate = function(date, amount = 1) {
6701
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
6702
- };
6703
-
6704
- const nextDate = function(date, amount = 1) {
6705
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
6706
- };
6707
-
6708
- const getStartDateOfMonth = function(year, month) {
6709
- const result = new Date(year, month, 1);
6710
- const day = result.getDay();
6711
-
6712
- if (day === 0) {
6713
- return prevDate(result, 7);
6714
- } else {
6715
- return prevDate(result, day);
6716
- }
6717
- };
6718
-
6719
- const getWeekNumber = function(date) {
6720
- // 支持多种输入类型
6721
- if (!date||!isDate(date)) {
6722
- date = new Date();
6723
- }
6724
- if (typeof date === 'string') {
6725
- date = new Date(date);
6726
- }
6727
-
6728
- // 验证日期有效性
6729
- if (!isDate(date)) return null;
6730
-
6731
- const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
6732
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
6733
- // 将星期日的星期数设为7
6734
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
6735
- // 获取当年的第一天
6736
- const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
6737
- // 计算到最近的星期四的完整周数
6738
- const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
6739
- // 返回周数
6740
- return weekNo;
6741
- };
6742
-
6743
- const getRangeHours = function(ranges) {
6744
- const hours = [];
6745
- let disabledHours = [];
6746
-
6747
- (ranges || []).forEach(range => {
6748
- const value = range.map(date => date.getHours());
6749
-
6750
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
6751
- });
6752
-
6753
- if (disabledHours.length) {
6754
- for (let i = 0; i < 24; i++) {
6755
- hours[i] = disabledHours.indexOf(i) === -1;
6756
- }
6757
- } else {
6758
- for (let i = 0; i < 24; i++) {
6759
- hours[i] = false;
6760
- }
6761
- }
6762
-
6763
- return hours;
6764
- };
6765
-
6766
- const getPrevMonthLastDays = (date, amount) => {
6767
- if (amount <= 0) return [];
6768
- const temp = new Date(date.getTime());
6769
- temp.setDate(0);
6770
- const lastDay = temp.getDate();
6771
- return range(amount).map((_, index) => lastDay - (amount - index - 1));
6772
- };
6773
-
6774
- const getMonthDays = (date) => {
6775
- const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
6776
- const days = temp.getDate();
6777
- return range(days).map((_, index) => index + 1);
6778
- };
6779
-
6780
- function setRangeData(arr, start, end, value) {
6781
- for (let i = start; i < end; i++) {
6782
- arr[i] = value;
6783
- }
6784
- }
6785
-
6786
- const getRangeMinutes = function(ranges, hour) {
6787
- const minutes = new Array(60);
6788
-
6789
- if (ranges.length > 0) {
6790
- ranges.forEach(range => {
6791
- const start = range[0];
6792
- const end = range[1];
6793
- const startHour = start.getHours();
6794
- const startMinute = start.getMinutes();
6795
- const endHour = end.getHours();
6796
- const endMinute = end.getMinutes();
6797
- if (startHour === hour && endHour !== hour) {
6798
- setRangeData(minutes, startMinute, 60, true);
6799
- } else if (startHour === hour && endHour === hour) {
6800
- setRangeData(minutes, startMinute, endMinute + 1, true);
6801
- } else if (startHour !== hour && endHour === hour) {
6802
- setRangeData(minutes, 0, endMinute + 1, true);
6803
- } else if (startHour < hour && endHour > hour) {
6804
- setRangeData(minutes, 0, 60, true);
6805
- }
6806
- });
6807
- } else {
6808
- setRangeData(minutes, 0, 60, true);
6809
- }
6810
- return minutes;
6811
- };
6812
-
6813
- const range = function(n) {
6814
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
6815
- return Array.apply(null, {length: n}).map((_, n) => n);
6816
- };
6817
-
6818
- const modifyDate = function(date, y, m, d) {
6819
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
6820
- };
6821
-
6822
- const modifyTime = function(date, h, m, s) {
6823
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
6824
- };
6825
-
6826
- const modifyWithTimeString = (date, time) => {
6827
- if (date == null || !time) {
6828
- return date;
6829
- }
6830
- time = parseDate(time, 'HH:mm:ss');
6831
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
6832
- };
6833
-
6834
- const clearTime = function(date) {
6835
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
6836
- };
6837
-
6838
- const clearMilliseconds = function(date) {
6839
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
6840
- };
6841
-
6842
- const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
6843
- // TODO: refactory a more elegant solution
6844
- if (ranges.length === 0) return date;
6845
- const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
6846
- const ndate = normalizeDate(date);
6847
- const nranges = ranges.map(range => range.map(normalizeDate));
6848
- if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
6849
-
6850
- let minDate = nranges[0][0];
6851
- let maxDate = nranges[0][0];
6852
-
6853
- nranges.forEach(nrange => {
6854
- minDate = new Date(Math.min(nrange[0], minDate));
6855
- maxDate = new Date(Math.max(nrange[1], minDate));
6856
- });
6857
-
6858
- const ret = ndate < minDate ? minDate : maxDate;
6859
- // preserve Year/Month/Date
6860
- return modifyDate(
6861
- ret,
6862
- date.getFullYear(),
6863
- date.getMonth(),
6864
- date.getDate()
6865
- );
6866
- };
6867
-
6868
- const timeWithinRange = function(date, selectableRange, format) {
6869
- const limitedDate = limitTimeRange(date, selectableRange, format);
6870
- return limitedDate.getTime() === date.getTime();
6871
- };
6872
-
6873
- const changeYearMonthAndClampDate = function(date, year, month) {
6874
- // clamp date to the number of days in `year`, `month`
6875
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
6876
- const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
6877
- return modifyDate(date, year, month, monthDate);
6878
- };
6879
-
6880
- const prevMonth = function(date) {
6881
- const year = date.getFullYear();
6882
- const month = date.getMonth();
6883
- return month === 0
6884
- ? changeYearMonthAndClampDate(date, year - 1, 11)
6885
- : changeYearMonthAndClampDate(date, year, month - 1);
6886
- };
6887
-
6888
- const nextMonth = function(date) {
6889
- const year = date.getFullYear();
6890
- const month = date.getMonth();
6891
- return month === 11
6892
- ? changeYearMonthAndClampDate(date, year + 1, 0)
6893
- : changeYearMonthAndClampDate(date, year, month + 1);
6894
- };
6895
-
6896
- const prevYear = function(date, amount = 1) {
6897
- const year = date.getFullYear();
6898
- const month = date.getMonth();
6899
- return changeYearMonthAndClampDate(date, year - amount, month);
6900
- };
6901
-
6902
- const nextYear = function(date, amount = 1) {
6903
- const year = date.getFullYear();
6904
- const month = date.getMonth();
6905
- return changeYearMonthAndClampDate(date, year + amount, month);
6906
- };
6907
-
6908
- const extractDateFormat = function(format) {
6909
- return format
6910
- .replace(/\W?m{1,2}|\W?ZZ/g, '')
6911
- .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
6912
- .trim();
6913
- };
6914
-
6915
- const extractTimeFormat = function(format) {
6916
- return format
6917
- .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
6918
- .trim();
6919
- };
6920
-
6921
- const validateRangeInOneMonth = function(start, end) {
6922
- return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
6923
- };
6924
-
6514
+ */
6515
+ fecha.parse = function (dateStr, format) {
6516
+ if (typeof format !== 'string') {
6517
+ throw new Error('Invalid format in fecha.parse');
6518
+ }
6519
+
6520
+ format = fecha.masks[format] || format;
6521
+
6522
+ // Avoid regular expression denial of service, fail early for really long strings
6523
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
6524
+ if (dateStr.length > 1000) {
6525
+ return null;
6526
+ }
6527
+
6528
+ var dateInfo = {};
6529
+ var parseInfo = [];
6530
+ var literals = [];
6531
+ format = format.replace(literal, function ($0, $1) {
6532
+ literals.push($1);
6533
+ return '@@@';
6534
+ });
6535
+ var newFormat = regexEscape(format).replace(token, function ($0) {
6536
+ if (parseFlags[$0]) {
6537
+ var info = parseFlags[$0];
6538
+ parseInfo.push(info[1]);
6539
+ return '(' + info[0] + ')';
6540
+ }
6541
+
6542
+ return $0;
6543
+ });
6544
+ newFormat = newFormat.replace(/@@@/g, function () {
6545
+ return literals.shift();
6546
+ });
6547
+ var matches = dateStr.match(new RegExp(newFormat, 'i'));
6548
+ if (!matches) {
6549
+ return null;
6550
+ }
6551
+
6552
+ for (var i = 1; i < matches.length; i++) {
6553
+ parseInfo[i - 1](dateInfo, matches[i]);
6554
+ }
6555
+
6556
+ var today = new Date();
6557
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
6558
+ dateInfo.hour = +dateInfo.hour + 12;
6559
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
6560
+ dateInfo.hour = 0;
6561
+ }
6562
+
6563
+ var date = void 0;
6564
+ if (dateInfo.timezoneOffset != null) {
6565
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
6566
+ 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));
6567
+ } else {
6568
+ 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);
6569
+ }
6570
+ return date;
6571
+ };
6572
+
6573
+ // 导出fecha对象
6574
+
6575
+
6576
+ // 以下是从date-util.js合并的函数
6577
+ var newArray = function newArray(start, end) {
6578
+ var result = [];
6579
+ for (var i = start; i <= end; i++) {
6580
+ result.push(i);
6581
+ }
6582
+ return result;
6583
+ };
6584
+
6585
+ var getSettings = function getSettings() {
6586
+ return {
6587
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
6588
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
6589
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
6590
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
6591
+ amPm: ['上午', '下午']
6592
+ };
6593
+ };
6594
+
6595
+ var toDate = function toDate(date) {
6596
+ return isDate(date) ? new Date(date) : null;
6597
+ };
6598
+
6599
+ var isDate = function isDate(date) {
6600
+ if (date === null || date === undefined) return false;
6601
+ if (isNaN(new Date(date).getTime())) return false;
6602
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
6603
+ return true;
6604
+ };
6605
+
6606
+ var isDateObject = function isDateObject(val) {
6607
+ return val instanceof Date;
6608
+ };
6609
+
6610
+ var formatDate = function formatDate(date) {
6611
+ var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
6612
+
6613
+ // 处理多种输入类型
6614
+ if (!date) return '';
6615
+
6616
+ // 如果是时间戳,转成日期对象
6617
+ if (typeof date === 'number') {
6618
+ date = new Date(date);
6619
+ }
6620
+ // 如果是字符串,转成日期对象
6621
+ if (typeof date === 'string') {
6622
+ date = new Date(date);
6623
+ }
6624
+
6625
+ // 调用toDate进一步验证和转换
6626
+ date = toDate(date);
6627
+ if (!date) return '';
6628
+
6629
+ // 兼容大写和小写的格式标记
6630
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
6631
+ var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
6632
+
6633
+ // 使用fecha库进行格式化,支持中文配置
6634
+ var str = fecha.format(date, lowercaseFormat, getSettings());
6635
+ return str;
6636
+ };
6637
+
6638
+ var parseDate = function parseDate(string, format) {
6639
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
6640
+ };
6641
+
6642
+ var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
6643
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
6644
+ return 30;
6645
+ }
6646
+
6647
+ if (month === 1) {
6648
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
6649
+ return 29;
6650
+ } else {
6651
+ return 28;
6652
+ }
6653
+ }
6654
+
6655
+ return 31;
6656
+ };
6657
+
6658
+ var getDayCountOfYear = function getDayCountOfYear(year) {
6659
+ var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
6660
+ return isLeapYear ? 366 : 365;
6661
+ };
6662
+
6663
+ var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
6664
+ var temp = new Date(date.getTime());
6665
+ temp.setDate(1);
6666
+ return temp.getDay();
6667
+ };
6668
+
6669
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
6670
+ // {prev, next} Date should work for Daylight Saving Time
6671
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
6672
+ var prevDate = function prevDate(date) {
6673
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6674
+
6675
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
6676
+ };
6677
+
6678
+ var nextDate = function nextDate(date) {
6679
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6680
+
6681
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
6682
+ };
6683
+
6684
+ var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
6685
+ var result = new Date(year, month, 1);
6686
+ var day = result.getDay();
6687
+
6688
+ if (day === 0) {
6689
+ return prevDate(result, 7);
6690
+ } else {
6691
+ return prevDate(result, day);
6692
+ }
6693
+ };
6694
+
6695
+ var getWeekNumber = function getWeekNumber(date) {
6696
+ // 支持多种输入类型
6697
+ if (!date || !isDate(date)) {
6698
+ date = new Date();
6699
+ }
6700
+ if (typeof date === 'string') {
6701
+ date = new Date(date);
6702
+ }
6703
+
6704
+ // 验证日期有效性
6705
+ if (!isDate(date)) return null;
6706
+
6707
+ var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
6708
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
6709
+ // 将星期日的星期数设为7
6710
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
6711
+ // 获取当年的第一天
6712
+ var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
6713
+ // 计算到最近的星期四的完整周数
6714
+ var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
6715
+ // 返回周数
6716
+ return weekNo;
6717
+ };
6718
+
6719
+ var getRangeHours = function getRangeHours(ranges) {
6720
+ var hours = [];
6721
+ var disabledHours = [];
6722
+
6723
+ (ranges || []).forEach(function (range) {
6724
+ var value = range.map(function (date) {
6725
+ return date.getHours();
6726
+ });
6727
+
6728
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
6729
+ });
6730
+
6731
+ if (disabledHours.length) {
6732
+ for (var i = 0; i < 24; i++) {
6733
+ hours[i] = disabledHours.indexOf(i) === -1;
6734
+ }
6735
+ } else {
6736
+ for (var _i = 0; _i < 24; _i++) {
6737
+ hours[_i] = false;
6738
+ }
6739
+ }
6740
+
6741
+ return hours;
6742
+ };
6743
+
6744
+ var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
6745
+ if (amount <= 0) return [];
6746
+ var temp = new Date(date.getTime());
6747
+ temp.setDate(0);
6748
+ var lastDay = temp.getDate();
6749
+ return range(amount).map(function (_, index) {
6750
+ return lastDay - (amount - index - 1);
6751
+ });
6752
+ };
6753
+
6754
+ var getMonthDays = function getMonthDays(date) {
6755
+ var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
6756
+ var days = temp.getDate();
6757
+ return range(days).map(function (_, index) {
6758
+ return index + 1;
6759
+ });
6760
+ };
6761
+
6762
+ function setRangeData(arr, start, end, value) {
6763
+ for (var i = start; i < end; i++) {
6764
+ arr[i] = value;
6765
+ }
6766
+ }
6767
+
6768
+ var getRangeMinutes = function getRangeMinutes(ranges, hour) {
6769
+ var minutes = new Array(60);
6770
+
6771
+ if (ranges.length > 0) {
6772
+ ranges.forEach(function (range) {
6773
+ var start = range[0];
6774
+ var end = range[1];
6775
+ var startHour = start.getHours();
6776
+ var startMinute = start.getMinutes();
6777
+ var endHour = end.getHours();
6778
+ var endMinute = end.getMinutes();
6779
+ if (startHour === hour && endHour !== hour) {
6780
+ setRangeData(minutes, startMinute, 60, true);
6781
+ } else if (startHour === hour && endHour === hour) {
6782
+ setRangeData(minutes, startMinute, endMinute + 1, true);
6783
+ } else if (startHour !== hour && endHour === hour) {
6784
+ setRangeData(minutes, 0, endMinute + 1, true);
6785
+ } else if (startHour < hour && endHour > hour) {
6786
+ setRangeData(minutes, 0, 60, true);
6787
+ }
6788
+ });
6789
+ } else {
6790
+ setRangeData(minutes, 0, 60, true);
6791
+ }
6792
+ return minutes;
6793
+ };
6794
+
6795
+ var range = function range(n) {
6796
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
6797
+ return Array.apply(null, { length: n }).map(function (_, n) {
6798
+ return n;
6799
+ });
6800
+ };
6801
+
6802
+ var modifyDate = function modifyDate(date, y, m, d) {
6803
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
6804
+ };
6805
+
6806
+ var modifyTime = function modifyTime(date, h, m, s) {
6807
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
6808
+ };
6809
+
6810
+ var modifyWithTimeString = function modifyWithTimeString(date, time) {
6811
+ if (date == null || !time) {
6812
+ return date;
6813
+ }
6814
+ time = parseDate(time, 'HH:mm:ss');
6815
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
6816
+ };
6817
+
6818
+ var clearTime = function clearTime(date) {
6819
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
6820
+ };
6821
+
6822
+ var clearMilliseconds = function clearMilliseconds(date) {
6823
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
6824
+ };
6825
+
6826
+ var limitTimeRange = function limitTimeRange(date, ranges) {
6827
+ var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
6828
+
6829
+ // TODO: refactory a more elegant solution
6830
+ if (ranges.length === 0) return date;
6831
+ var normalizeDate = function normalizeDate(date) {
6832
+ return fecha.parse(fecha.format(date, format), format);
6833
+ };
6834
+ var ndate = normalizeDate(date);
6835
+ var nranges = ranges.map(function (range) {
6836
+ return range.map(normalizeDate);
6837
+ });
6838
+ if (nranges.some(function (nrange) {
6839
+ return ndate >= nrange[0] && ndate <= nrange[1];
6840
+ })) return date;
6841
+
6842
+ var minDate = nranges[0][0];
6843
+ var maxDate = nranges[0][0];
6844
+
6845
+ nranges.forEach(function (nrange) {
6846
+ minDate = new Date(Math.min(nrange[0], minDate));
6847
+ maxDate = new Date(Math.max(nrange[1], minDate));
6848
+ });
6849
+
6850
+ var ret = ndate < minDate ? minDate : maxDate;
6851
+ // preserve Year/Month/Date
6852
+ return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
6853
+ };
6854
+
6855
+ var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
6856
+ var limitedDate = limitTimeRange(date, selectableRange, format);
6857
+ return limitedDate.getTime() === date.getTime();
6858
+ };
6859
+
6860
+ var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
6861
+ // clamp date to the number of days in `year`, `month`
6862
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
6863
+ var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
6864
+ return modifyDate(date, year, month, monthDate);
6865
+ };
6866
+
6867
+ var prevMonth = function prevMonth(date) {
6868
+ var year = date.getFullYear();
6869
+ var month = date.getMonth();
6870
+ return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
6871
+ };
6872
+
6873
+ var nextMonth = function nextMonth(date) {
6874
+ var year = date.getFullYear();
6875
+ var month = date.getMonth();
6876
+ return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
6877
+ };
6878
+
6879
+ var prevYear = function prevYear(date) {
6880
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6881
+
6882
+ var year = date.getFullYear();
6883
+ var month = date.getMonth();
6884
+ return changeYearMonthAndClampDate(date, year - amount, month);
6885
+ };
6886
+
6887
+ var nextYear = function nextYear(date) {
6888
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6889
+
6890
+ var year = date.getFullYear();
6891
+ var month = date.getMonth();
6892
+ return changeYearMonthAndClampDate(date, year + amount, month);
6893
+ };
6894
+
6895
+ var extractDateFormat = function extractDateFormat(format) {
6896
+ return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
6897
+ };
6898
+
6899
+ var extractTimeFormat = function extractTimeFormat(format) {
6900
+ return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
6901
+ };
6902
+
6903
+ var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
6904
+ return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
6905
+ };
6906
+
6925
6907
  /**
6926
6908
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
6927
6909
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
6928
6910
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
6929
6911
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
6930
6912
  * @returns {number} 工作日数量
6931
- */
6932
- const calculateNetworkDays = function (start_date, end_date, holidays = []) {
6933
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
6934
- throw new Error(
6935
- "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
6936
- );
6937
- }
6938
-
6939
- const startDateObj = new Date(start_date);
6940
- const endDateObj = new Date(end_date);
6941
-
6942
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
6943
- throw new Error(
6944
- "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
6945
- );
6946
- }
6947
-
6948
- if (startDateObj > endDateObj) {
6949
- throw new Error('Start date should be earlier than or equal to end date.');
6950
- }
6951
-
6952
- let workdays = 0;
6953
-
6954
- // Iterate through each day in the date range
6955
- for (
6956
- let currentDate = new Date(startDateObj);
6957
- currentDate <= endDateObj;
6958
- currentDate.setDate(currentDate.getDate() + 1)
6959
- ) {
6960
- // Check if the current day is a weekend (Saturday or Sunday)
6961
- const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
6962
-
6963
- // Check if the current day is a holiday
6964
- const isHoliday = holidays.some((holiday) => {
6965
- const holidayDate = new Date(holiday);
6966
- return currentDate.toDateString() === holidayDate.toDateString();
6967
- });
6968
-
6969
- // If it's a workday (not a weekend or holiday), increment the workdays count
6970
- if (!isWeekend && !isHoliday) {
6971
- workdays++;
6972
- }
6973
- }
6974
-
6975
- return workdays;
6976
- };
6977
-
6913
+ */
6914
+ var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
6915
+ var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
6916
+
6917
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
6918
+ throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
6919
+ }
6920
+
6921
+ var startDateObj = new Date(start_date);
6922
+ var endDateObj = new Date(end_date);
6923
+
6924
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
6925
+ throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
6926
+ }
6927
+
6928
+ if (startDateObj > endDateObj) {
6929
+ throw new Error('Start date should be earlier than or equal to end date.');
6930
+ }
6931
+
6932
+ var workdays = 0;
6933
+
6934
+ // Iterate through each day in the date range
6935
+
6936
+ var _loop = function _loop(currentDate) {
6937
+ // Check if the current day is a weekend (Saturday or Sunday)
6938
+ var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
6939
+
6940
+ // Check if the current day is a holiday
6941
+ var isHoliday = holidays.some(function (holiday) {
6942
+ var holidayDate = new Date(holiday);
6943
+ return currentDate.toDateString() === holidayDate.toDateString();
6944
+ });
6945
+
6946
+ // If it's a workday (not a weekend or holiday), increment the workdays count
6947
+ if (!isWeekend && !isHoliday) {
6948
+ workdays++;
6949
+ }
6950
+ };
6951
+
6952
+ for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
6953
+ _loop(currentDate);
6954
+ }
6955
+
6956
+ return workdays;
6957
+ };
6958
+
6978
6959
  /**
6979
6960
  * 日期加减天数
6980
6961
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
6981
6962
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
6982
6963
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
6983
- */
6984
- const dateAddDays = function (start_date, days) {
6985
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
6986
- throw new Error(
6987
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
6988
- );
6989
- }
6990
-
6991
- const startDateObj = new Date(start_date);
6992
- if (isNaN(startDateObj.getTime())) {
6993
- throw new Error(
6994
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
6995
- );
6996
- }
6997
-
6998
- const resultDateObj = new Date(startDateObj);
6999
- resultDateObj.setDate(resultDateObj.getDate() + days);
7000
-
7001
- const resultYear = resultDateObj.getFullYear();
7002
- const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
7003
- const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
7004
-
7005
- return `${resultYear}-${resultMonth}-${resultDay}`;
7006
- };
7007
-
6964
+ */
6965
+ var dateAddDays = function dateAddDays(start_date, days) {
6966
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
6967
+ 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.");
6968
+ }
6969
+
6970
+ var startDateObj = new Date(start_date);
6971
+ if (isNaN(startDateObj.getTime())) {
6972
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6973
+ }
6974
+
6975
+ var resultDateObj = new Date(startDateObj);
6976
+ resultDateObj.setDate(resultDateObj.getDate() + days);
6977
+
6978
+ var resultYear = resultDateObj.getFullYear();
6979
+ var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
6980
+ var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
6981
+
6982
+ return resultYear + '-' + resultMonth + '-' + resultDay;
6983
+ };
6984
+
7008
6985
  /**
7009
6986
  * 计算两个日期之间的差值
7010
6987
  * @date 2023年12月14日
@@ -7012,182 +6989,180 @@ const dateAddDays = function (start_date, days) {
7012
6989
  * @param {String} end_date - 结束日期字符串
7013
6990
  * @param {String} unit - 单位:year/month/day
7014
6991
  * @returns {Number} 差值
7015
- */
7016
- const dateDiff = function (start_date, end_date, unit = 'day') {
7017
- // Assuming date strings are in "YYYY-MM-DD" format
7018
- var startDate = new Date(start_date);
7019
- var endDate = new Date(end_date);
7020
-
7021
- // If the date is invalid, return 0
7022
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
7023
- return 0;
7024
- }
7025
-
7026
- if (unit === 'year') {
7027
- return endDate.getFullYear() - startDate.getFullYear();
7028
- } else if (unit === 'month') {
7029
- return (
7030
- (endDate.getFullYear() - startDate.getFullYear()) * 12 +
7031
- (endDate.getMonth() - startDate.getMonth())
7032
- );
7033
- } else {
7034
- // Default to day
7035
- var timeDifference = endDate - startDate;
7036
- // Calculate days (86400000 milliseconds per day)
7037
- return Math.floor(timeDifference / 86400000);
7038
- }
7039
- };
7040
-
6992
+ */
6993
+ var dateDiff = function dateDiff(start_date, end_date) {
6994
+ var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
6995
+
6996
+ // Assuming date strings are in "YYYY-MM-DD" format
6997
+ var startDate = new Date(start_date);
6998
+ var endDate = new Date(end_date);
6999
+
7000
+ // If the date is invalid, return 0
7001
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
7002
+ return 0;
7003
+ }
7004
+
7005
+ if (unit === 'year') {
7006
+ return endDate.getFullYear() - startDate.getFullYear();
7007
+ } else if (unit === 'month') {
7008
+ return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
7009
+ } else {
7010
+ // Default to day
7011
+ var timeDifference = endDate - startDate;
7012
+ // Calculate days (86400000 milliseconds per day)
7013
+ return Math.floor(timeDifference / 86400000);
7014
+ }
7015
+ };
7016
+
7041
7017
  /**
7042
7018
  * 获取月份中的日期
7043
7019
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
7044
7020
  * @returns {number} 月份中的日期(1-31)
7045
- */
7046
- const dayOfMonth = function (date) {
7047
- if (typeof date !== 'string') {
7048
- throw new Error(
7049
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
7050
- );
7051
- }
7052
-
7053
- const dateObj = new Date(date);
7054
- if (isNaN(dateObj.getTime())) {
7055
- throw new Error(
7056
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
7057
- );
7058
- }
7059
-
7060
- return dateObj.getDate();
7061
- };
7062
-
7021
+ */
7022
+ var dayOfMonth = function dayOfMonth(date) {
7023
+ if (typeof date !== 'string') {
7024
+ throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
7025
+ }
7026
+
7027
+ var dateObj = new Date(date);
7028
+ if (isNaN(dateObj.getTime())) {
7029
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
7030
+ }
7031
+
7032
+ return dateObj.getDate();
7033
+ };
7034
+
7063
7035
  /**
7064
7036
  * 获取当前日期
7065
7037
  * @date 2022年5月7日
7066
7038
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
7067
7039
  * @returns {string} 当前日期的格式化字符串
7068
- */
7069
- const getCurrentDate = function (format = 'YYYY-MM-DD') {
7070
- return formatDate(new Date(), format);
7071
- };
7072
-
7040
+ */
7041
+ var getCurrentDate = function getCurrentDate() {
7042
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
7043
+
7044
+ return formatDate(new Date(), format);
7045
+ };
7046
+
7073
7047
  /**
7074
7048
  * 获取当前日期时间
7075
7049
  * @date 2022年5月7日
7076
7050
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
7077
7051
  * @returns {string} 当前日期时间的格式化字符串
7078
- */
7079
- const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
7080
- return formatDate(new Date(), format);
7081
- };
7082
-
7052
+ */
7053
+ var getCurrentDateTime = function getCurrentDateTime() {
7054
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
7055
+
7056
+ return formatDate(new Date(), format);
7057
+ };
7058
+
7083
7059
  /**
7084
7060
  * 获取小时
7085
7061
  * @date 2022年5月7日
7086
7062
  * @param {Date|string} [date] - 日期对象或日期字符串
7087
7063
  * @returns {number} 小时数(0-23)
7088
- */
7089
- const getHour = function (date) {
7090
- if (!date) {
7091
- return new Date().getHours();
7092
- }
7093
- if (typeof date === 'string') {
7094
- date = new Date(date);
7095
- }
7096
- return date.getHours();
7097
- };
7098
-
7064
+ */
7065
+ var getHour = function getHour(date) {
7066
+ if (!date) {
7067
+ return new Date().getHours();
7068
+ }
7069
+ if (typeof date === 'string') {
7070
+ date = new Date(date);
7071
+ }
7072
+ return date.getHours();
7073
+ };
7074
+
7099
7075
  /**
7100
7076
  * 获取分钟
7101
7077
  * @date 2022年5月7日
7102
7078
  * @param {Date|string} [date] - 日期对象或日期字符串
7103
7079
  * @returns {number} 分钟数(0-59)
7104
- */
7105
- const getMinute = function (date) {
7106
- if (!date) {
7107
- return new Date().getMinutes();
7108
- }
7109
- if (typeof date === 'string') {
7110
- date = new Date(date);
7111
- }
7112
- return date.getMinutes();
7113
- };
7114
-
7080
+ */
7081
+ var getMinute = function getMinute(date) {
7082
+ if (!date) {
7083
+ return new Date().getMinutes();
7084
+ }
7085
+ if (typeof date === 'string') {
7086
+ date = new Date(date);
7087
+ }
7088
+ return date.getMinutes();
7089
+ };
7090
+
7115
7091
  /**
7116
7092
  * 获取月份
7117
7093
  * @date 2022年5月7日
7118
7094
  * @param {Date|string} [date] - 日期对象或日期字符串
7119
7095
  * @returns {number} 月份数(1-12)
7120
- */
7121
- const getMonth = function (date) {
7122
- if (!date) {
7123
- return new Date().getMonth() + 1;
7124
- }
7125
- if (typeof date === 'string') {
7126
- date = new Date(date);
7127
- }
7128
- return date.getMonth() + 1;
7129
- };
7130
-
7096
+ */
7097
+ var getMonth = function getMonth(date) {
7098
+ if (!date) {
7099
+ return new Date().getMonth() + 1;
7100
+ }
7101
+ if (typeof date === 'string') {
7102
+ date = new Date(date);
7103
+ }
7104
+ return date.getMonth() + 1;
7105
+ };
7106
+
7131
7107
  /**
7132
7108
  * 获取秒
7133
7109
  * @date 2022年5月7日
7134
7110
  * @param {Date|string} [date] - 日期对象或日期字符串
7135
7111
  * @returns {number} 秒数(0-59)
7136
- */
7137
- const getSecond = function (date) {
7138
- if (!date) {
7139
- return new Date().getSeconds();
7140
- }
7141
- if (typeof date === 'string') {
7142
- date = new Date(date);
7143
- }
7144
- return date.getSeconds();
7145
- };
7146
-
7112
+ */
7113
+ var getSecond = function getSecond(date) {
7114
+ if (!date) {
7115
+ return new Date().getSeconds();
7116
+ }
7117
+ if (typeof date === 'string') {
7118
+ date = new Date(date);
7119
+ }
7120
+ return date.getSeconds();
7121
+ };
7122
+
7147
7123
  /**
7148
7124
  * 获取星期几
7149
7125
  * @date 2022年5月7日
7150
7126
  * @param {Date|string} [date] - 日期对象或日期字符串
7151
7127
  * @returns {number} 星期几(0-6,0表示星期日)
7152
- */
7153
- const getWeekday = function (date) {
7154
- if (!date) {
7155
- return new Date().getDay();
7156
- }
7157
- if (typeof date === 'string') {
7158
- date = new Date(date);
7159
- }
7160
- return date.getDay();
7161
- };
7162
-
7163
-
7128
+ */
7129
+ var getWeekday = function getWeekday(date) {
7130
+ if (!date) {
7131
+ return new Date().getDay();
7132
+ }
7133
+ if (typeof date === 'string') {
7134
+ date = new Date(date);
7135
+ }
7136
+ return date.getDay();
7137
+ };
7138
+
7164
7139
  /**
7165
7140
  * @desc 获取上午/下午/晚上
7166
7141
  * @author huangbo
7167
7142
  * @date 2022年5月7日
7168
7143
  * @param {String} [time] - 时间
7169
- **/
7170
- const timeCycle = function (time) {
7171
- let hour = 0;
7172
- if (!time) {
7173
- hour = new Date().getHours();
7174
- } else if (typeof time === 'string') {
7175
- // 从时间字符串中提取小时
7176
- const match = time.match(/^(\d{1,2})/);
7177
- if (match) {
7178
- hour = parseInt(match[1], 10);
7179
- }
7180
- } else if (typeof time === 'number') {
7181
- hour = time;
7182
- }
7183
- // 判断时间段
7184
- if (hour >= 5 && hour < 12) {
7185
- return '上午';
7186
- } else if (hour >= 12 && hour < 18) {
7187
- return '下午';
7188
- } else {
7189
- return '晚上';
7190
- }
7144
+ **/
7145
+ var timeCycle = function timeCycle(time) {
7146
+ var hour = 0;
7147
+ if (!time) {
7148
+ hour = new Date().getHours();
7149
+ } else if (typeof time === 'string') {
7150
+ // 从时间字符串中提取小时
7151
+ var match = time.match(/^(\d{1,2})/);
7152
+ if (match) {
7153
+ hour = parseInt(match[1], 10);
7154
+ }
7155
+ } else if (typeof time === 'number') {
7156
+ hour = time;
7157
+ }
7158
+ // 判断时间段
7159
+ if (hour >= 5 && hour < 12) {
7160
+ return '上午';
7161
+ } else if (hour >= 12 && hour < 18) {
7162
+ return '下午';
7163
+ } else {
7164
+ return '晚上';
7165
+ }
7191
7166
  };
7192
7167
 
7193
7168
  /***/ }),
@@ -7199,7 +7174,7 @@ module.exports = require("eoss/lib/message-box");
7199
7174
 
7200
7175
  /***/ }),
7201
7176
 
7202
- /***/ 94:
7177
+ /***/ 96:
7203
7178
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
7204
7179
 
7205
7180
  "use strict";