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
package/lib/upload.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 = 187);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 194);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -4668,24 +4668,24 @@ var getRgb = function getRgb($color) {
4668
4668
 
4669
4669
  /***/ }),
4670
4670
 
4671
- /***/ 120:
4671
+ /***/ 124:
4672
4672
  /***/ (function(module, exports) {
4673
4673
 
4674
4674
  module.exports = require("eoss/lib/image-viewer");
4675
4675
 
4676
4676
  /***/ }),
4677
4677
 
4678
- /***/ 126:
4678
+ /***/ 13:
4679
4679
  /***/ (function(module, exports) {
4680
4680
 
4681
- module.exports = require("eoss/lib/progress");
4681
+ module.exports = require("eoss/lib/button");
4682
4682
 
4683
4683
  /***/ }),
4684
4684
 
4685
- /***/ 13:
4685
+ /***/ 130:
4686
4686
  /***/ (function(module, exports) {
4687
4687
 
4688
- module.exports = require("eoss/lib/button");
4688
+ module.exports = require("eoss/lib/progress");
4689
4689
 
4690
4690
  /***/ }),
4691
4691
 
@@ -4710,14 +4710,21 @@ module.exports = require("lodash/set");
4710
4710
 
4711
4711
  /***/ }),
4712
4712
 
4713
- /***/ 180:
4713
+ /***/ 187:
4714
4714
  /***/ (function(module, exports) {
4715
4715
 
4716
4716
  module.exports = require("lodash");
4717
4717
 
4718
4718
  /***/ }),
4719
4719
 
4720
- /***/ 187:
4720
+ /***/ 19:
4721
+ /***/ (function(module, exports) {
4722
+
4723
+ module.exports = require("lodash/cloneDeep");
4724
+
4725
+ /***/ }),
4726
+
4727
+ /***/ 194:
4721
4728
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4722
4729
 
4723
4730
  "use strict";
@@ -4962,7 +4969,7 @@ render._withStripped = true
4962
4969
  // CONCATENATED MODULE: ./packages/upload/src/index.vue?vue&type=template&id=24a5f8ce&
4963
4970
 
4964
4971
  // EXTERNAL MODULE: external "lodash"
4965
- var external_lodash_ = __webpack_require__(180);
4972
+ var external_lodash_ = __webpack_require__(187);
4966
4973
 
4967
4974
  // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/upload/src/upload-list.vue?vue&type=template&id=667db7eb&
4968
4975
  var upload_listvue_type_template_id_667db7eb_render = function () {
@@ -5240,7 +5247,7 @@ upload_listvue_type_template_id_667db7eb_render._withStripped = true
5240
5247
  // CONCATENATED MODULE: ./packages/upload/src/upload-list.vue?vue&type=template&id=667db7eb&
5241
5248
 
5242
5249
  // EXTERNAL MODULE: external "eoss/lib/progress"
5243
- var progress_ = __webpack_require__(126);
5250
+ var progress_ = __webpack_require__(130);
5244
5251
  var progress_default = /*#__PURE__*/__webpack_require__.n(progress_);
5245
5252
 
5246
5253
  // CONCATENATED MODULE: ./packages/upload/src/list.js
@@ -5485,11 +5492,11 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
5485
5492
  }
5486
5493
  });
5487
5494
  // EXTERNAL MODULE: external "sortablejs"
5488
- var external_sortablejs_ = __webpack_require__(56);
5495
+ var external_sortablejs_ = __webpack_require__(55);
5489
5496
  var external_sortablejs_default = /*#__PURE__*/__webpack_require__.n(external_sortablejs_);
5490
5497
 
5491
5498
  // EXTERNAL MODULE: ./src/components/bar.js
5492
- var bar = __webpack_require__(58);
5499
+ var bar = __webpack_require__(59);
5493
5500
 
5494
5501
  // EXTERNAL MODULE: ./src/utils/scrollbar.js
5495
5502
  var scrollbar = __webpack_require__(23);
@@ -5498,7 +5505,7 @@ var scrollbar = __webpack_require__(23);
5498
5505
  var external_throttle_debounce_ = __webpack_require__(24);
5499
5506
 
5500
5507
  // EXTERNAL MODULE: external "eoss/lib/button-group"
5501
- var button_group_ = __webpack_require__(53);
5508
+ var button_group_ = __webpack_require__(54);
5502
5509
  var button_group_default = /*#__PURE__*/__webpack_require__.n(button_group_);
5503
5510
 
5504
5511
  // EXTERNAL MODULE: external "eoss/lib/tooltip"
@@ -7321,7 +7328,7 @@ var message_box_ = __webpack_require__(8);
7321
7328
  var message_box_default = /*#__PURE__*/__webpack_require__.n(message_box_);
7322
7329
 
7323
7330
  // EXTERNAL MODULE: external "eoss/lib/image-viewer"
7324
- var image_viewer_ = __webpack_require__(120);
7331
+ var image_viewer_ = __webpack_require__(124);
7325
7332
  var image_viewer_default = /*#__PURE__*/__webpack_require__.n(image_viewer_);
7326
7333
 
7327
7334
  // EXTERNAL MODULE: ./src/config/api.js
@@ -8896,13 +8903,6 @@ src.install = function (Vue) {
8896
8903
 
8897
8904
  /***/ }),
8898
8905
 
8899
- /***/ 19:
8900
- /***/ (function(module, exports) {
8901
-
8902
- module.exports = require("lodash/cloneDeep");
8903
-
8904
- /***/ }),
8905
-
8906
8906
  /***/ 2:
8907
8907
  /***/ (function(module, exports) {
8908
8908
 
@@ -9673,21 +9673,21 @@ function insertAfter(newEl, targetEl) {
9673
9673
 
9674
9674
  /***/ }),
9675
9675
 
9676
- /***/ 53:
9676
+ /***/ 54:
9677
9677
  /***/ (function(module, exports) {
9678
9678
 
9679
9679
  module.exports = require("eoss/lib/button-group");
9680
9680
 
9681
9681
  /***/ }),
9682
9682
 
9683
- /***/ 56:
9683
+ /***/ 55:
9684
9684
  /***/ (function(module, exports) {
9685
9685
 
9686
9686
  module.exports = require("sortablejs");
9687
9687
 
9688
9688
  /***/ }),
9689
9689
 
9690
- /***/ 58:
9690
+ /***/ 59:
9691
9691
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
9692
9692
 
9693
9693
  "use strict";
@@ -10668,759 +10668,736 @@ var changeInTime = '/baseIssueRules/changeInTime';
10668
10668
  /* unused harmony export getSecond */
10669
10669
  /* unused harmony export getWeekday */
10670
10670
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
10671
- /* Modified from https://github.com/taylorhakes/fecha
10672
- *
10673
- * The MIT License (MIT)
10674
- *
10675
- * Copyright (c) 2015 Taylor Hakes
10676
- *
10677
- * Permission is hereby granted, free of charge, to any person obtaining a copy
10678
- * of this software and associated documentation files (the "Software"), to deal
10679
- * in the Software without restriction, including without limitation the rights
10680
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10681
- * copies of the Software, and to permit persons to whom the Software is
10682
- * furnished to do so, subject to the following conditions:
10683
- *
10684
- * The above copyright notice and this permission notice shall be included in all
10685
- * copies or substantial portions of the Software.
10686
- *
10687
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10688
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
10689
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
10690
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
10691
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
10692
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
10693
- * SOFTWARE.
10694
- */
10695
-
10696
- /*eslint-disable*/
10697
- // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
10698
-
10699
-
10671
+
10672
+
10700
10673
  /**
10701
10674
  * Parse or format dates
10702
10675
  * @class fecha
10703
- */
10704
- const fecha = {};
10705
- const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
10706
- const twoDigits = '\\d\\d?';
10707
- const threeDigits = '\\d{3}';
10708
- const fourDigits = '\\d{4}';
10709
- const word = '[^\\s]+';
10710
- const literal = /\[([^]*?)\]/gm;
10711
- const noop = function () {};
10712
-
10713
- function regexEscape(str) {
10714
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
10715
- }
10716
-
10717
- function shorten(arr, sLen) {
10718
- const newArr = [];
10719
- for (let i = 0, len = arr.length; i < len; i++) {
10720
- newArr.push(arr[i].substr(0, sLen));
10721
- }
10722
- return newArr;
10723
- }
10724
-
10725
- function monthUpdate() {
10726
- return function (d, v) {
10727
- const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
10728
- if (~index) {
10729
- d.month = index;
10730
- }
10731
- };
10732
- }
10733
-
10734
- function pad(val, len) {
10735
- val = String(val);
10736
- len = len || 2;
10737
- while (val.length < len) {
10738
- val = '0' + val;
10739
- }
10740
- return val;
10741
- }
10742
-
10743
- // 直接使用中文日期名称常量
10744
- const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
10745
- const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
10746
- const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
10747
- const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
10748
- const amPm = ['上午', '下午'];
10749
- const DoFn = function DoFn(D) {
10750
- return D + '日';
10751
- };
10752
-
10753
- const formatFlags = {
10754
- D: function(dateObj) {
10755
- return dateObj.getDay();
10756
- },
10757
- DD: function(dateObj) {
10758
- return pad(dateObj.getDay());
10759
- },
10760
- Do: function(dateObj) {
10761
- return DoFn(dateObj.getDate());
10762
- },
10763
- d: function(dateObj) {
10764
- return dateObj.getDate();
10765
- },
10766
- dd: function(dateObj) {
10767
- return pad(dateObj.getDate());
10768
- },
10769
- ddd: function(dateObj) {
10770
- return dayNamesShort[dateObj.getDay()];
10771
- },
10772
- dddd: function(dateObj) {
10773
- return dayNames[dateObj.getDay()];
10774
- },
10775
- M: function(dateObj) {
10776
- return dateObj.getMonth() + 1;
10777
- },
10778
- MM: function(dateObj) {
10779
- return pad(dateObj.getMonth() + 1);
10780
- },
10781
- MMM: function(dateObj) {
10782
- return monthNamesShort[dateObj.getMonth()];
10783
- },
10784
- MMMM: function(dateObj) {
10785
- return monthNames[dateObj.getMonth()];
10786
- },
10787
- yy: function(dateObj) {
10788
- return pad(String(dateObj.getFullYear()), 4).substr(2);
10789
- },
10790
- yyyy: function(dateObj) {
10791
- return pad(dateObj.getFullYear(), 4);
10792
- },
10793
- h: function(dateObj) {
10794
- return dateObj.getHours() % 12 || 12;
10795
- },
10796
- hh: function(dateObj) {
10797
- return pad(dateObj.getHours() % 12 || 12);
10798
- },
10799
- H: function(dateObj) {
10800
- return dateObj.getHours();
10801
- },
10802
- HH: function(dateObj) {
10803
- return pad(dateObj.getHours());
10804
- },
10805
- m: function(dateObj) {
10806
- return dateObj.getMinutes();
10807
- },
10808
- mm: function(dateObj) {
10809
- return pad(dateObj.getMinutes());
10810
- },
10811
- s: function(dateObj) {
10812
- return dateObj.getSeconds();
10813
- },
10814
- ss: function(dateObj) {
10815
- return pad(dateObj.getSeconds());
10816
- },
10817
- S: function(dateObj) {
10818
- return Math.round(dateObj.getMilliseconds() / 100);
10819
- },
10820
- SS: function(dateObj) {
10821
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
10822
- },
10823
- SSS: function(dateObj) {
10824
- return pad(dateObj.getMilliseconds(), 3);
10825
- },
10826
- a: function(dateObj) {
10827
- return dateObj.getHours() < 12 ? '上午' : '下午';
10828
- },
10829
- A: function(dateObj) {
10830
- return dateObj.getHours() < 12 ? '上午' : '下午';
10831
- },
10832
- ZZ: function(dateObj) {
10833
- const o = dateObj.getTimezoneOffset();
10834
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
10835
- }
10836
- };
10837
-
10838
- const parseFlags = {
10839
- d: [twoDigits, function (d, v) {
10840
- d.day = v;
10841
- }],
10842
- Do: [twoDigits + word, function (d, v) {
10843
- d.day = parseInt(v, 10);
10844
- }],
10845
- M: [twoDigits, function (d, v) {
10846
- d.month = v - 1;
10847
- }],
10848
- yy: [twoDigits, function (d, v) {
10849
- const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
10850
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
10851
- }],
10852
- h: [twoDigits, function (d, v) {
10853
- d.hour = v;
10854
- }],
10855
- m: [twoDigits, function (d, v) {
10856
- d.minute = v;
10857
- }],
10858
- s: [twoDigits, function (d, v) {
10859
- d.second = v;
10860
- }],
10861
- yyyy: [fourDigits, function (d, v) {
10862
- d.year = v;
10863
- }],
10864
- S: ['\\d', function (d, v) {
10865
- d.millisecond = v * 100;
10866
- }],
10867
- SS: ['\\d{2}', function (d, v) {
10868
- d.millisecond = v * 10;
10869
- }],
10870
- SSS: [threeDigits, function (d, v) {
10871
- d.millisecond = v;
10872
- }],
10873
- D: [twoDigits, noop],
10874
- ddd: [word, noop],
10875
- MMM: [word, monthUpdate('monthNamesShort')],
10876
- MMMM: [word, monthUpdate('monthNames')],
10877
- a: [word, function (d, v) {
10878
- const val = v.toLowerCase();
10879
- if (val === '上午') {
10880
- d.isPm = false;
10881
- } else if (val === '下午') {
10882
- d.isPm = true;
10883
- }
10884
- }],
10885
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
10886
- let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
10887
-
10888
- if (parts) {
10889
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
10890
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
10891
- }
10892
- }]
10893
- };
10894
- parseFlags.dd = parseFlags.d;
10895
- parseFlags.dddd = parseFlags.ddd;
10896
- parseFlags.DD = parseFlags.D;
10897
- parseFlags.mm = parseFlags.m;
10898
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
10899
- parseFlags.MM = parseFlags.M;
10900
- parseFlags.ss = parseFlags.s;
10901
- parseFlags.A = parseFlags.a;
10902
-
10903
-
10904
- // Some common format strings
10905
- fecha.masks = {
10906
- default: 'ddd MMM dd yyyy HH:mm:ss',
10907
- shortDate: 'M/D/yy',
10908
- mediumDate: 'MMM d, yyyy',
10909
- longDate: 'MMMM d, yyyy',
10910
- fullDate: 'dddd, MMMM d, yyyy',
10911
- shortTime: 'HH:mm',
10912
- mediumTime: 'HH:mm:ss',
10913
- longTime: 'HH:mm:ss.SSS'
10914
- };
10915
-
10676
+ */
10677
+ var fecha = {};
10678
+ var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
10679
+ var twoDigits = '\\d\\d?';
10680
+ var threeDigits = '\\d{3}';
10681
+ var fourDigits = '\\d{4}';
10682
+ var word = '[^\\s]+';
10683
+ var literal = /\[([^]*?)\]/gm;
10684
+ var noop = function noop() {};
10685
+
10686
+ function regexEscape(str) {
10687
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
10688
+ }
10689
+
10690
+ function shorten(arr, sLen) {
10691
+ var newArr = [];
10692
+ for (var i = 0, len = arr.length; i < len; i++) {
10693
+ newArr.push(arr[i].substr(0, sLen));
10694
+ }
10695
+ return newArr;
10696
+ }
10697
+
10698
+ function monthUpdate() {
10699
+ return function (d, v) {
10700
+ var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
10701
+ if (~index) {
10702
+ d.month = index;
10703
+ }
10704
+ };
10705
+ }
10706
+
10707
+ function pad(val, len) {
10708
+ val = String(val);
10709
+ len = len || 2;
10710
+ while (val.length < len) {
10711
+ val = '0' + val;
10712
+ }
10713
+ return val;
10714
+ }
10715
+
10716
+ // 直接使用中文日期名称常量
10717
+ var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
10718
+ var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
10719
+ var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
10720
+ var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
10721
+ var amPm = ['上午', '下午'];
10722
+ var DoFn = function DoFn(D) {
10723
+ return D + '日';
10724
+ };
10725
+
10726
+ var formatFlags = {
10727
+ D: function D(dateObj) {
10728
+ return dateObj.getDay();
10729
+ },
10730
+ DD: function DD(dateObj) {
10731
+ return pad(dateObj.getDay());
10732
+ },
10733
+ Do: function Do(dateObj) {
10734
+ return DoFn(dateObj.getDate());
10735
+ },
10736
+ d: function d(dateObj) {
10737
+ return dateObj.getDate();
10738
+ },
10739
+ dd: function dd(dateObj) {
10740
+ return pad(dateObj.getDate());
10741
+ },
10742
+ ddd: function ddd(dateObj) {
10743
+ return dayNamesShort[dateObj.getDay()];
10744
+ },
10745
+ dddd: function dddd(dateObj) {
10746
+ return dayNames[dateObj.getDay()];
10747
+ },
10748
+ M: function M(dateObj) {
10749
+ return dateObj.getMonth() + 1;
10750
+ },
10751
+ MM: function MM(dateObj) {
10752
+ return pad(dateObj.getMonth() + 1);
10753
+ },
10754
+ MMM: function MMM(dateObj) {
10755
+ return monthNamesShort[dateObj.getMonth()];
10756
+ },
10757
+ MMMM: function MMMM(dateObj) {
10758
+ return monthNames[dateObj.getMonth()];
10759
+ },
10760
+ yy: function yy(dateObj) {
10761
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
10762
+ },
10763
+ yyyy: function yyyy(dateObj) {
10764
+ return pad(dateObj.getFullYear(), 4);
10765
+ },
10766
+ h: function h(dateObj) {
10767
+ return dateObj.getHours() % 12 || 12;
10768
+ },
10769
+ hh: function hh(dateObj) {
10770
+ return pad(dateObj.getHours() % 12 || 12);
10771
+ },
10772
+ H: function H(dateObj) {
10773
+ return dateObj.getHours();
10774
+ },
10775
+ HH: function HH(dateObj) {
10776
+ return pad(dateObj.getHours());
10777
+ },
10778
+ m: function m(dateObj) {
10779
+ return dateObj.getMinutes();
10780
+ },
10781
+ mm: function mm(dateObj) {
10782
+ return pad(dateObj.getMinutes());
10783
+ },
10784
+ s: function s(dateObj) {
10785
+ return dateObj.getSeconds();
10786
+ },
10787
+ ss: function ss(dateObj) {
10788
+ return pad(dateObj.getSeconds());
10789
+ },
10790
+ S: function S(dateObj) {
10791
+ return Math.round(dateObj.getMilliseconds() / 100);
10792
+ },
10793
+ SS: function SS(dateObj) {
10794
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
10795
+ },
10796
+ SSS: function SSS(dateObj) {
10797
+ return pad(dateObj.getMilliseconds(), 3);
10798
+ },
10799
+ a: function a(dateObj) {
10800
+ return dateObj.getHours() < 12 ? '上午' : '下午';
10801
+ },
10802
+ A: function A(dateObj) {
10803
+ return dateObj.getHours() < 12 ? '上午' : '下午';
10804
+ },
10805
+ ZZ: function ZZ(dateObj) {
10806
+ var o = dateObj.getTimezoneOffset();
10807
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
10808
+ }
10809
+ };
10810
+
10811
+ var parseFlags = {
10812
+ d: [twoDigits, function (d, v) {
10813
+ d.day = v;
10814
+ }],
10815
+ Do: [twoDigits + word, function (d, v) {
10816
+ d.day = parseInt(v, 10);
10817
+ }],
10818
+ M: [twoDigits, function (d, v) {
10819
+ d.month = v - 1;
10820
+ }],
10821
+ yy: [twoDigits, function (d, v) {
10822
+ var da = new Date(),
10823
+ cent = +('' + da.getFullYear()).substr(0, 2);
10824
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
10825
+ }],
10826
+ h: [twoDigits, function (d, v) {
10827
+ d.hour = v;
10828
+ }],
10829
+ m: [twoDigits, function (d, v) {
10830
+ d.minute = v;
10831
+ }],
10832
+ s: [twoDigits, function (d, v) {
10833
+ d.second = v;
10834
+ }],
10835
+ yyyy: [fourDigits, function (d, v) {
10836
+ d.year = v;
10837
+ }],
10838
+ S: ['\\d', function (d, v) {
10839
+ d.millisecond = v * 100;
10840
+ }],
10841
+ SS: ['\\d{2}', function (d, v) {
10842
+ d.millisecond = v * 10;
10843
+ }],
10844
+ SSS: [threeDigits, function (d, v) {
10845
+ d.millisecond = v;
10846
+ }],
10847
+ D: [twoDigits, noop],
10848
+ ddd: [word, noop],
10849
+ MMM: [word, monthUpdate('monthNamesShort')],
10850
+ MMMM: [word, monthUpdate('monthNames')],
10851
+ a: [word, function (d, v) {
10852
+ var val = v.toLowerCase();
10853
+ if (val === '上午') {
10854
+ d.isPm = false;
10855
+ } else if (val === '下午') {
10856
+ d.isPm = true;
10857
+ }
10858
+ }],
10859
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
10860
+ var parts = (v + '').match(/([+-]|\d\d)/gi),
10861
+ minutes = void 0;
10862
+
10863
+ if (parts) {
10864
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
10865
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
10866
+ }
10867
+ }]
10868
+ };
10869
+ parseFlags.dd = parseFlags.d;
10870
+ parseFlags.dddd = parseFlags.ddd;
10871
+ parseFlags.DD = parseFlags.D;
10872
+ parseFlags.mm = parseFlags.m;
10873
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
10874
+ parseFlags.MM = parseFlags.M;
10875
+ parseFlags.ss = parseFlags.s;
10876
+ parseFlags.A = parseFlags.a;
10877
+
10878
+ // Some common format strings
10879
+ fecha.masks = {
10880
+ default: 'ddd MMM dd yyyy HH:mm:ss',
10881
+ shortDate: 'M/D/yy',
10882
+ mediumDate: 'MMM d, yyyy',
10883
+ longDate: 'MMMM d, yyyy',
10884
+ fullDate: 'dddd, MMMM d, yyyy',
10885
+ shortTime: 'HH:mm',
10886
+ mediumTime: 'HH:mm:ss',
10887
+ longTime: 'HH:mm:ss.SSS'
10888
+ };
10889
+
10916
10890
  /***
10917
10891
  * Format a date
10918
10892
  * @method format
10919
10893
  * @param {Date|number} dateObj
10920
10894
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
10921
- */
10922
- fecha.format = function (dateObj, mask) {
10923
- if (typeof dateObj === 'number') {
10924
- dateObj = new Date(dateObj);
10925
- }
10926
-
10927
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
10928
- throw new Error('Invalid Date in fecha.format');
10929
- }
10930
-
10931
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
10932
-
10933
- const literals = [];
10934
-
10935
- // Make literals inactive by replacing them with ??
10936
- mask = mask.replace(literal, function($0, $1) {
10937
- literals.push($1);
10938
- return '@@@';
10939
- });
10940
- // Apply formatting rules
10941
- mask = mask.replace(token, function ($0) {
10942
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
10943
- });
10944
- // Inline literal values back into the formatted value
10945
- return mask.replace(/@@@/g, function() {
10946
- return literals.shift();
10947
- });
10948
- };
10949
-
10895
+ */
10896
+ fecha.format = function (dateObj, mask) {
10897
+ if (typeof dateObj === 'number') {
10898
+ dateObj = new Date(dateObj);
10899
+ }
10900
+
10901
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
10902
+ throw new Error('Invalid Date in fecha.format');
10903
+ }
10904
+
10905
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
10906
+
10907
+ var literals = [];
10908
+
10909
+ // Make literals inactive by replacing them with ??
10910
+ mask = mask.replace(literal, function ($0, $1) {
10911
+ literals.push($1);
10912
+ return '@@@';
10913
+ });
10914
+ // Apply formatting rules
10915
+ mask = mask.replace(token, function ($0) {
10916
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
10917
+ });
10918
+ // Inline literal values back into the formatted value
10919
+ return mask.replace(/@@@/g, function () {
10920
+ return literals.shift();
10921
+ });
10922
+ };
10923
+
10950
10924
  /**
10951
10925
  * Parse a date string into an object, changes - into /
10952
10926
  * @method parse
10953
10927
  * @param {string} dateStr Date string
10954
10928
  * @param {string} format Date parse format
10955
10929
  * @returns {Date|boolean}
10956
- */
10957
- fecha.parse = function (dateStr, format) {
10958
- if (typeof format !== 'string') {
10959
- throw new Error('Invalid format in fecha.parse');
10960
- }
10961
-
10962
- format = fecha.masks[format] || format;
10963
-
10964
- // Avoid regular expression denial of service, fail early for really long strings
10965
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
10966
- if (dateStr.length > 1000) {
10967
- return null;
10968
- }
10969
-
10970
- const dateInfo = {};
10971
- const parseInfo = [];
10972
- const literals = [];
10973
- format = format.replace(literal, function($0, $1) {
10974
- literals.push($1);
10975
- return '@@@';
10976
- });
10977
- let newFormat = regexEscape(format).replace(token, function ($0) {
10978
- if (parseFlags[$0]) {
10979
- const info = parseFlags[$0];
10980
- parseInfo.push(info[1]);
10981
- return '(' + info[0] + ')';
10982
- }
10983
-
10984
- return $0;
10985
- });
10986
- newFormat = newFormat.replace(/@@@/g, function() {
10987
- return literals.shift();
10988
- });
10989
- const matches = dateStr.match(new RegExp(newFormat, 'i'));
10990
- if (!matches) {
10991
- return null;
10992
- }
10993
-
10994
- for (let i = 1; i < matches.length; i++) {
10995
- parseInfo[i - 1](dateInfo, matches[i]);
10996
- }
10997
-
10998
- const today = new Date();
10999
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
11000
- dateInfo.hour = +dateInfo.hour + 12;
11001
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
11002
- dateInfo.hour = 0;
11003
- }
11004
-
11005
- let date;
11006
- if (dateInfo.timezoneOffset != null) {
11007
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
11008
- date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
11009
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
11010
- } else {
11011
- date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
11012
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
11013
- }
11014
- return date;
11015
- };
11016
-
11017
- // 导出fecha对象
11018
-
11019
-
11020
- // 以下是从date-util.js合并的函数
11021
- const newArray = function(start, end) {
11022
- let result = [];
11023
- for (let i = start; i <= end; i++) {
11024
- result.push(i);
11025
- }
11026
- return result;
11027
- };
11028
-
11029
- const getSettings = () => {
11030
- return {
11031
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
11032
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
11033
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
11034
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
11035
- amPm: ['上午', '下午']
11036
- };
11037
- };
11038
-
11039
- const toDate = function(date) {
11040
- return isDate(date) ? new Date(date) : null;
11041
- };
11042
-
11043
- const isDate = function(date) {
11044
- if (date === null || date === undefined) return false;
11045
- if (isNaN(new Date(date).getTime())) return false;
11046
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
11047
- return true;
11048
- };
11049
-
11050
- const isDateObject = function(val) {
11051
- return val instanceof Date;
11052
- };
11053
-
11054
- const formatDate = function (date, format = 'yyyy-MM-dd') {
11055
- // 处理多种输入类型
11056
- if (!date) return '';
11057
-
11058
- // 如果是时间戳,转成日期对象
11059
- if (typeof date === 'number') {
11060
- date = new Date(date);
11061
- }
11062
- // 如果是字符串,转成日期对象
11063
- if (typeof date === 'string') {
11064
- date = new Date(date);
11065
- }
11066
-
11067
- // 调用toDate进一步验证和转换
11068
- date = toDate(date);
11069
- if (!date) return '';
11070
-
11071
- // 兼容大写和小写的格式标记
11072
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
11073
- const lowercaseFormat = format
11074
- .replace(/YYYY/g, 'yyyy')
11075
- .replace(/D/g, 'd')
11076
-
11077
- // 使用fecha库进行格式化,支持中文配置
11078
- const str = fecha.format(date, lowercaseFormat, getSettings());
11079
- return str;
11080
- };
11081
-
11082
- const parseDate = function(string, format) {
11083
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
11084
- };
11085
-
11086
- const getDayCountOfMonth = function(year, month) {
11087
- if (month === 3 || month === 5 || month === 8 || month === 10) {
11088
- return 30;
11089
- }
11090
-
11091
- if (month === 1) {
11092
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
11093
- return 29;
11094
- } else {
11095
- return 28;
11096
- }
11097
- }
11098
-
11099
- return 31;
11100
- };
11101
-
11102
- const getDayCountOfYear = function(year) {
11103
- const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
11104
- return isLeapYear ? 366 : 365;
11105
- };
11106
-
11107
- const getFirstDayOfMonth = function(date) {
11108
- const temp = new Date(date.getTime());
11109
- temp.setDate(1);
11110
- return temp.getDay();
11111
- };
11112
-
11113
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
11114
- // {prev, next} Date should work for Daylight Saving Time
11115
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
11116
- const prevDate = function(date, amount = 1) {
11117
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
11118
- };
11119
-
11120
- const nextDate = function(date, amount = 1) {
11121
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
11122
- };
11123
-
11124
- const getStartDateOfMonth = function(year, month) {
11125
- const result = new Date(year, month, 1);
11126
- const day = result.getDay();
11127
-
11128
- if (day === 0) {
11129
- return prevDate(result, 7);
11130
- } else {
11131
- return prevDate(result, day);
11132
- }
11133
- };
11134
-
11135
- const getWeekNumber = function(date) {
11136
- // 支持多种输入类型
11137
- if (!date||!isDate(date)) {
11138
- date = new Date();
11139
- }
11140
- if (typeof date === 'string') {
11141
- date = new Date(date);
11142
- }
11143
-
11144
- // 验证日期有效性
11145
- if (!isDate(date)) return null;
11146
-
11147
- const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
11148
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
11149
- // 将星期日的星期数设为7
11150
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
11151
- // 获取当年的第一天
11152
- const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
11153
- // 计算到最近的星期四的完整周数
11154
- const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
11155
- // 返回周数
11156
- return weekNo;
11157
- };
11158
-
11159
- const getRangeHours = function(ranges) {
11160
- const hours = [];
11161
- let disabledHours = [];
11162
-
11163
- (ranges || []).forEach(range => {
11164
- const value = range.map(date => date.getHours());
11165
-
11166
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
11167
- });
11168
-
11169
- if (disabledHours.length) {
11170
- for (let i = 0; i < 24; i++) {
11171
- hours[i] = disabledHours.indexOf(i) === -1;
11172
- }
11173
- } else {
11174
- for (let i = 0; i < 24; i++) {
11175
- hours[i] = false;
11176
- }
11177
- }
11178
-
11179
- return hours;
11180
- };
11181
-
11182
- const getPrevMonthLastDays = (date, amount) => {
11183
- if (amount <= 0) return [];
11184
- const temp = new Date(date.getTime());
11185
- temp.setDate(0);
11186
- const lastDay = temp.getDate();
11187
- return range(amount).map((_, index) => lastDay - (amount - index - 1));
11188
- };
11189
-
11190
- const getMonthDays = (date) => {
11191
- const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
11192
- const days = temp.getDate();
11193
- return range(days).map((_, index) => index + 1);
11194
- };
11195
-
11196
- function setRangeData(arr, start, end, value) {
11197
- for (let i = start; i < end; i++) {
11198
- arr[i] = value;
11199
- }
11200
- }
11201
-
11202
- const getRangeMinutes = function(ranges, hour) {
11203
- const minutes = new Array(60);
11204
-
11205
- if (ranges.length > 0) {
11206
- ranges.forEach(range => {
11207
- const start = range[0];
11208
- const end = range[1];
11209
- const startHour = start.getHours();
11210
- const startMinute = start.getMinutes();
11211
- const endHour = end.getHours();
11212
- const endMinute = end.getMinutes();
11213
- if (startHour === hour && endHour !== hour) {
11214
- setRangeData(minutes, startMinute, 60, true);
11215
- } else if (startHour === hour && endHour === hour) {
11216
- setRangeData(minutes, startMinute, endMinute + 1, true);
11217
- } else if (startHour !== hour && endHour === hour) {
11218
- setRangeData(minutes, 0, endMinute + 1, true);
11219
- } else if (startHour < hour && endHour > hour) {
11220
- setRangeData(minutes, 0, 60, true);
11221
- }
11222
- });
11223
- } else {
11224
- setRangeData(minutes, 0, 60, true);
11225
- }
11226
- return minutes;
11227
- };
11228
-
11229
- const range = function(n) {
11230
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
11231
- return Array.apply(null, {length: n}).map((_, n) => n);
11232
- };
11233
-
11234
- const modifyDate = function(date, y, m, d) {
11235
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
11236
- };
11237
-
11238
- const modifyTime = function(date, h, m, s) {
11239
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
11240
- };
11241
-
11242
- const modifyWithTimeString = (date, time) => {
11243
- if (date == null || !time) {
11244
- return date;
11245
- }
11246
- time = parseDate(time, 'HH:mm:ss');
11247
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
11248
- };
11249
-
11250
- const clearTime = function(date) {
11251
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
11252
- };
11253
-
11254
- const clearMilliseconds = function(date) {
11255
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
11256
- };
11257
-
11258
- const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
11259
- // TODO: refactory a more elegant solution
11260
- if (ranges.length === 0) return date;
11261
- const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
11262
- const ndate = normalizeDate(date);
11263
- const nranges = ranges.map(range => range.map(normalizeDate));
11264
- if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
11265
-
11266
- let minDate = nranges[0][0];
11267
- let maxDate = nranges[0][0];
11268
-
11269
- nranges.forEach(nrange => {
11270
- minDate = new Date(Math.min(nrange[0], minDate));
11271
- maxDate = new Date(Math.max(nrange[1], minDate));
11272
- });
11273
-
11274
- const ret = ndate < minDate ? minDate : maxDate;
11275
- // preserve Year/Month/Date
11276
- return modifyDate(
11277
- ret,
11278
- date.getFullYear(),
11279
- date.getMonth(),
11280
- date.getDate()
11281
- );
11282
- };
11283
-
11284
- const timeWithinRange = function(date, selectableRange, format) {
11285
- const limitedDate = limitTimeRange(date, selectableRange, format);
11286
- return limitedDate.getTime() === date.getTime();
11287
- };
11288
-
11289
- const changeYearMonthAndClampDate = function(date, year, month) {
11290
- // clamp date to the number of days in `year`, `month`
11291
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
11292
- const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
11293
- return modifyDate(date, year, month, monthDate);
11294
- };
11295
-
11296
- const prevMonth = function(date) {
11297
- const year = date.getFullYear();
11298
- const month = date.getMonth();
11299
- return month === 0
11300
- ? changeYearMonthAndClampDate(date, year - 1, 11)
11301
- : changeYearMonthAndClampDate(date, year, month - 1);
11302
- };
11303
-
11304
- const nextMonth = function(date) {
11305
- const year = date.getFullYear();
11306
- const month = date.getMonth();
11307
- return month === 11
11308
- ? changeYearMonthAndClampDate(date, year + 1, 0)
11309
- : changeYearMonthAndClampDate(date, year, month + 1);
11310
- };
11311
-
11312
- const prevYear = function(date, amount = 1) {
11313
- const year = date.getFullYear();
11314
- const month = date.getMonth();
11315
- return changeYearMonthAndClampDate(date, year - amount, month);
11316
- };
11317
-
11318
- const nextYear = function(date, amount = 1) {
11319
- const year = date.getFullYear();
11320
- const month = date.getMonth();
11321
- return changeYearMonthAndClampDate(date, year + amount, month);
11322
- };
11323
-
11324
- const extractDateFormat = function(format) {
11325
- return format
11326
- .replace(/\W?m{1,2}|\W?ZZ/g, '')
11327
- .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
11328
- .trim();
11329
- };
11330
-
11331
- const extractTimeFormat = function(format) {
11332
- return format
11333
- .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
11334
- .trim();
11335
- };
11336
-
11337
- const validateRangeInOneMonth = function(start, end) {
11338
- return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
11339
- };
11340
-
10930
+ */
10931
+ fecha.parse = function (dateStr, format) {
10932
+ if (typeof format !== 'string') {
10933
+ throw new Error('Invalid format in fecha.parse');
10934
+ }
10935
+
10936
+ format = fecha.masks[format] || format;
10937
+
10938
+ // Avoid regular expression denial of service, fail early for really long strings
10939
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
10940
+ if (dateStr.length > 1000) {
10941
+ return null;
10942
+ }
10943
+
10944
+ var dateInfo = {};
10945
+ var parseInfo = [];
10946
+ var literals = [];
10947
+ format = format.replace(literal, function ($0, $1) {
10948
+ literals.push($1);
10949
+ return '@@@';
10950
+ });
10951
+ var newFormat = regexEscape(format).replace(token, function ($0) {
10952
+ if (parseFlags[$0]) {
10953
+ var info = parseFlags[$0];
10954
+ parseInfo.push(info[1]);
10955
+ return '(' + info[0] + ')';
10956
+ }
10957
+
10958
+ return $0;
10959
+ });
10960
+ newFormat = newFormat.replace(/@@@/g, function () {
10961
+ return literals.shift();
10962
+ });
10963
+ var matches = dateStr.match(new RegExp(newFormat, 'i'));
10964
+ if (!matches) {
10965
+ return null;
10966
+ }
10967
+
10968
+ for (var i = 1; i < matches.length; i++) {
10969
+ parseInfo[i - 1](dateInfo, matches[i]);
10970
+ }
10971
+
10972
+ var today = new Date();
10973
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
10974
+ dateInfo.hour = +dateInfo.hour + 12;
10975
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
10976
+ dateInfo.hour = 0;
10977
+ }
10978
+
10979
+ var date = void 0;
10980
+ if (dateInfo.timezoneOffset != null) {
10981
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
10982
+ 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));
10983
+ } else {
10984
+ 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);
10985
+ }
10986
+ return date;
10987
+ };
10988
+
10989
+ // 导出fecha对象
10990
+
10991
+
10992
+ // 以下是从date-util.js合并的函数
10993
+ var newArray = function newArray(start, end) {
10994
+ var result = [];
10995
+ for (var i = start; i <= end; i++) {
10996
+ result.push(i);
10997
+ }
10998
+ return result;
10999
+ };
11000
+
11001
+ var getSettings = function getSettings() {
11002
+ return {
11003
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
11004
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
11005
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
11006
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
11007
+ amPm: ['上午', '下午']
11008
+ };
11009
+ };
11010
+
11011
+ var toDate = function toDate(date) {
11012
+ return isDate(date) ? new Date(date) : null;
11013
+ };
11014
+
11015
+ var isDate = function isDate(date) {
11016
+ if (date === null || date === undefined) return false;
11017
+ if (isNaN(new Date(date).getTime())) return false;
11018
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
11019
+ return true;
11020
+ };
11021
+
11022
+ var isDateObject = function isDateObject(val) {
11023
+ return val instanceof Date;
11024
+ };
11025
+
11026
+ var formatDate = function formatDate(date) {
11027
+ var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
11028
+
11029
+ // 处理多种输入类型
11030
+ if (!date) return '';
11031
+
11032
+ // 如果是时间戳,转成日期对象
11033
+ if (typeof date === 'number') {
11034
+ date = new Date(date);
11035
+ }
11036
+ // 如果是字符串,转成日期对象
11037
+ if (typeof date === 'string') {
11038
+ date = new Date(date);
11039
+ }
11040
+
11041
+ // 调用toDate进一步验证和转换
11042
+ date = toDate(date);
11043
+ if (!date) return '';
11044
+
11045
+ // 兼容大写和小写的格式标记
11046
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
11047
+ var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
11048
+
11049
+ // 使用fecha库进行格式化,支持中文配置
11050
+ var str = fecha.format(date, lowercaseFormat, getSettings());
11051
+ return str;
11052
+ };
11053
+
11054
+ var parseDate = function parseDate(string, format) {
11055
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
11056
+ };
11057
+
11058
+ var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
11059
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
11060
+ return 30;
11061
+ }
11062
+
11063
+ if (month === 1) {
11064
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
11065
+ return 29;
11066
+ } else {
11067
+ return 28;
11068
+ }
11069
+ }
11070
+
11071
+ return 31;
11072
+ };
11073
+
11074
+ var getDayCountOfYear = function getDayCountOfYear(year) {
11075
+ var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
11076
+ return isLeapYear ? 366 : 365;
11077
+ };
11078
+
11079
+ var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
11080
+ var temp = new Date(date.getTime());
11081
+ temp.setDate(1);
11082
+ return temp.getDay();
11083
+ };
11084
+
11085
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
11086
+ // {prev, next} Date should work for Daylight Saving Time
11087
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
11088
+ var prevDate = function prevDate(date) {
11089
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
11090
+
11091
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
11092
+ };
11093
+
11094
+ var nextDate = function nextDate(date) {
11095
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
11096
+
11097
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
11098
+ };
11099
+
11100
+ var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
11101
+ var result = new Date(year, month, 1);
11102
+ var day = result.getDay();
11103
+
11104
+ if (day === 0) {
11105
+ return prevDate(result, 7);
11106
+ } else {
11107
+ return prevDate(result, day);
11108
+ }
11109
+ };
11110
+
11111
+ var getWeekNumber = function getWeekNumber(date) {
11112
+ // 支持多种输入类型
11113
+ if (!date || !isDate(date)) {
11114
+ date = new Date();
11115
+ }
11116
+ if (typeof date === 'string') {
11117
+ date = new Date(date);
11118
+ }
11119
+
11120
+ // 验证日期有效性
11121
+ if (!isDate(date)) return null;
11122
+
11123
+ var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
11124
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
11125
+ // 将星期日的星期数设为7
11126
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
11127
+ // 获取当年的第一天
11128
+ var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
11129
+ // 计算到最近的星期四的完整周数
11130
+ var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
11131
+ // 返回周数
11132
+ return weekNo;
11133
+ };
11134
+
11135
+ var getRangeHours = function getRangeHours(ranges) {
11136
+ var hours = [];
11137
+ var disabledHours = [];
11138
+
11139
+ (ranges || []).forEach(function (range) {
11140
+ var value = range.map(function (date) {
11141
+ return date.getHours();
11142
+ });
11143
+
11144
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
11145
+ });
11146
+
11147
+ if (disabledHours.length) {
11148
+ for (var i = 0; i < 24; i++) {
11149
+ hours[i] = disabledHours.indexOf(i) === -1;
11150
+ }
11151
+ } else {
11152
+ for (var _i = 0; _i < 24; _i++) {
11153
+ hours[_i] = false;
11154
+ }
11155
+ }
11156
+
11157
+ return hours;
11158
+ };
11159
+
11160
+ var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
11161
+ if (amount <= 0) return [];
11162
+ var temp = new Date(date.getTime());
11163
+ temp.setDate(0);
11164
+ var lastDay = temp.getDate();
11165
+ return range(amount).map(function (_, index) {
11166
+ return lastDay - (amount - index - 1);
11167
+ });
11168
+ };
11169
+
11170
+ var getMonthDays = function getMonthDays(date) {
11171
+ var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
11172
+ var days = temp.getDate();
11173
+ return range(days).map(function (_, index) {
11174
+ return index + 1;
11175
+ });
11176
+ };
11177
+
11178
+ function setRangeData(arr, start, end, value) {
11179
+ for (var i = start; i < end; i++) {
11180
+ arr[i] = value;
11181
+ }
11182
+ }
11183
+
11184
+ var getRangeMinutes = function getRangeMinutes(ranges, hour) {
11185
+ var minutes = new Array(60);
11186
+
11187
+ if (ranges.length > 0) {
11188
+ ranges.forEach(function (range) {
11189
+ var start = range[0];
11190
+ var end = range[1];
11191
+ var startHour = start.getHours();
11192
+ var startMinute = start.getMinutes();
11193
+ var endHour = end.getHours();
11194
+ var endMinute = end.getMinutes();
11195
+ if (startHour === hour && endHour !== hour) {
11196
+ setRangeData(minutes, startMinute, 60, true);
11197
+ } else if (startHour === hour && endHour === hour) {
11198
+ setRangeData(minutes, startMinute, endMinute + 1, true);
11199
+ } else if (startHour !== hour && endHour === hour) {
11200
+ setRangeData(minutes, 0, endMinute + 1, true);
11201
+ } else if (startHour < hour && endHour > hour) {
11202
+ setRangeData(minutes, 0, 60, true);
11203
+ }
11204
+ });
11205
+ } else {
11206
+ setRangeData(minutes, 0, 60, true);
11207
+ }
11208
+ return minutes;
11209
+ };
11210
+
11211
+ var range = function range(n) {
11212
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
11213
+ return Array.apply(null, { length: n }).map(function (_, n) {
11214
+ return n;
11215
+ });
11216
+ };
11217
+
11218
+ var modifyDate = function modifyDate(date, y, m, d) {
11219
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
11220
+ };
11221
+
11222
+ var modifyTime = function modifyTime(date, h, m, s) {
11223
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
11224
+ };
11225
+
11226
+ var modifyWithTimeString = function modifyWithTimeString(date, time) {
11227
+ if (date == null || !time) {
11228
+ return date;
11229
+ }
11230
+ time = parseDate(time, 'HH:mm:ss');
11231
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
11232
+ };
11233
+
11234
+ var clearTime = function clearTime(date) {
11235
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
11236
+ };
11237
+
11238
+ var clearMilliseconds = function clearMilliseconds(date) {
11239
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
11240
+ };
11241
+
11242
+ var limitTimeRange = function limitTimeRange(date, ranges) {
11243
+ var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
11244
+
11245
+ // TODO: refactory a more elegant solution
11246
+ if (ranges.length === 0) return date;
11247
+ var normalizeDate = function normalizeDate(date) {
11248
+ return fecha.parse(fecha.format(date, format), format);
11249
+ };
11250
+ var ndate = normalizeDate(date);
11251
+ var nranges = ranges.map(function (range) {
11252
+ return range.map(normalizeDate);
11253
+ });
11254
+ if (nranges.some(function (nrange) {
11255
+ return ndate >= nrange[0] && ndate <= nrange[1];
11256
+ })) return date;
11257
+
11258
+ var minDate = nranges[0][0];
11259
+ var maxDate = nranges[0][0];
11260
+
11261
+ nranges.forEach(function (nrange) {
11262
+ minDate = new Date(Math.min(nrange[0], minDate));
11263
+ maxDate = new Date(Math.max(nrange[1], minDate));
11264
+ });
11265
+
11266
+ var ret = ndate < minDate ? minDate : maxDate;
11267
+ // preserve Year/Month/Date
11268
+ return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
11269
+ };
11270
+
11271
+ var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
11272
+ var limitedDate = limitTimeRange(date, selectableRange, format);
11273
+ return limitedDate.getTime() === date.getTime();
11274
+ };
11275
+
11276
+ var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
11277
+ // clamp date to the number of days in `year`, `month`
11278
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
11279
+ var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
11280
+ return modifyDate(date, year, month, monthDate);
11281
+ };
11282
+
11283
+ var prevMonth = function prevMonth(date) {
11284
+ var year = date.getFullYear();
11285
+ var month = date.getMonth();
11286
+ return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
11287
+ };
11288
+
11289
+ var nextMonth = function nextMonth(date) {
11290
+ var year = date.getFullYear();
11291
+ var month = date.getMonth();
11292
+ return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
11293
+ };
11294
+
11295
+ var prevYear = function prevYear(date) {
11296
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
11297
+
11298
+ var year = date.getFullYear();
11299
+ var month = date.getMonth();
11300
+ return changeYearMonthAndClampDate(date, year - amount, month);
11301
+ };
11302
+
11303
+ var nextYear = function nextYear(date) {
11304
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
11305
+
11306
+ var year = date.getFullYear();
11307
+ var month = date.getMonth();
11308
+ return changeYearMonthAndClampDate(date, year + amount, month);
11309
+ };
11310
+
11311
+ var extractDateFormat = function extractDateFormat(format) {
11312
+ return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
11313
+ };
11314
+
11315
+ var extractTimeFormat = function extractTimeFormat(format) {
11316
+ return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
11317
+ };
11318
+
11319
+ var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
11320
+ return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
11321
+ };
11322
+
11341
11323
  /**
11342
11324
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
11343
11325
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
11344
11326
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
11345
11327
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
11346
11328
  * @returns {number} 工作日数量
11347
- */
11348
- const calculateNetworkDays = function (start_date, end_date, holidays = []) {
11349
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
11350
- throw new Error(
11351
- "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
11352
- );
11353
- }
11354
-
11355
- const startDateObj = new Date(start_date);
11356
- const endDateObj = new Date(end_date);
11357
-
11358
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
11359
- throw new Error(
11360
- "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
11361
- );
11362
- }
11363
-
11364
- if (startDateObj > endDateObj) {
11365
- throw new Error('Start date should be earlier than or equal to end date.');
11366
- }
11367
-
11368
- let workdays = 0;
11369
-
11370
- // Iterate through each day in the date range
11371
- for (
11372
- let currentDate = new Date(startDateObj);
11373
- currentDate <= endDateObj;
11374
- currentDate.setDate(currentDate.getDate() + 1)
11375
- ) {
11376
- // Check if the current day is a weekend (Saturday or Sunday)
11377
- const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
11378
-
11379
- // Check if the current day is a holiday
11380
- const isHoliday = holidays.some((holiday) => {
11381
- const holidayDate = new Date(holiday);
11382
- return currentDate.toDateString() === holidayDate.toDateString();
11383
- });
11384
-
11385
- // If it's a workday (not a weekend or holiday), increment the workdays count
11386
- if (!isWeekend && !isHoliday) {
11387
- workdays++;
11388
- }
11389
- }
11390
-
11391
- return workdays;
11392
- };
11393
-
11329
+ */
11330
+ var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
11331
+ var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
11332
+
11333
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
11334
+ throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
11335
+ }
11336
+
11337
+ var startDateObj = new Date(start_date);
11338
+ var endDateObj = new Date(end_date);
11339
+
11340
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
11341
+ throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
11342
+ }
11343
+
11344
+ if (startDateObj > endDateObj) {
11345
+ throw new Error('Start date should be earlier than or equal to end date.');
11346
+ }
11347
+
11348
+ var workdays = 0;
11349
+
11350
+ // Iterate through each day in the date range
11351
+
11352
+ var _loop = function _loop(currentDate) {
11353
+ // Check if the current day is a weekend (Saturday or Sunday)
11354
+ var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
11355
+
11356
+ // Check if the current day is a holiday
11357
+ var isHoliday = holidays.some(function (holiday) {
11358
+ var holidayDate = new Date(holiday);
11359
+ return currentDate.toDateString() === holidayDate.toDateString();
11360
+ });
11361
+
11362
+ // If it's a workday (not a weekend or holiday), increment the workdays count
11363
+ if (!isWeekend && !isHoliday) {
11364
+ workdays++;
11365
+ }
11366
+ };
11367
+
11368
+ for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
11369
+ _loop(currentDate);
11370
+ }
11371
+
11372
+ return workdays;
11373
+ };
11374
+
11394
11375
  /**
11395
11376
  * 日期加减天数
11396
11377
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
11397
11378
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
11398
11379
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
11399
- */
11400
- const dateAddDays = function (start_date, days) {
11401
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
11402
- throw new Error(
11403
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
11404
- );
11405
- }
11406
-
11407
- const startDateObj = new Date(start_date);
11408
- if (isNaN(startDateObj.getTime())) {
11409
- throw new Error(
11410
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
11411
- );
11412
- }
11413
-
11414
- const resultDateObj = new Date(startDateObj);
11415
- resultDateObj.setDate(resultDateObj.getDate() + days);
11416
-
11417
- const resultYear = resultDateObj.getFullYear();
11418
- const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
11419
- const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
11420
-
11421
- return `${resultYear}-${resultMonth}-${resultDay}`;
11422
- };
11423
-
11380
+ */
11381
+ var dateAddDays = function dateAddDays(start_date, days) {
11382
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
11383
+ 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.");
11384
+ }
11385
+
11386
+ var startDateObj = new Date(start_date);
11387
+ if (isNaN(startDateObj.getTime())) {
11388
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
11389
+ }
11390
+
11391
+ var resultDateObj = new Date(startDateObj);
11392
+ resultDateObj.setDate(resultDateObj.getDate() + days);
11393
+
11394
+ var resultYear = resultDateObj.getFullYear();
11395
+ var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
11396
+ var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
11397
+
11398
+ return resultYear + '-' + resultMonth + '-' + resultDay;
11399
+ };
11400
+
11424
11401
  /**
11425
11402
  * 计算两个日期之间的差值
11426
11403
  * @date 2023年12月14日
@@ -11428,182 +11405,180 @@ const dateAddDays = function (start_date, days) {
11428
11405
  * @param {String} end_date - 结束日期字符串
11429
11406
  * @param {String} unit - 单位:year/month/day
11430
11407
  * @returns {Number} 差值
11431
- */
11432
- const dateDiff = function (start_date, end_date, unit = 'day') {
11433
- // Assuming date strings are in "YYYY-MM-DD" format
11434
- var startDate = new Date(start_date);
11435
- var endDate = new Date(end_date);
11436
-
11437
- // If the date is invalid, return 0
11438
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
11439
- return 0;
11440
- }
11441
-
11442
- if (unit === 'year') {
11443
- return endDate.getFullYear() - startDate.getFullYear();
11444
- } else if (unit === 'month') {
11445
- return (
11446
- (endDate.getFullYear() - startDate.getFullYear()) * 12 +
11447
- (endDate.getMonth() - startDate.getMonth())
11448
- );
11449
- } else {
11450
- // Default to day
11451
- var timeDifference = endDate - startDate;
11452
- // Calculate days (86400000 milliseconds per day)
11453
- return Math.floor(timeDifference / 86400000);
11454
- }
11455
- };
11456
-
11408
+ */
11409
+ var dateDiff = function dateDiff(start_date, end_date) {
11410
+ var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
11411
+
11412
+ // Assuming date strings are in "YYYY-MM-DD" format
11413
+ var startDate = new Date(start_date);
11414
+ var endDate = new Date(end_date);
11415
+
11416
+ // If the date is invalid, return 0
11417
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
11418
+ return 0;
11419
+ }
11420
+
11421
+ if (unit === 'year') {
11422
+ return endDate.getFullYear() - startDate.getFullYear();
11423
+ } else if (unit === 'month') {
11424
+ return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
11425
+ } else {
11426
+ // Default to day
11427
+ var timeDifference = endDate - startDate;
11428
+ // Calculate days (86400000 milliseconds per day)
11429
+ return Math.floor(timeDifference / 86400000);
11430
+ }
11431
+ };
11432
+
11457
11433
  /**
11458
11434
  * 获取月份中的日期
11459
11435
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
11460
11436
  * @returns {number} 月份中的日期(1-31)
11461
- */
11462
- const dayOfMonth = function (date) {
11463
- if (typeof date !== 'string') {
11464
- throw new Error(
11465
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
11466
- );
11467
- }
11468
-
11469
- const dateObj = new Date(date);
11470
- if (isNaN(dateObj.getTime())) {
11471
- throw new Error(
11472
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
11473
- );
11474
- }
11475
-
11476
- return dateObj.getDate();
11477
- };
11478
-
11437
+ */
11438
+ var dayOfMonth = function dayOfMonth(date) {
11439
+ if (typeof date !== 'string') {
11440
+ throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
11441
+ }
11442
+
11443
+ var dateObj = new Date(date);
11444
+ if (isNaN(dateObj.getTime())) {
11445
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
11446
+ }
11447
+
11448
+ return dateObj.getDate();
11449
+ };
11450
+
11479
11451
  /**
11480
11452
  * 获取当前日期
11481
11453
  * @date 2022年5月7日
11482
11454
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
11483
11455
  * @returns {string} 当前日期的格式化字符串
11484
- */
11485
- const getCurrentDate = function (format = 'YYYY-MM-DD') {
11486
- return formatDate(new Date(), format);
11487
- };
11488
-
11456
+ */
11457
+ var getCurrentDate = function getCurrentDate() {
11458
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
11459
+
11460
+ return formatDate(new Date(), format);
11461
+ };
11462
+
11489
11463
  /**
11490
11464
  * 获取当前日期时间
11491
11465
  * @date 2022年5月7日
11492
11466
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
11493
11467
  * @returns {string} 当前日期时间的格式化字符串
11494
- */
11495
- const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
11496
- return formatDate(new Date(), format);
11497
- };
11498
-
11468
+ */
11469
+ var getCurrentDateTime = function getCurrentDateTime() {
11470
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
11471
+
11472
+ return formatDate(new Date(), format);
11473
+ };
11474
+
11499
11475
  /**
11500
11476
  * 获取小时
11501
11477
  * @date 2022年5月7日
11502
11478
  * @param {Date|string} [date] - 日期对象或日期字符串
11503
11479
  * @returns {number} 小时数(0-23)
11504
- */
11505
- const getHour = function (date) {
11506
- if (!date) {
11507
- return new Date().getHours();
11508
- }
11509
- if (typeof date === 'string') {
11510
- date = new Date(date);
11511
- }
11512
- return date.getHours();
11513
- };
11514
-
11480
+ */
11481
+ var getHour = function getHour(date) {
11482
+ if (!date) {
11483
+ return new Date().getHours();
11484
+ }
11485
+ if (typeof date === 'string') {
11486
+ date = new Date(date);
11487
+ }
11488
+ return date.getHours();
11489
+ };
11490
+
11515
11491
  /**
11516
11492
  * 获取分钟
11517
11493
  * @date 2022年5月7日
11518
11494
  * @param {Date|string} [date] - 日期对象或日期字符串
11519
11495
  * @returns {number} 分钟数(0-59)
11520
- */
11521
- const getMinute = function (date) {
11522
- if (!date) {
11523
- return new Date().getMinutes();
11524
- }
11525
- if (typeof date === 'string') {
11526
- date = new Date(date);
11527
- }
11528
- return date.getMinutes();
11529
- };
11530
-
11496
+ */
11497
+ var getMinute = function getMinute(date) {
11498
+ if (!date) {
11499
+ return new Date().getMinutes();
11500
+ }
11501
+ if (typeof date === 'string') {
11502
+ date = new Date(date);
11503
+ }
11504
+ return date.getMinutes();
11505
+ };
11506
+
11531
11507
  /**
11532
11508
  * 获取月份
11533
11509
  * @date 2022年5月7日
11534
11510
  * @param {Date|string} [date] - 日期对象或日期字符串
11535
11511
  * @returns {number} 月份数(1-12)
11536
- */
11537
- const getMonth = function (date) {
11538
- if (!date) {
11539
- return new Date().getMonth() + 1;
11540
- }
11541
- if (typeof date === 'string') {
11542
- date = new Date(date);
11543
- }
11544
- return date.getMonth() + 1;
11545
- };
11546
-
11512
+ */
11513
+ var getMonth = function getMonth(date) {
11514
+ if (!date) {
11515
+ return new Date().getMonth() + 1;
11516
+ }
11517
+ if (typeof date === 'string') {
11518
+ date = new Date(date);
11519
+ }
11520
+ return date.getMonth() + 1;
11521
+ };
11522
+
11547
11523
  /**
11548
11524
  * 获取秒
11549
11525
  * @date 2022年5月7日
11550
11526
  * @param {Date|string} [date] - 日期对象或日期字符串
11551
11527
  * @returns {number} 秒数(0-59)
11552
- */
11553
- const getSecond = function (date) {
11554
- if (!date) {
11555
- return new Date().getSeconds();
11556
- }
11557
- if (typeof date === 'string') {
11558
- date = new Date(date);
11559
- }
11560
- return date.getSeconds();
11561
- };
11562
-
11528
+ */
11529
+ var getSecond = function getSecond(date) {
11530
+ if (!date) {
11531
+ return new Date().getSeconds();
11532
+ }
11533
+ if (typeof date === 'string') {
11534
+ date = new Date(date);
11535
+ }
11536
+ return date.getSeconds();
11537
+ };
11538
+
11563
11539
  /**
11564
11540
  * 获取星期几
11565
11541
  * @date 2022年5月7日
11566
11542
  * @param {Date|string} [date] - 日期对象或日期字符串
11567
11543
  * @returns {number} 星期几(0-6,0表示星期日)
11568
- */
11569
- const getWeekday = function (date) {
11570
- if (!date) {
11571
- return new Date().getDay();
11572
- }
11573
- if (typeof date === 'string') {
11574
- date = new Date(date);
11575
- }
11576
- return date.getDay();
11577
- };
11578
-
11579
-
11544
+ */
11545
+ var getWeekday = function getWeekday(date) {
11546
+ if (!date) {
11547
+ return new Date().getDay();
11548
+ }
11549
+ if (typeof date === 'string') {
11550
+ date = new Date(date);
11551
+ }
11552
+ return date.getDay();
11553
+ };
11554
+
11580
11555
  /**
11581
11556
  * @desc 获取上午/下午/晚上
11582
11557
  * @author huangbo
11583
11558
  * @date 2022年5月7日
11584
11559
  * @param {String} [time] - 时间
11585
- **/
11586
- const timeCycle = function (time) {
11587
- let hour = 0;
11588
- if (!time) {
11589
- hour = new Date().getHours();
11590
- } else if (typeof time === 'string') {
11591
- // 从时间字符串中提取小时
11592
- const match = time.match(/^(\d{1,2})/);
11593
- if (match) {
11594
- hour = parseInt(match[1], 10);
11595
- }
11596
- } else if (typeof time === 'number') {
11597
- hour = time;
11598
- }
11599
- // 判断时间段
11600
- if (hour >= 5 && hour < 12) {
11601
- return '上午';
11602
- } else if (hour >= 12 && hour < 18) {
11603
- return '下午';
11604
- } else {
11605
- return '晚上';
11606
- }
11560
+ **/
11561
+ var timeCycle = function timeCycle(time) {
11562
+ var hour = 0;
11563
+ if (!time) {
11564
+ hour = new Date().getHours();
11565
+ } else if (typeof time === 'string') {
11566
+ // 从时间字符串中提取小时
11567
+ var match = time.match(/^(\d{1,2})/);
11568
+ if (match) {
11569
+ hour = parseInt(match[1], 10);
11570
+ }
11571
+ } else if (typeof time === 'number') {
11572
+ hour = time;
11573
+ }
11574
+ // 判断时间段
11575
+ if (hour >= 5 && hour < 12) {
11576
+ return '上午';
11577
+ } else if (hour >= 12 && hour < 18) {
11578
+ return '下午';
11579
+ } else {
11580
+ return '晚上';
11581
+ }
11607
11582
  };
11608
11583
 
11609
11584
  /***/ }),