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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/lib/0.js +1 -1
  2. package/lib/1.js +1 -1
  3. package/lib/10.js +1 -1
  4. package/lib/11.js +1 -1
  5. package/lib/12.js +1 -1
  6. package/lib/13.js +1 -1
  7. package/lib/14.js +1 -1
  8. package/lib/15.js +1 -1
  9. package/lib/16.js +1 -1
  10. package/lib/17.js +1 -1
  11. package/lib/18.js +1 -1
  12. package/lib/19.js +1 -1
  13. package/lib/20.js +1 -1
  14. package/lib/21.js +1 -1
  15. package/lib/22.js +1 -1
  16. package/lib/23.js +1 -1
  17. package/lib/24.js +1 -1
  18. package/lib/25.js +1 -1
  19. package/lib/26.js +1 -1
  20. package/lib/27.js +1 -1
  21. package/lib/28.js +1 -1
  22. package/lib/29.js +1 -1
  23. package/lib/3.js +1 -1
  24. package/lib/30.js +1 -1
  25. package/lib/31.js +1 -1
  26. package/lib/32.js +1 -1
  27. package/lib/33.js +1 -1
  28. package/lib/34.js +1 -1
  29. package/lib/35.js +1 -1
  30. package/lib/36.js +1 -1
  31. package/lib/37.js +1 -1
  32. package/lib/38.js +1 -1
  33. package/lib/39.js +1 -1
  34. package/lib/4.js +1 -1
  35. package/lib/40.js +1 -1
  36. package/lib/41.js +1 -1
  37. package/lib/42.js +1 -1
  38. package/lib/43.js +1 -1
  39. package/lib/44.js +1 -1
  40. package/lib/45.js +1 -1
  41. package/lib/46.js +1 -1
  42. package/lib/47.js +1 -1
  43. package/lib/48.js +1 -1
  44. package/lib/49.js +1 -1
  45. package/lib/5.js +1 -1
  46. package/lib/50.js +1 -1
  47. package/lib/51.js +1 -1
  48. package/lib/52.js +1 -1
  49. package/lib/53.js +1 -1
  50. package/lib/54.js +1 -1
  51. package/lib/55.js +1 -1
  52. package/lib/56.js +1 -1
  53. package/lib/57.js +1 -1
  54. package/lib/58.js +1 -1
  55. package/lib/59.js +1 -1
  56. package/lib/6.js +1 -1
  57. package/lib/60.js +1 -1
  58. package/lib/61.js +1 -1
  59. package/lib/62.js +1 -1
  60. package/lib/63.js +1 -1
  61. package/lib/64.js +1 -1
  62. package/lib/65.js +1 -1
  63. package/lib/66.js +1 -1
  64. package/lib/67.js +1 -1
  65. package/lib/68.js +1 -1
  66. package/lib/69.js +1 -1
  67. package/lib/7.js +1 -1
  68. package/lib/70.js +1 -1
  69. package/lib/71.js +1 -1
  70. package/lib/72.js +1 -1
  71. package/lib/73.js +1 -1
  72. package/lib/74.js +1 -1
  73. package/lib/75.js +1 -1
  74. package/lib/76.js +1 -1
  75. package/lib/77.js +1 -1
  76. package/lib/78.js +1 -1
  77. package/lib/79.js +1 -1
  78. package/lib/8.js +1 -1
  79. package/lib/80.js +1 -1
  80. package/lib/81.js +1 -1
  81. package/lib/9.js +1 -1
  82. package/lib/account-login.js +1101 -1035
  83. package/lib/alert.js +2 -2
  84. package/lib/aside.js +2 -2
  85. package/lib/audit-trajectory.js +150 -150
  86. package/lib/autocomplete.js +2095 -1871
  87. package/lib/avatar.js +2 -2
  88. package/lib/backtop.js +2 -2
  89. package/lib/badge.js +2 -2
  90. package/lib/breadcrumb-item.js +4 -4
  91. package/lib/breadcrumb.js +4 -4
  92. package/lib/button-group.js +4 -4
  93. package/lib/button.js +2 -2
  94. package/lib/ca-login.js +862 -837
  95. package/lib/calendar.js +864 -839
  96. package/lib/card.js +2 -2
  97. package/lib/carousel-item.js +864 -839
  98. package/lib/carousel.js +866 -841
  99. package/lib/cascader-panel.js +878 -853
  100. package/lib/cascader.js +2325 -2101
  101. package/lib/checkbox-button.js +4 -4
  102. package/lib/checkbox-group.js +1060 -1025
  103. package/lib/checkbox.js +6 -6
  104. package/lib/col.js +2 -2
  105. package/lib/collapse-item.js +920 -895
  106. package/lib/collapse.js +913 -888
  107. package/lib/color-picker.js +1155 -956
  108. package/lib/container.js +2 -2
  109. package/lib/cron.js +18 -18
  110. package/lib/data-table.js +1053 -1018
  111. package/lib/date-picker.js +2094 -1870
  112. package/lib/descriptions-item.js +144 -0
  113. package/lib/descriptions.js +561 -0
  114. package/lib/dialog.js +943 -918
  115. package/lib/divider.js +2 -2
  116. package/lib/drawer.js +12 -12
  117. package/lib/dropdown-item.js +6 -6
  118. package/lib/dropdown-menu.js +1157 -958
  119. package/lib/dropdown.js +870 -845
  120. package/lib/email-login.js +1047 -1012
  121. package/lib/empty.js +2 -2
  122. package/lib/eoss.common.js +3493 -2313
  123. package/lib/flip.js +2 -2
  124. package/lib/flow-group.js +876 -851
  125. package/lib/flow.js +1184 -1149
  126. package/lib/flows.js +1080 -1045
  127. package/lib/footer.js +2 -2
  128. package/lib/form-item.js +877 -852
  129. package/lib/form.js +1123 -1087
  130. package/lib/guide.js +2 -2
  131. package/lib/header.js +2 -2
  132. package/lib/icon.js +1009 -984
  133. package/lib/icons.js +6 -6
  134. package/lib/image-viewer.js +862 -837
  135. package/lib/image.js +4 -4
  136. package/lib/index.js +1 -1
  137. package/lib/infinite-scroll.js +2 -2
  138. package/lib/input-number.js +6 -6
  139. package/lib/input.js +870 -845
  140. package/lib/link.js +2 -2
  141. package/lib/loading.js +13 -13
  142. package/lib/login.js +1116 -1066
  143. package/lib/lowcode-view.js +1078 -1043
  144. package/lib/lowcode.js +1131 -1096
  145. package/lib/main.js +1185 -1148
  146. package/lib/marquee.js +862 -837
  147. package/lib/menu-item-group.js +20 -17
  148. package/lib/menu-item.js +8 -8
  149. package/lib/menu.js +2390 -2164
  150. package/lib/message-box.js +950 -925
  151. package/lib/message.js +941 -916
  152. package/lib/notification.js +962 -937
  153. package/lib/option-group.js +4 -4
  154. package/lib/option.js +871 -846
  155. package/lib/page-header.js +2 -2
  156. package/lib/pagination.js +866 -841
  157. package/lib/phone-login.js +1049 -1014
  158. package/lib/popconfirm.js +4 -4
  159. package/lib/popover.js +2100 -1876
  160. package/lib/process-config.js +1065 -1030
  161. package/lib/process-module.js +1053 -1018
  162. package/lib/process-rule.js +1062 -1027
  163. package/lib/progress.js +2 -2
  164. package/lib/qr-code.js +4 -4
  165. package/lib/qrcode-login.js +1052 -1017
  166. package/lib/radio-button.js +4 -4
  167. package/lib/radio-group.js +2608 -2573
  168. package/lib/radio.js +6 -6
  169. package/lib/rate.js +864 -839
  170. package/lib/retrial-auth.js +7063 -0
  171. package/lib/row.js +2 -2
  172. package/lib/scrollbar.js +868 -843
  173. package/lib/select.js +2591 -2357
  174. package/lib/selector-panel.js +2659 -2624
  175. package/lib/selector.js +1068 -1033
  176. package/lib/slider.js +6 -6
  177. package/lib/step.js +44 -44
  178. package/lib/steps.js +911 -886
  179. package/lib/submenu.js +1439 -1236
  180. package/lib/switch.js +866 -841
  181. package/lib/tab-pane.js +4 -4
  182. package/lib/table-column.js +936 -911
  183. package/lib/table.js +2318 -2084
  184. package/lib/tabs.js +866 -841
  185. package/lib/tag.js +2 -2
  186. package/lib/theme-chalk/base.css +1 -1
  187. package/lib/theme-chalk/descriptions.css +1 -1
  188. package/lib/theme-chalk/index.css +1 -1
  189. package/lib/theme-chalk/main.css +1 -1
  190. package/lib/theme-chalk/retrial-auth.css +1 -0
  191. package/lib/time-picker.js +2047 -1823
  192. package/lib/time-select.js +2041 -1817
  193. package/lib/timeline-item.js +2 -2
  194. package/lib/timeline.js +2 -2
  195. package/lib/tips.js +1047 -1012
  196. package/lib/toolbar.js +36 -17
  197. package/lib/tooltip.js +2080 -1856
  198. package/lib/transfer.js +881 -856
  199. package/lib/tree-group.js +1020 -995
  200. package/lib/tree.js +1062 -1027
  201. package/lib/update-history.js +151 -151
  202. package/lib/upload.js +1082 -1047
  203. package/lib/utils/ajax.js +5 -1
  204. package/lib/utils/popper.js +97 -48
  205. package/lib/wujie.js +866 -841
  206. package/package.json +1 -1
  207. package/packages/account-login/src/account-login.vue +29 -0
  208. package/packages/descriptions/index.js +8 -0
  209. package/packages/descriptions/src/index.js +181 -0
  210. package/packages/descriptions/src/item.js +30 -0
  211. package/packages/descriptions/src/row.js +120 -0
  212. package/packages/descriptions-item/index.js +8 -0
  213. package/packages/login/src/login.vue +8 -0
  214. package/packages/login/src/mixins.js +3 -1
  215. package/packages/main/src/minxs.js +1 -0
  216. package/packages/menu/src/menu.vue +0 -1
  217. package/packages/menu/src/mixins.js +4 -3
  218. package/packages/menu/src/submenu.vue +4 -4
  219. package/packages/retrial-auth/index.js +5 -0
  220. package/packages/retrial-auth/src/main.vue +300 -0
  221. package/packages/theme-chalk/src/base.scss +2 -1
  222. package/packages/theme-chalk/src/descriptions.scss +0 -1
  223. package/packages/theme-chalk/src/index.scss +3 -0
  224. package/packages/theme-chalk/src/retrial-auth.scss +38 -0
  225. package/packages/toolbar/src/toolbar.vue +5 -0
  226. package/src/index.js +336 -327
  227. package/src/utils/ajax.js +2 -1
  228. package/src/utils/popper.js +109 -70
@@ -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 = 210);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 213);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -3285,7 +3285,7 @@ var warning = function warning(content, _callback3) {
3285
3285
 
3286
3286
  /***/ }),
3287
3287
 
3288
- /***/ 10:
3288
+ /***/ 11:
3289
3289
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3290
3290
 
3291
3291
  "use strict";
@@ -3501,7 +3501,7 @@ if (!vue__WEBPACK_IMPORTED_MODULE_0___default.a.prototype.$isServer) {
3501
3501
  }
3502
3502
 
3503
3503
  /* harmony default export */ __webpack_exports__["a"] = (PopupManager);
3504
- /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(44)))
3504
+ /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(45)))
3505
3505
 
3506
3506
  /***/ }),
3507
3507
 
@@ -3741,29 +3741,7 @@ module.exports = require("vue");
3741
3741
 
3742
3742
  /***/ }),
3743
3743
 
3744
- /***/ 21:
3745
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
3746
-
3747
- "use strict";
3748
- /* harmony default export */ __webpack_exports__["a"] = (function (target) {
3749
- for (var i = 1, j = arguments.length; i < j; i++) {
3750
- var source = arguments[i] || {};
3751
- for (var prop in source) {
3752
- if (source.hasOwnProperty(prop)) {
3753
- var value = source[prop];
3754
- if (value !== undefined) {
3755
- target[prop] = value;
3756
- }
3757
- }
3758
- }
3759
- }
3760
-
3761
- return target;
3762
- });;
3763
-
3764
- /***/ }),
3765
-
3766
- /***/ 210:
3744
+ /***/ 213:
3767
3745
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3768
3746
 
3769
3747
  "use strict";
@@ -4125,13 +4103,13 @@ var component = Object(componentNormalizer["a" /* default */])(
4125
4103
 
4126
4104
  /* harmony default export */ var main = (component.exports);
4127
4105
  // EXTERNAL MODULE: ./src/utils/merge.js
4128
- var merge = __webpack_require__(21);
4106
+ var merge = __webpack_require__(22);
4129
4107
 
4130
4108
  // EXTERNAL MODULE: ./src/utils/popup/index.js
4131
- var popup = __webpack_require__(28);
4109
+ var popup = __webpack_require__(32);
4132
4110
 
4133
4111
  // EXTERNAL MODULE: ./src/utils/vdom.js
4134
- var vdom = __webpack_require__(93);
4112
+ var vdom = __webpack_require__(94);
4135
4113
 
4136
4114
  // CONCATENATED MODULE: ./packages/notification/src/main.js
4137
4115
  /**
@@ -4267,6 +4245,28 @@ main_Notification.closeAll = function () {
4267
4245
  /***/ 22:
4268
4246
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4269
4247
 
4248
+ "use strict";
4249
+ /* harmony default export */ __webpack_exports__["a"] = (function (target) {
4250
+ for (var i = 1, j = arguments.length; i < j; i++) {
4251
+ var source = arguments[i] || {};
4252
+ for (var prop in source) {
4253
+ if (source.hasOwnProperty(prop)) {
4254
+ var value = source[prop];
4255
+ if (value !== undefined) {
4256
+ target[prop] = value;
4257
+ }
4258
+ }
4259
+ }
4260
+ }
4261
+
4262
+ return target;
4263
+ });;
4264
+
4265
+ /***/ }),
4266
+
4267
+ /***/ 23:
4268
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
4269
+
4270
4270
  "use strict";
4271
4271
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return getScrollbarWidth; });
4272
4272
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return scrollIntoView; });
@@ -4409,17 +4409,84 @@ function scrollMove(wrap) {
4409
4409
 
4410
4410
  /***/ }),
4411
4411
 
4412
- /***/ 28:
4412
+ /***/ 3:
4413
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
4414
+
4415
+ "use strict";
4416
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return isString; });
4417
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return isObject; });
4418
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return isHtmlElement; });
4419
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return isFunction; });
4420
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return isUndefined; });
4421
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return isDefined; });
4422
+ /**
4423
+ * 检查一个值是否为字符串类型
4424
+ * @param {*} obj 要检查的值
4425
+ * @returns {boolean} 如果值为字符串则返回true,否则返回false
4426
+ */
4427
+ function isString(obj) {
4428
+ return Object.prototype.toString.call(obj) === '[object String]';
4429
+ }
4430
+
4431
+ /**
4432
+ * 检查一个值是否为对象类型
4433
+ * @param {*} obj 要检查的值
4434
+ * @returns {boolean} 如果值为对象则返回true,否则返回false
4435
+ */
4436
+ function isObject(obj) {
4437
+ return Object.prototype.toString.call(obj) === '[object Object]';
4438
+ }
4439
+
4440
+ /**
4441
+ * 检查一个节点是否为HTML元素
4442
+ * @param {Node} node 要检查的节点
4443
+ * @returns {boolean} 如果节点为HTML元素则返回true,否则返回false
4444
+ */
4445
+ function isHtmlElement(node) {
4446
+ return node && node.nodeType === Node.ELEMENT_NODE;
4447
+ }
4448
+
4449
+ /**
4450
+ * 检查一个值是否为函数类型
4451
+ * @param {*} functionToCheck 要检查的值
4452
+ * @returns {boolean} 如果值为函数则返回true,否则返回false
4453
+ */
4454
+ function isFunction(functionToCheck) {
4455
+ var getType = {};
4456
+ return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
4457
+ }
4458
+
4459
+ /**
4460
+ * 检查一个值是否为undefined
4461
+ * @param {*} val 要检查的值
4462
+ * @returns {boolean} 如果值为undefined则返回true,否则返回false
4463
+ */
4464
+ function isUndefined(val) {
4465
+ return val === void 0;
4466
+ }
4467
+
4468
+ /**
4469
+ * 检查一个值是否已定义(不是undefined或null)
4470
+ * @param {*} val 要检查的值
4471
+ * @returns {boolean} 如果值已定义则返回true,否则返回false
4472
+ */
4473
+ function isDefined(val) {
4474
+ return val !== undefined && val !== null;
4475
+ }
4476
+
4477
+ /***/ }),
4478
+
4479
+ /***/ 32:
4413
4480
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4414
4481
 
4415
4482
  "use strict";
4416
4483
  /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
4417
4484
  /* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(vue__WEBPACK_IMPORTED_MODULE_0__);
4418
- /* harmony import */ var eoss_src_utils_merge__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(21);
4419
- /* harmony import */ var eoss_src_utils_popup_popup_manager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(10);
4485
+ /* harmony import */ var eoss_src_utils_merge__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(22);
4486
+ /* harmony import */ var eoss_src_utils_popup_popup_manager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(11);
4420
4487
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "a", function() { return eoss_src_utils_popup_popup_manager__WEBPACK_IMPORTED_MODULE_2__["a"]; });
4421
4488
 
4422
- /* harmony import */ var _scrollbar__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(22);
4489
+ /* harmony import */ var _scrollbar__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(23);
4423
4490
  /* harmony import */ var _dom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5);
4424
4491
 
4425
4492
 
@@ -4648,73 +4715,6 @@ var scrollBarWidth = void 0;
4648
4715
 
4649
4716
 
4650
4717
 
4651
- /***/ }),
4652
-
4653
- /***/ 3:
4654
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
4655
-
4656
- "use strict";
4657
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return isString; });
4658
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return isObject; });
4659
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return isHtmlElement; });
4660
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return isFunction; });
4661
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return isUndefined; });
4662
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return isDefined; });
4663
- /**
4664
- * 检查一个值是否为字符串类型
4665
- * @param {*} obj 要检查的值
4666
- * @returns {boolean} 如果值为字符串则返回true,否则返回false
4667
- */
4668
- function isString(obj) {
4669
- return Object.prototype.toString.call(obj) === '[object String]';
4670
- }
4671
-
4672
- /**
4673
- * 检查一个值是否为对象类型
4674
- * @param {*} obj 要检查的值
4675
- * @returns {boolean} 如果值为对象则返回true,否则返回false
4676
- */
4677
- function isObject(obj) {
4678
- return Object.prototype.toString.call(obj) === '[object Object]';
4679
- }
4680
-
4681
- /**
4682
- * 检查一个节点是否为HTML元素
4683
- * @param {Node} node 要检查的节点
4684
- * @returns {boolean} 如果节点为HTML元素则返回true,否则返回false
4685
- */
4686
- function isHtmlElement(node) {
4687
- return node && node.nodeType === Node.ELEMENT_NODE;
4688
- }
4689
-
4690
- /**
4691
- * 检查一个值是否为函数类型
4692
- * @param {*} functionToCheck 要检查的值
4693
- * @returns {boolean} 如果值为函数则返回true,否则返回false
4694
- */
4695
- function isFunction(functionToCheck) {
4696
- var getType = {};
4697
- return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
4698
- }
4699
-
4700
- /**
4701
- * 检查一个值是否为undefined
4702
- * @param {*} val 要检查的值
4703
- * @returns {boolean} 如果值为undefined则返回true,否则返回false
4704
- */
4705
- function isUndefined(val) {
4706
- return val === void 0;
4707
- }
4708
-
4709
- /**
4710
- * 检查一个值是否已定义(不是undefined或null)
4711
- * @param {*} val 要检查的值
4712
- * @returns {boolean} 如果值已定义则返回true,否则返回false
4713
- */
4714
- function isDefined(val) {
4715
- return val !== undefined && val !== null;
4716
- }
4717
-
4718
4718
  /***/ }),
4719
4719
 
4720
4720
  /***/ 4:
@@ -4822,7 +4822,7 @@ function normalizeComponent(
4822
4822
 
4823
4823
  /***/ }),
4824
4824
 
4825
- /***/ 44:
4825
+ /***/ 45:
4826
4826
  /***/ (function(module, exports) {
4827
4827
 
4828
4828
  var g;
@@ -5158,736 +5158,759 @@ function insertAfter(newEl, targetEl) {
5158
5158
  /* unused harmony export getSecond */
5159
5159
  /* unused harmony export getWeekday */
5160
5160
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
5161
-
5162
-
5161
+ /* Modified from https://github.com/taylorhakes/fecha
5162
+ *
5163
+ * The MIT License (MIT)
5164
+ *
5165
+ * Copyright (c) 2015 Taylor Hakes
5166
+ *
5167
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5168
+ * of this software and associated documentation files (the "Software"), to deal
5169
+ * in the Software without restriction, including without limitation the rights
5170
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5171
+ * copies of the Software, and to permit persons to whom the Software is
5172
+ * furnished to do so, subject to the following conditions:
5173
+ *
5174
+ * The above copyright notice and this permission notice shall be included in all
5175
+ * copies or substantial portions of the Software.
5176
+ *
5177
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5178
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5179
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5180
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5181
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5182
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
5183
+ * SOFTWARE.
5184
+ */
5185
+
5186
+ /*eslint-disable*/
5187
+ // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
5188
+
5189
+
5163
5190
  /**
5164
5191
  * Parse or format dates
5165
5192
  * @class fecha
5166
- */
5167
- var fecha = {};
5168
- var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
5169
- var twoDigits = '\\d\\d?';
5170
- var threeDigits = '\\d{3}';
5171
- var fourDigits = '\\d{4}';
5172
- var word = '[^\\s]+';
5173
- var literal = /\[([^]*?)\]/gm;
5174
- var noop = function noop() {};
5175
-
5176
- function regexEscape(str) {
5177
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
5178
- }
5179
-
5180
- function shorten(arr, sLen) {
5181
- var newArr = [];
5182
- for (var i = 0, len = arr.length; i < len; i++) {
5183
- newArr.push(arr[i].substr(0, sLen));
5184
- }
5185
- return newArr;
5186
- }
5187
-
5188
- function monthUpdate() {
5189
- return function (d, v) {
5190
- var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
5191
- if (~index) {
5192
- d.month = index;
5193
- }
5194
- };
5195
- }
5196
-
5197
- function pad(val, len) {
5198
- val = String(val);
5199
- len = len || 2;
5200
- while (val.length < len) {
5201
- val = '0' + val;
5202
- }
5203
- return val;
5204
- }
5205
-
5206
- // 直接使用中文日期名称常量
5207
- var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
5208
- var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
5209
- var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
5210
- var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
5211
- var amPm = ['上午', '下午'];
5212
- var DoFn = function DoFn(D) {
5213
- return D + '日';
5214
- };
5215
-
5216
- var formatFlags = {
5217
- D: function D(dateObj) {
5218
- return dateObj.getDay();
5219
- },
5220
- DD: function DD(dateObj) {
5221
- return pad(dateObj.getDay());
5222
- },
5223
- Do: function Do(dateObj) {
5224
- return DoFn(dateObj.getDate());
5225
- },
5226
- d: function d(dateObj) {
5227
- return dateObj.getDate();
5228
- },
5229
- dd: function dd(dateObj) {
5230
- return pad(dateObj.getDate());
5231
- },
5232
- ddd: function ddd(dateObj) {
5233
- return dayNamesShort[dateObj.getDay()];
5234
- },
5235
- dddd: function dddd(dateObj) {
5236
- return dayNames[dateObj.getDay()];
5237
- },
5238
- M: function M(dateObj) {
5239
- return dateObj.getMonth() + 1;
5240
- },
5241
- MM: function MM(dateObj) {
5242
- return pad(dateObj.getMonth() + 1);
5243
- },
5244
- MMM: function MMM(dateObj) {
5245
- return monthNamesShort[dateObj.getMonth()];
5246
- },
5247
- MMMM: function MMMM(dateObj) {
5248
- return monthNames[dateObj.getMonth()];
5249
- },
5250
- yy: function yy(dateObj) {
5251
- return pad(String(dateObj.getFullYear()), 4).substr(2);
5252
- },
5253
- yyyy: function yyyy(dateObj) {
5254
- return pad(dateObj.getFullYear(), 4);
5255
- },
5256
- h: function h(dateObj) {
5257
- return dateObj.getHours() % 12 || 12;
5258
- },
5259
- hh: function hh(dateObj) {
5260
- return pad(dateObj.getHours() % 12 || 12);
5261
- },
5262
- H: function H(dateObj) {
5263
- return dateObj.getHours();
5264
- },
5265
- HH: function HH(dateObj) {
5266
- return pad(dateObj.getHours());
5267
- },
5268
- m: function m(dateObj) {
5269
- return dateObj.getMinutes();
5270
- },
5271
- mm: function mm(dateObj) {
5272
- return pad(dateObj.getMinutes());
5273
- },
5274
- s: function s(dateObj) {
5275
- return dateObj.getSeconds();
5276
- },
5277
- ss: function ss(dateObj) {
5278
- return pad(dateObj.getSeconds());
5279
- },
5280
- S: function S(dateObj) {
5281
- return Math.round(dateObj.getMilliseconds() / 100);
5282
- },
5283
- SS: function SS(dateObj) {
5284
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
5285
- },
5286
- SSS: function SSS(dateObj) {
5287
- return pad(dateObj.getMilliseconds(), 3);
5288
- },
5289
- a: function a(dateObj) {
5290
- return dateObj.getHours() < 12 ? '上午' : '下午';
5291
- },
5292
- A: function A(dateObj) {
5293
- return dateObj.getHours() < 12 ? '上午' : '下午';
5294
- },
5295
- ZZ: function ZZ(dateObj) {
5296
- var o = dateObj.getTimezoneOffset();
5297
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
5298
- }
5299
- };
5300
-
5301
- var parseFlags = {
5302
- d: [twoDigits, function (d, v) {
5303
- d.day = v;
5304
- }],
5305
- Do: [twoDigits + word, function (d, v) {
5306
- d.day = parseInt(v, 10);
5307
- }],
5308
- M: [twoDigits, function (d, v) {
5309
- d.month = v - 1;
5310
- }],
5311
- yy: [twoDigits, function (d, v) {
5312
- var da = new Date(),
5313
- cent = +('' + da.getFullYear()).substr(0, 2);
5314
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
5315
- }],
5316
- h: [twoDigits, function (d, v) {
5317
- d.hour = v;
5318
- }],
5319
- m: [twoDigits, function (d, v) {
5320
- d.minute = v;
5321
- }],
5322
- s: [twoDigits, function (d, v) {
5323
- d.second = v;
5324
- }],
5325
- yyyy: [fourDigits, function (d, v) {
5326
- d.year = v;
5327
- }],
5328
- S: ['\\d', function (d, v) {
5329
- d.millisecond = v * 100;
5330
- }],
5331
- SS: ['\\d{2}', function (d, v) {
5332
- d.millisecond = v * 10;
5333
- }],
5334
- SSS: [threeDigits, function (d, v) {
5335
- d.millisecond = v;
5336
- }],
5337
- D: [twoDigits, noop],
5338
- ddd: [word, noop],
5339
- MMM: [word, monthUpdate('monthNamesShort')],
5340
- MMMM: [word, monthUpdate('monthNames')],
5341
- a: [word, function (d, v) {
5342
- var val = v.toLowerCase();
5343
- if (val === '上午') {
5344
- d.isPm = false;
5345
- } else if (val === '下午') {
5346
- d.isPm = true;
5347
- }
5348
- }],
5349
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
5350
- var parts = (v + '').match(/([+-]|\d\d)/gi),
5351
- minutes = void 0;
5352
-
5353
- if (parts) {
5354
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
5355
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
5356
- }
5357
- }]
5358
- };
5359
- parseFlags.dd = parseFlags.d;
5360
- parseFlags.dddd = parseFlags.ddd;
5361
- parseFlags.DD = parseFlags.D;
5362
- parseFlags.mm = parseFlags.m;
5363
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
5364
- parseFlags.MM = parseFlags.M;
5365
- parseFlags.ss = parseFlags.s;
5366
- parseFlags.A = parseFlags.a;
5367
-
5368
- // Some common format strings
5369
- fecha.masks = {
5370
- default: 'ddd MMM dd yyyy HH:mm:ss',
5371
- shortDate: 'M/D/yy',
5372
- mediumDate: 'MMM d, yyyy',
5373
- longDate: 'MMMM d, yyyy',
5374
- fullDate: 'dddd, MMMM d, yyyy',
5375
- shortTime: 'HH:mm',
5376
- mediumTime: 'HH:mm:ss',
5377
- longTime: 'HH:mm:ss.SSS'
5378
- };
5379
-
5193
+ */
5194
+ const fecha = {};
5195
+ const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
5196
+ const twoDigits = '\\d\\d?';
5197
+ const threeDigits = '\\d{3}';
5198
+ const fourDigits = '\\d{4}';
5199
+ const word = '[^\\s]+';
5200
+ const literal = /\[([^]*?)\]/gm;
5201
+ const noop = function () {};
5202
+
5203
+ function regexEscape(str) {
5204
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
5205
+ }
5206
+
5207
+ function shorten(arr, sLen) {
5208
+ const newArr = [];
5209
+ for (let i = 0, len = arr.length; i < len; i++) {
5210
+ newArr.push(arr[i].substr(0, sLen));
5211
+ }
5212
+ return newArr;
5213
+ }
5214
+
5215
+ function monthUpdate() {
5216
+ return function (d, v) {
5217
+ const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
5218
+ if (~index) {
5219
+ d.month = index;
5220
+ }
5221
+ };
5222
+ }
5223
+
5224
+ function pad(val, len) {
5225
+ val = String(val);
5226
+ len = len || 2;
5227
+ while (val.length < len) {
5228
+ val = '0' + val;
5229
+ }
5230
+ return val;
5231
+ }
5232
+
5233
+ // 直接使用中文日期名称常量
5234
+ const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
5235
+ const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
5236
+ const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
5237
+ const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
5238
+ const amPm = ['上午', '下午'];
5239
+ const DoFn = function DoFn(D) {
5240
+ return D + '日';
5241
+ };
5242
+
5243
+ const formatFlags = {
5244
+ D: function(dateObj) {
5245
+ return dateObj.getDay();
5246
+ },
5247
+ DD: function(dateObj) {
5248
+ return pad(dateObj.getDay());
5249
+ },
5250
+ Do: function(dateObj) {
5251
+ return DoFn(dateObj.getDate());
5252
+ },
5253
+ d: function(dateObj) {
5254
+ return dateObj.getDate();
5255
+ },
5256
+ dd: function(dateObj) {
5257
+ return pad(dateObj.getDate());
5258
+ },
5259
+ ddd: function(dateObj) {
5260
+ return dayNamesShort[dateObj.getDay()];
5261
+ },
5262
+ dddd: function(dateObj) {
5263
+ return dayNames[dateObj.getDay()];
5264
+ },
5265
+ M: function(dateObj) {
5266
+ return dateObj.getMonth() + 1;
5267
+ },
5268
+ MM: function(dateObj) {
5269
+ return pad(dateObj.getMonth() + 1);
5270
+ },
5271
+ MMM: function(dateObj) {
5272
+ return monthNamesShort[dateObj.getMonth()];
5273
+ },
5274
+ MMMM: function(dateObj) {
5275
+ return monthNames[dateObj.getMonth()];
5276
+ },
5277
+ yy: function(dateObj) {
5278
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
5279
+ },
5280
+ yyyy: function(dateObj) {
5281
+ return pad(dateObj.getFullYear(), 4);
5282
+ },
5283
+ h: function(dateObj) {
5284
+ return dateObj.getHours() % 12 || 12;
5285
+ },
5286
+ hh: function(dateObj) {
5287
+ return pad(dateObj.getHours() % 12 || 12);
5288
+ },
5289
+ H: function(dateObj) {
5290
+ return dateObj.getHours();
5291
+ },
5292
+ HH: function(dateObj) {
5293
+ return pad(dateObj.getHours());
5294
+ },
5295
+ m: function(dateObj) {
5296
+ return dateObj.getMinutes();
5297
+ },
5298
+ mm: function(dateObj) {
5299
+ return pad(dateObj.getMinutes());
5300
+ },
5301
+ s: function(dateObj) {
5302
+ return dateObj.getSeconds();
5303
+ },
5304
+ ss: function(dateObj) {
5305
+ return pad(dateObj.getSeconds());
5306
+ },
5307
+ S: function(dateObj) {
5308
+ return Math.round(dateObj.getMilliseconds() / 100);
5309
+ },
5310
+ SS: function(dateObj) {
5311
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
5312
+ },
5313
+ SSS: function(dateObj) {
5314
+ return pad(dateObj.getMilliseconds(), 3);
5315
+ },
5316
+ a: function(dateObj) {
5317
+ return dateObj.getHours() < 12 ? '上午' : '下午';
5318
+ },
5319
+ A: function(dateObj) {
5320
+ return dateObj.getHours() < 12 ? '上午' : '下午';
5321
+ },
5322
+ ZZ: function(dateObj) {
5323
+ const o = dateObj.getTimezoneOffset();
5324
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
5325
+ }
5326
+ };
5327
+
5328
+ const parseFlags = {
5329
+ d: [twoDigits, function (d, v) {
5330
+ d.day = v;
5331
+ }],
5332
+ Do: [twoDigits + word, function (d, v) {
5333
+ d.day = parseInt(v, 10);
5334
+ }],
5335
+ M: [twoDigits, function (d, v) {
5336
+ d.month = v - 1;
5337
+ }],
5338
+ yy: [twoDigits, function (d, v) {
5339
+ const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
5340
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
5341
+ }],
5342
+ h: [twoDigits, function (d, v) {
5343
+ d.hour = v;
5344
+ }],
5345
+ m: [twoDigits, function (d, v) {
5346
+ d.minute = v;
5347
+ }],
5348
+ s: [twoDigits, function (d, v) {
5349
+ d.second = v;
5350
+ }],
5351
+ yyyy: [fourDigits, function (d, v) {
5352
+ d.year = v;
5353
+ }],
5354
+ S: ['\\d', function (d, v) {
5355
+ d.millisecond = v * 100;
5356
+ }],
5357
+ SS: ['\\d{2}', function (d, v) {
5358
+ d.millisecond = v * 10;
5359
+ }],
5360
+ SSS: [threeDigits, function (d, v) {
5361
+ d.millisecond = v;
5362
+ }],
5363
+ D: [twoDigits, noop],
5364
+ ddd: [word, noop],
5365
+ MMM: [word, monthUpdate('monthNamesShort')],
5366
+ MMMM: [word, monthUpdate('monthNames')],
5367
+ a: [word, function (d, v) {
5368
+ const val = v.toLowerCase();
5369
+ if (val === '上午') {
5370
+ d.isPm = false;
5371
+ } else if (val === '下午') {
5372
+ d.isPm = true;
5373
+ }
5374
+ }],
5375
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
5376
+ let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
5377
+
5378
+ if (parts) {
5379
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
5380
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
5381
+ }
5382
+ }]
5383
+ };
5384
+ parseFlags.dd = parseFlags.d;
5385
+ parseFlags.dddd = parseFlags.ddd;
5386
+ parseFlags.DD = parseFlags.D;
5387
+ parseFlags.mm = parseFlags.m;
5388
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
5389
+ parseFlags.MM = parseFlags.M;
5390
+ parseFlags.ss = parseFlags.s;
5391
+ parseFlags.A = parseFlags.a;
5392
+
5393
+
5394
+ // Some common format strings
5395
+ fecha.masks = {
5396
+ default: 'ddd MMM dd yyyy HH:mm:ss',
5397
+ shortDate: 'M/D/yy',
5398
+ mediumDate: 'MMM d, yyyy',
5399
+ longDate: 'MMMM d, yyyy',
5400
+ fullDate: 'dddd, MMMM d, yyyy',
5401
+ shortTime: 'HH:mm',
5402
+ mediumTime: 'HH:mm:ss',
5403
+ longTime: 'HH:mm:ss.SSS'
5404
+ };
5405
+
5380
5406
  /***
5381
5407
  * Format a date
5382
5408
  * @method format
5383
5409
  * @param {Date|number} dateObj
5384
5410
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
5385
- */
5386
- fecha.format = function (dateObj, mask) {
5387
- if (typeof dateObj === 'number') {
5388
- dateObj = new Date(dateObj);
5389
- }
5390
-
5391
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
5392
- throw new Error('Invalid Date in fecha.format');
5393
- }
5394
-
5395
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
5396
-
5397
- var literals = [];
5398
-
5399
- // Make literals inactive by replacing them with ??
5400
- mask = mask.replace(literal, function ($0, $1) {
5401
- literals.push($1);
5402
- return '@@@';
5403
- });
5404
- // Apply formatting rules
5405
- mask = mask.replace(token, function ($0) {
5406
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
5407
- });
5408
- // Inline literal values back into the formatted value
5409
- return mask.replace(/@@@/g, function () {
5410
- return literals.shift();
5411
- });
5412
- };
5413
-
5411
+ */
5412
+ fecha.format = function (dateObj, mask) {
5413
+ if (typeof dateObj === 'number') {
5414
+ dateObj = new Date(dateObj);
5415
+ }
5416
+
5417
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
5418
+ throw new Error('Invalid Date in fecha.format');
5419
+ }
5420
+
5421
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
5422
+
5423
+ const literals = [];
5424
+
5425
+ // Make literals inactive by replacing them with ??
5426
+ mask = mask.replace(literal, function($0, $1) {
5427
+ literals.push($1);
5428
+ return '@@@';
5429
+ });
5430
+ // Apply formatting rules
5431
+ mask = mask.replace(token, function ($0) {
5432
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
5433
+ });
5434
+ // Inline literal values back into the formatted value
5435
+ return mask.replace(/@@@/g, function() {
5436
+ return literals.shift();
5437
+ });
5438
+ };
5439
+
5414
5440
  /**
5415
5441
  * Parse a date string into an object, changes - into /
5416
5442
  * @method parse
5417
5443
  * @param {string} dateStr Date string
5418
5444
  * @param {string} format Date parse format
5419
5445
  * @returns {Date|boolean}
5420
- */
5421
- fecha.parse = function (dateStr, format) {
5422
- if (typeof format !== 'string') {
5423
- throw new Error('Invalid format in fecha.parse');
5424
- }
5425
-
5426
- format = fecha.masks[format] || format;
5427
-
5428
- // Avoid regular expression denial of service, fail early for really long strings
5429
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
5430
- if (dateStr.length > 1000) {
5431
- return null;
5432
- }
5433
-
5434
- var dateInfo = {};
5435
- var parseInfo = [];
5436
- var literals = [];
5437
- format = format.replace(literal, function ($0, $1) {
5438
- literals.push($1);
5439
- return '@@@';
5440
- });
5441
- var newFormat = regexEscape(format).replace(token, function ($0) {
5442
- if (parseFlags[$0]) {
5443
- var info = parseFlags[$0];
5444
- parseInfo.push(info[1]);
5445
- return '(' + info[0] + ')';
5446
- }
5447
-
5448
- return $0;
5449
- });
5450
- newFormat = newFormat.replace(/@@@/g, function () {
5451
- return literals.shift();
5452
- });
5453
- var matches = dateStr.match(new RegExp(newFormat, 'i'));
5454
- if (!matches) {
5455
- return null;
5456
- }
5457
-
5458
- for (var i = 1; i < matches.length; i++) {
5459
- parseInfo[i - 1](dateInfo, matches[i]);
5460
- }
5461
-
5462
- var today = new Date();
5463
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
5464
- dateInfo.hour = +dateInfo.hour + 12;
5465
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
5466
- dateInfo.hour = 0;
5467
- }
5468
-
5469
- var date = void 0;
5470
- if (dateInfo.timezoneOffset != null) {
5471
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
5472
- 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));
5473
- } else {
5474
- 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);
5475
- }
5476
- return date;
5477
- };
5478
-
5479
- // 导出fecha对象
5480
-
5481
-
5482
- // 以下是从date-util.js合并的函数
5483
- var newArray = function newArray(start, end) {
5484
- var result = [];
5485
- for (var i = start; i <= end; i++) {
5486
- result.push(i);
5487
- }
5488
- return result;
5489
- };
5490
-
5491
- var getSettings = function getSettings() {
5492
- return {
5493
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
5494
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
5495
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
5496
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
5497
- amPm: ['上午', '下午']
5498
- };
5499
- };
5500
-
5501
- var toDate = function toDate(date) {
5502
- return isDate(date) ? new Date(date) : null;
5503
- };
5504
-
5505
- var isDate = function isDate(date) {
5506
- if (date === null || date === undefined) return false;
5507
- if (isNaN(new Date(date).getTime())) return false;
5508
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
5509
- return true;
5510
- };
5511
-
5512
- var isDateObject = function isDateObject(val) {
5513
- return val instanceof Date;
5514
- };
5515
-
5516
- var formatDate = function formatDate(date) {
5517
- var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
5518
-
5519
- // 处理多种输入类型
5520
- if (!date) return '';
5521
-
5522
- // 如果是时间戳,转成日期对象
5523
- if (typeof date === 'number') {
5524
- date = new Date(date);
5525
- }
5526
- // 如果是字符串,转成日期对象
5527
- if (typeof date === 'string') {
5528
- date = new Date(date);
5529
- }
5530
-
5531
- // 调用toDate进一步验证和转换
5532
- date = toDate(date);
5533
- if (!date) return '';
5534
-
5535
- // 兼容大写和小写的格式标记
5536
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
5537
- var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
5538
-
5539
- // 使用fecha库进行格式化,支持中文配置
5540
- var str = fecha.format(date, lowercaseFormat, getSettings());
5541
- return str;
5542
- };
5543
-
5544
- var parseDate = function parseDate(string, format) {
5545
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
5546
- };
5547
-
5548
- var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
5549
- if (month === 3 || month === 5 || month === 8 || month === 10) {
5550
- return 30;
5551
- }
5552
-
5553
- if (month === 1) {
5554
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
5555
- return 29;
5556
- } else {
5557
- return 28;
5558
- }
5559
- }
5560
-
5561
- return 31;
5562
- };
5563
-
5564
- var getDayCountOfYear = function getDayCountOfYear(year) {
5565
- var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
5566
- return isLeapYear ? 366 : 365;
5567
- };
5568
-
5569
- var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
5570
- var temp = new Date(date.getTime());
5571
- temp.setDate(1);
5572
- return temp.getDay();
5573
- };
5574
-
5575
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
5576
- // {prev, next} Date should work for Daylight Saving Time
5577
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
5578
- var prevDate = function prevDate(date) {
5579
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5580
-
5581
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
5582
- };
5583
-
5584
- var nextDate = function nextDate(date) {
5585
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5586
-
5587
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
5588
- };
5589
-
5590
- var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
5591
- var result = new Date(year, month, 1);
5592
- var day = result.getDay();
5593
-
5594
- if (day === 0) {
5595
- return prevDate(result, 7);
5596
- } else {
5597
- return prevDate(result, day);
5598
- }
5599
- };
5600
-
5601
- var getWeekNumber = function getWeekNumber(date) {
5602
- // 支持多种输入类型
5603
- if (!date || !isDate(date)) {
5604
- date = new Date();
5605
- }
5606
- if (typeof date === 'string') {
5607
- date = new Date(date);
5608
- }
5609
-
5610
- // 验证日期有效性
5611
- if (!isDate(date)) return null;
5612
-
5613
- var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
5614
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
5615
- // 将星期日的星期数设为7
5616
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
5617
- // 获取当年的第一天
5618
- var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
5619
- // 计算到最近的星期四的完整周数
5620
- var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
5621
- // 返回周数
5622
- return weekNo;
5623
- };
5624
-
5625
- var getRangeHours = function getRangeHours(ranges) {
5626
- var hours = [];
5627
- var disabledHours = [];
5628
-
5629
- (ranges || []).forEach(function (range) {
5630
- var value = range.map(function (date) {
5631
- return date.getHours();
5632
- });
5633
-
5634
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
5635
- });
5636
-
5637
- if (disabledHours.length) {
5638
- for (var i = 0; i < 24; i++) {
5639
- hours[i] = disabledHours.indexOf(i) === -1;
5640
- }
5641
- } else {
5642
- for (var _i = 0; _i < 24; _i++) {
5643
- hours[_i] = false;
5644
- }
5645
- }
5646
-
5647
- return hours;
5648
- };
5649
-
5650
- var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
5651
- if (amount <= 0) return [];
5652
- var temp = new Date(date.getTime());
5653
- temp.setDate(0);
5654
- var lastDay = temp.getDate();
5655
- return range(amount).map(function (_, index) {
5656
- return lastDay - (amount - index - 1);
5657
- });
5658
- };
5659
-
5660
- var getMonthDays = function getMonthDays(date) {
5661
- var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
5662
- var days = temp.getDate();
5663
- return range(days).map(function (_, index) {
5664
- return index + 1;
5665
- });
5666
- };
5667
-
5668
- function setRangeData(arr, start, end, value) {
5669
- for (var i = start; i < end; i++) {
5670
- arr[i] = value;
5671
- }
5672
- }
5673
-
5674
- var getRangeMinutes = function getRangeMinutes(ranges, hour) {
5675
- var minutes = new Array(60);
5676
-
5677
- if (ranges.length > 0) {
5678
- ranges.forEach(function (range) {
5679
- var start = range[0];
5680
- var end = range[1];
5681
- var startHour = start.getHours();
5682
- var startMinute = start.getMinutes();
5683
- var endHour = end.getHours();
5684
- var endMinute = end.getMinutes();
5685
- if (startHour === hour && endHour !== hour) {
5686
- setRangeData(minutes, startMinute, 60, true);
5687
- } else if (startHour === hour && endHour === hour) {
5688
- setRangeData(minutes, startMinute, endMinute + 1, true);
5689
- } else if (startHour !== hour && endHour === hour) {
5690
- setRangeData(minutes, 0, endMinute + 1, true);
5691
- } else if (startHour < hour && endHour > hour) {
5692
- setRangeData(minutes, 0, 60, true);
5693
- }
5694
- });
5695
- } else {
5696
- setRangeData(minutes, 0, 60, true);
5697
- }
5698
- return minutes;
5699
- };
5700
-
5701
- var range = function range(n) {
5702
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
5703
- return Array.apply(null, { length: n }).map(function (_, n) {
5704
- return n;
5705
- });
5706
- };
5707
-
5708
- var modifyDate = function modifyDate(date, y, m, d) {
5709
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
5710
- };
5711
-
5712
- var modifyTime = function modifyTime(date, h, m, s) {
5713
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
5714
- };
5715
-
5716
- var modifyWithTimeString = function modifyWithTimeString(date, time) {
5717
- if (date == null || !time) {
5718
- return date;
5719
- }
5720
- time = parseDate(time, 'HH:mm:ss');
5721
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
5722
- };
5723
-
5724
- var clearTime = function clearTime(date) {
5725
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
5726
- };
5727
-
5728
- var clearMilliseconds = function clearMilliseconds(date) {
5729
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
5730
- };
5731
-
5732
- var limitTimeRange = function limitTimeRange(date, ranges) {
5733
- var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
5734
-
5735
- // TODO: refactory a more elegant solution
5736
- if (ranges.length === 0) return date;
5737
- var normalizeDate = function normalizeDate(date) {
5738
- return fecha.parse(fecha.format(date, format), format);
5739
- };
5740
- var ndate = normalizeDate(date);
5741
- var nranges = ranges.map(function (range) {
5742
- return range.map(normalizeDate);
5743
- });
5744
- if (nranges.some(function (nrange) {
5745
- return ndate >= nrange[0] && ndate <= nrange[1];
5746
- })) return date;
5747
-
5748
- var minDate = nranges[0][0];
5749
- var maxDate = nranges[0][0];
5750
-
5751
- nranges.forEach(function (nrange) {
5752
- minDate = new Date(Math.min(nrange[0], minDate));
5753
- maxDate = new Date(Math.max(nrange[1], minDate));
5754
- });
5755
-
5756
- var ret = ndate < minDate ? minDate : maxDate;
5757
- // preserve Year/Month/Date
5758
- return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
5759
- };
5760
-
5761
- var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
5762
- var limitedDate = limitTimeRange(date, selectableRange, format);
5763
- return limitedDate.getTime() === date.getTime();
5764
- };
5765
-
5766
- var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
5767
- // clamp date to the number of days in `year`, `month`
5768
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
5769
- var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
5770
- return modifyDate(date, year, month, monthDate);
5771
- };
5772
-
5773
- var prevMonth = function prevMonth(date) {
5774
- var year = date.getFullYear();
5775
- var month = date.getMonth();
5776
- return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
5777
- };
5778
-
5779
- var nextMonth = function nextMonth(date) {
5780
- var year = date.getFullYear();
5781
- var month = date.getMonth();
5782
- return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
5783
- };
5784
-
5785
- var prevYear = function prevYear(date) {
5786
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5787
-
5788
- var year = date.getFullYear();
5789
- var month = date.getMonth();
5790
- return changeYearMonthAndClampDate(date, year - amount, month);
5791
- };
5792
-
5793
- var nextYear = function nextYear(date) {
5794
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5795
-
5796
- var year = date.getFullYear();
5797
- var month = date.getMonth();
5798
- return changeYearMonthAndClampDate(date, year + amount, month);
5799
- };
5800
-
5801
- var extractDateFormat = function extractDateFormat(format) {
5802
- return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
5803
- };
5804
-
5805
- var extractTimeFormat = function extractTimeFormat(format) {
5806
- return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
5807
- };
5808
-
5809
- var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
5810
- return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
5811
- };
5812
-
5446
+ */
5447
+ fecha.parse = function (dateStr, format) {
5448
+ if (typeof format !== 'string') {
5449
+ throw new Error('Invalid format in fecha.parse');
5450
+ }
5451
+
5452
+ format = fecha.masks[format] || format;
5453
+
5454
+ // Avoid regular expression denial of service, fail early for really long strings
5455
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
5456
+ if (dateStr.length > 1000) {
5457
+ return null;
5458
+ }
5459
+
5460
+ const dateInfo = {};
5461
+ const parseInfo = [];
5462
+ const literals = [];
5463
+ format = format.replace(literal, function($0, $1) {
5464
+ literals.push($1);
5465
+ return '@@@';
5466
+ });
5467
+ let newFormat = regexEscape(format).replace(token, function ($0) {
5468
+ if (parseFlags[$0]) {
5469
+ const info = parseFlags[$0];
5470
+ parseInfo.push(info[1]);
5471
+ return '(' + info[0] + ')';
5472
+ }
5473
+
5474
+ return $0;
5475
+ });
5476
+ newFormat = newFormat.replace(/@@@/g, function() {
5477
+ return literals.shift();
5478
+ });
5479
+ const matches = dateStr.match(new RegExp(newFormat, 'i'));
5480
+ if (!matches) {
5481
+ return null;
5482
+ }
5483
+
5484
+ for (let i = 1; i < matches.length; i++) {
5485
+ parseInfo[i - 1](dateInfo, matches[i]);
5486
+ }
5487
+
5488
+ const today = new Date();
5489
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
5490
+ dateInfo.hour = +dateInfo.hour + 12;
5491
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
5492
+ dateInfo.hour = 0;
5493
+ }
5494
+
5495
+ let date;
5496
+ if (dateInfo.timezoneOffset != null) {
5497
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
5498
+ date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
5499
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
5500
+ } else {
5501
+ date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
5502
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
5503
+ }
5504
+ return date;
5505
+ };
5506
+
5507
+ // 导出fecha对象
5508
+
5509
+
5510
+ // 以下是从date-util.js合并的函数
5511
+ const newArray = function(start, end) {
5512
+ let result = [];
5513
+ for (let i = start; i <= end; i++) {
5514
+ result.push(i);
5515
+ }
5516
+ return result;
5517
+ };
5518
+
5519
+ const getSettings = () => {
5520
+ return {
5521
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
5522
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
5523
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
5524
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
5525
+ amPm: ['上午', '下午']
5526
+ };
5527
+ };
5528
+
5529
+ const toDate = function(date) {
5530
+ return isDate(date) ? new Date(date) : null;
5531
+ };
5532
+
5533
+ const isDate = function(date) {
5534
+ if (date === null || date === undefined) return false;
5535
+ if (isNaN(new Date(date).getTime())) return false;
5536
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
5537
+ return true;
5538
+ };
5539
+
5540
+ const isDateObject = function(val) {
5541
+ return val instanceof Date;
5542
+ };
5543
+
5544
+ const formatDate = function (date, format = 'yyyy-MM-dd') {
5545
+ // 处理多种输入类型
5546
+ if (!date) return '';
5547
+
5548
+ // 如果是时间戳,转成日期对象
5549
+ if (typeof date === 'number') {
5550
+ date = new Date(date);
5551
+ }
5552
+ // 如果是字符串,转成日期对象
5553
+ if (typeof date === 'string') {
5554
+ date = new Date(date);
5555
+ }
5556
+
5557
+ // 调用toDate进一步验证和转换
5558
+ date = toDate(date);
5559
+ if (!date) return '';
5560
+
5561
+ // 兼容大写和小写的格式标记
5562
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
5563
+ const lowercaseFormat = format
5564
+ .replace(/YYYY/g, 'yyyy')
5565
+ .replace(/D/g, 'd')
5566
+
5567
+ // 使用fecha库进行格式化,支持中文配置
5568
+ const str = fecha.format(date, lowercaseFormat, getSettings());
5569
+ return str;
5570
+ };
5571
+
5572
+ const parseDate = function(string, format) {
5573
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
5574
+ };
5575
+
5576
+ const getDayCountOfMonth = function(year, month) {
5577
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
5578
+ return 30;
5579
+ }
5580
+
5581
+ if (month === 1) {
5582
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
5583
+ return 29;
5584
+ } else {
5585
+ return 28;
5586
+ }
5587
+ }
5588
+
5589
+ return 31;
5590
+ };
5591
+
5592
+ const getDayCountOfYear = function(year) {
5593
+ const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
5594
+ return isLeapYear ? 366 : 365;
5595
+ };
5596
+
5597
+ const getFirstDayOfMonth = function(date) {
5598
+ const temp = new Date(date.getTime());
5599
+ temp.setDate(1);
5600
+ return temp.getDay();
5601
+ };
5602
+
5603
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
5604
+ // {prev, next} Date should work for Daylight Saving Time
5605
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
5606
+ const prevDate = function(date, amount = 1) {
5607
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
5608
+ };
5609
+
5610
+ const nextDate = function(date, amount = 1) {
5611
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
5612
+ };
5613
+
5614
+ const getStartDateOfMonth = function(year, month) {
5615
+ const result = new Date(year, month, 1);
5616
+ const day = result.getDay();
5617
+
5618
+ if (day === 0) {
5619
+ return prevDate(result, 7);
5620
+ } else {
5621
+ return prevDate(result, day);
5622
+ }
5623
+ };
5624
+
5625
+ const getWeekNumber = function(date) {
5626
+ // 支持多种输入类型
5627
+ if (!date||!isDate(date)) {
5628
+ date = new Date();
5629
+ }
5630
+ if (typeof date === 'string') {
5631
+ date = new Date(date);
5632
+ }
5633
+
5634
+ // 验证日期有效性
5635
+ if (!isDate(date)) return null;
5636
+
5637
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
5638
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
5639
+ // 将星期日的星期数设为7
5640
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
5641
+ // 获取当年的第一天
5642
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
5643
+ // 计算到最近的星期四的完整周数
5644
+ const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
5645
+ // 返回周数
5646
+ return weekNo;
5647
+ };
5648
+
5649
+ const getRangeHours = function(ranges) {
5650
+ const hours = [];
5651
+ let disabledHours = [];
5652
+
5653
+ (ranges || []).forEach(range => {
5654
+ const value = range.map(date => date.getHours());
5655
+
5656
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
5657
+ });
5658
+
5659
+ if (disabledHours.length) {
5660
+ for (let i = 0; i < 24; i++) {
5661
+ hours[i] = disabledHours.indexOf(i) === -1;
5662
+ }
5663
+ } else {
5664
+ for (let i = 0; i < 24; i++) {
5665
+ hours[i] = false;
5666
+ }
5667
+ }
5668
+
5669
+ return hours;
5670
+ };
5671
+
5672
+ const getPrevMonthLastDays = (date, amount) => {
5673
+ if (amount <= 0) return [];
5674
+ const temp = new Date(date.getTime());
5675
+ temp.setDate(0);
5676
+ const lastDay = temp.getDate();
5677
+ return range(amount).map((_, index) => lastDay - (amount - index - 1));
5678
+ };
5679
+
5680
+ const getMonthDays = (date) => {
5681
+ const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
5682
+ const days = temp.getDate();
5683
+ return range(days).map((_, index) => index + 1);
5684
+ };
5685
+
5686
+ function setRangeData(arr, start, end, value) {
5687
+ for (let i = start; i < end; i++) {
5688
+ arr[i] = value;
5689
+ }
5690
+ }
5691
+
5692
+ const getRangeMinutes = function(ranges, hour) {
5693
+ const minutes = new Array(60);
5694
+
5695
+ if (ranges.length > 0) {
5696
+ ranges.forEach(range => {
5697
+ const start = range[0];
5698
+ const end = range[1];
5699
+ const startHour = start.getHours();
5700
+ const startMinute = start.getMinutes();
5701
+ const endHour = end.getHours();
5702
+ const endMinute = end.getMinutes();
5703
+ if (startHour === hour && endHour !== hour) {
5704
+ setRangeData(minutes, startMinute, 60, true);
5705
+ } else if (startHour === hour && endHour === hour) {
5706
+ setRangeData(minutes, startMinute, endMinute + 1, true);
5707
+ } else if (startHour !== hour && endHour === hour) {
5708
+ setRangeData(minutes, 0, endMinute + 1, true);
5709
+ } else if (startHour < hour && endHour > hour) {
5710
+ setRangeData(minutes, 0, 60, true);
5711
+ }
5712
+ });
5713
+ } else {
5714
+ setRangeData(minutes, 0, 60, true);
5715
+ }
5716
+ return minutes;
5717
+ };
5718
+
5719
+ const range = function(n) {
5720
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
5721
+ return Array.apply(null, {length: n}).map((_, n) => n);
5722
+ };
5723
+
5724
+ const modifyDate = function(date, y, m, d) {
5725
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
5726
+ };
5727
+
5728
+ const modifyTime = function(date, h, m, s) {
5729
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
5730
+ };
5731
+
5732
+ const modifyWithTimeString = (date, time) => {
5733
+ if (date == null || !time) {
5734
+ return date;
5735
+ }
5736
+ time = parseDate(time, 'HH:mm:ss');
5737
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
5738
+ };
5739
+
5740
+ const clearTime = function(date) {
5741
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
5742
+ };
5743
+
5744
+ const clearMilliseconds = function(date) {
5745
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
5746
+ };
5747
+
5748
+ const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
5749
+ // TODO: refactory a more elegant solution
5750
+ if (ranges.length === 0) return date;
5751
+ const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
5752
+ const ndate = normalizeDate(date);
5753
+ const nranges = ranges.map(range => range.map(normalizeDate));
5754
+ if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
5755
+
5756
+ let minDate = nranges[0][0];
5757
+ let maxDate = nranges[0][0];
5758
+
5759
+ nranges.forEach(nrange => {
5760
+ minDate = new Date(Math.min(nrange[0], minDate));
5761
+ maxDate = new Date(Math.max(nrange[1], minDate));
5762
+ });
5763
+
5764
+ const ret = ndate < minDate ? minDate : maxDate;
5765
+ // preserve Year/Month/Date
5766
+ return modifyDate(
5767
+ ret,
5768
+ date.getFullYear(),
5769
+ date.getMonth(),
5770
+ date.getDate()
5771
+ );
5772
+ };
5773
+
5774
+ const timeWithinRange = function(date, selectableRange, format) {
5775
+ const limitedDate = limitTimeRange(date, selectableRange, format);
5776
+ return limitedDate.getTime() === date.getTime();
5777
+ };
5778
+
5779
+ const changeYearMonthAndClampDate = function(date, year, month) {
5780
+ // clamp date to the number of days in `year`, `month`
5781
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
5782
+ const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
5783
+ return modifyDate(date, year, month, monthDate);
5784
+ };
5785
+
5786
+ const prevMonth = function(date) {
5787
+ const year = date.getFullYear();
5788
+ const month = date.getMonth();
5789
+ return month === 0
5790
+ ? changeYearMonthAndClampDate(date, year - 1, 11)
5791
+ : changeYearMonthAndClampDate(date, year, month - 1);
5792
+ };
5793
+
5794
+ const nextMonth = function(date) {
5795
+ const year = date.getFullYear();
5796
+ const month = date.getMonth();
5797
+ return month === 11
5798
+ ? changeYearMonthAndClampDate(date, year + 1, 0)
5799
+ : changeYearMonthAndClampDate(date, year, month + 1);
5800
+ };
5801
+
5802
+ const prevYear = function(date, amount = 1) {
5803
+ const year = date.getFullYear();
5804
+ const month = date.getMonth();
5805
+ return changeYearMonthAndClampDate(date, year - amount, month);
5806
+ };
5807
+
5808
+ const nextYear = function(date, amount = 1) {
5809
+ const year = date.getFullYear();
5810
+ const month = date.getMonth();
5811
+ return changeYearMonthAndClampDate(date, year + amount, month);
5812
+ };
5813
+
5814
+ const extractDateFormat = function(format) {
5815
+ return format
5816
+ .replace(/\W?m{1,2}|\W?ZZ/g, '')
5817
+ .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
5818
+ .trim();
5819
+ };
5820
+
5821
+ const extractTimeFormat = function(format) {
5822
+ return format
5823
+ .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
5824
+ .trim();
5825
+ };
5826
+
5827
+ const validateRangeInOneMonth = function(start, end) {
5828
+ return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
5829
+ };
5830
+
5813
5831
  /**
5814
5832
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
5815
5833
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
5816
5834
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
5817
5835
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
5818
5836
  * @returns {number} 工作日数量
5819
- */
5820
- var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
5821
- var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
5822
-
5823
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
5824
- throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
5825
- }
5826
-
5827
- var startDateObj = new Date(start_date);
5828
- var endDateObj = new Date(end_date);
5829
-
5830
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
5831
- throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
5832
- }
5833
-
5834
- if (startDateObj > endDateObj) {
5835
- throw new Error('Start date should be earlier than or equal to end date.');
5836
- }
5837
-
5838
- var workdays = 0;
5839
-
5840
- // Iterate through each day in the date range
5841
-
5842
- var _loop = function _loop(currentDate) {
5843
- // Check if the current day is a weekend (Saturday or Sunday)
5844
- var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
5845
-
5846
- // Check if the current day is a holiday
5847
- var isHoliday = holidays.some(function (holiday) {
5848
- var holidayDate = new Date(holiday);
5849
- return currentDate.toDateString() === holidayDate.toDateString();
5850
- });
5851
-
5852
- // If it's a workday (not a weekend or holiday), increment the workdays count
5853
- if (!isWeekend && !isHoliday) {
5854
- workdays++;
5855
- }
5856
- };
5857
-
5858
- for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
5859
- _loop(currentDate);
5860
- }
5861
-
5862
- return workdays;
5863
- };
5864
-
5837
+ */
5838
+ const calculateNetworkDays = function (start_date, end_date, holidays = []) {
5839
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
5840
+ throw new Error(
5841
+ "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
5842
+ );
5843
+ }
5844
+
5845
+ const startDateObj = new Date(start_date);
5846
+ const endDateObj = new Date(end_date);
5847
+
5848
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
5849
+ throw new Error(
5850
+ "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
5851
+ );
5852
+ }
5853
+
5854
+ if (startDateObj > endDateObj) {
5855
+ throw new Error('Start date should be earlier than or equal to end date.');
5856
+ }
5857
+
5858
+ let workdays = 0;
5859
+
5860
+ // Iterate through each day in the date range
5861
+ for (
5862
+ let currentDate = new Date(startDateObj);
5863
+ currentDate <= endDateObj;
5864
+ currentDate.setDate(currentDate.getDate() + 1)
5865
+ ) {
5866
+ // Check if the current day is a weekend (Saturday or Sunday)
5867
+ const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
5868
+
5869
+ // Check if the current day is a holiday
5870
+ const isHoliday = holidays.some((holiday) => {
5871
+ const holidayDate = new Date(holiday);
5872
+ return currentDate.toDateString() === holidayDate.toDateString();
5873
+ });
5874
+
5875
+ // If it's a workday (not a weekend or holiday), increment the workdays count
5876
+ if (!isWeekend && !isHoliday) {
5877
+ workdays++;
5878
+ }
5879
+ }
5880
+
5881
+ return workdays;
5882
+ };
5883
+
5865
5884
  /**
5866
5885
  * 日期加减天数
5867
5886
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
5868
5887
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
5869
5888
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
5870
- */
5871
- var dateAddDays = function dateAddDays(start_date, days) {
5872
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
5873
- 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.");
5874
- }
5875
-
5876
- var startDateObj = new Date(start_date);
5877
- if (isNaN(startDateObj.getTime())) {
5878
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5879
- }
5880
-
5881
- var resultDateObj = new Date(startDateObj);
5882
- resultDateObj.setDate(resultDateObj.getDate() + days);
5883
-
5884
- var resultYear = resultDateObj.getFullYear();
5885
- var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
5886
- var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
5887
-
5888
- return resultYear + '-' + resultMonth + '-' + resultDay;
5889
- };
5890
-
5889
+ */
5890
+ const dateAddDays = function (start_date, days) {
5891
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
5892
+ throw new Error(
5893
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
5894
+ );
5895
+ }
5896
+
5897
+ const startDateObj = new Date(start_date);
5898
+ if (isNaN(startDateObj.getTime())) {
5899
+ throw new Error(
5900
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
5901
+ );
5902
+ }
5903
+
5904
+ const resultDateObj = new Date(startDateObj);
5905
+ resultDateObj.setDate(resultDateObj.getDate() + days);
5906
+
5907
+ const resultYear = resultDateObj.getFullYear();
5908
+ const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
5909
+ const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
5910
+
5911
+ return `${resultYear}-${resultMonth}-${resultDay}`;
5912
+ };
5913
+
5891
5914
  /**
5892
5915
  * 计算两个日期之间的差值
5893
5916
  * @date 2023年12月14日
@@ -5895,180 +5918,182 @@ var dateAddDays = function dateAddDays(start_date, days) {
5895
5918
  * @param {String} end_date - 结束日期字符串
5896
5919
  * @param {String} unit - 单位:year/month/day
5897
5920
  * @returns {Number} 差值
5898
- */
5899
- var dateDiff = function dateDiff(start_date, end_date) {
5900
- var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
5901
-
5902
- // Assuming date strings are in "YYYY-MM-DD" format
5903
- var startDate = new Date(start_date);
5904
- var endDate = new Date(end_date);
5905
-
5906
- // If the date is invalid, return 0
5907
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
5908
- return 0;
5909
- }
5910
-
5911
- if (unit === 'year') {
5912
- return endDate.getFullYear() - startDate.getFullYear();
5913
- } else if (unit === 'month') {
5914
- return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
5915
- } else {
5916
- // Default to day
5917
- var timeDifference = endDate - startDate;
5918
- // Calculate days (86400000 milliseconds per day)
5919
- return Math.floor(timeDifference / 86400000);
5920
- }
5921
- };
5922
-
5921
+ */
5922
+ const dateDiff = function (start_date, end_date, unit = 'day') {
5923
+ // Assuming date strings are in "YYYY-MM-DD" format
5924
+ var startDate = new Date(start_date);
5925
+ var endDate = new Date(end_date);
5926
+
5927
+ // If the date is invalid, return 0
5928
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
5929
+ return 0;
5930
+ }
5931
+
5932
+ if (unit === 'year') {
5933
+ return endDate.getFullYear() - startDate.getFullYear();
5934
+ } else if (unit === 'month') {
5935
+ return (
5936
+ (endDate.getFullYear() - startDate.getFullYear()) * 12 +
5937
+ (endDate.getMonth() - startDate.getMonth())
5938
+ );
5939
+ } else {
5940
+ // Default to day
5941
+ var timeDifference = endDate - startDate;
5942
+ // Calculate days (86400000 milliseconds per day)
5943
+ return Math.floor(timeDifference / 86400000);
5944
+ }
5945
+ };
5946
+
5923
5947
  /**
5924
5948
  * 获取月份中的日期
5925
5949
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
5926
5950
  * @returns {number} 月份中的日期(1-31)
5927
- */
5928
- var dayOfMonth = function dayOfMonth(date) {
5929
- if (typeof date !== 'string') {
5930
- throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5931
- }
5932
-
5933
- var dateObj = new Date(date);
5934
- if (isNaN(dateObj.getTime())) {
5935
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5936
- }
5937
-
5938
- return dateObj.getDate();
5939
- };
5940
-
5951
+ */
5952
+ const dayOfMonth = function (date) {
5953
+ if (typeof date !== 'string') {
5954
+ throw new Error(
5955
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
5956
+ );
5957
+ }
5958
+
5959
+ const dateObj = new Date(date);
5960
+ if (isNaN(dateObj.getTime())) {
5961
+ throw new Error(
5962
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
5963
+ );
5964
+ }
5965
+
5966
+ return dateObj.getDate();
5967
+ };
5968
+
5941
5969
  /**
5942
5970
  * 获取当前日期
5943
5971
  * @date 2022年5月7日
5944
5972
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
5945
5973
  * @returns {string} 当前日期的格式化字符串
5946
- */
5947
- var getCurrentDate = function getCurrentDate() {
5948
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
5949
-
5950
- return formatDate(new Date(), format);
5951
- };
5952
-
5974
+ */
5975
+ const getCurrentDate = function (format = 'YYYY-MM-DD') {
5976
+ return formatDate(new Date(), format);
5977
+ };
5978
+
5953
5979
  /**
5954
5980
  * 获取当前日期时间
5955
5981
  * @date 2022年5月7日
5956
5982
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
5957
5983
  * @returns {string} 当前日期时间的格式化字符串
5958
- */
5959
- var getCurrentDateTime = function getCurrentDateTime() {
5960
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
5961
-
5962
- return formatDate(new Date(), format);
5963
- };
5964
-
5984
+ */
5985
+ const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
5986
+ return formatDate(new Date(), format);
5987
+ };
5988
+
5965
5989
  /**
5966
5990
  * 获取小时
5967
5991
  * @date 2022年5月7日
5968
5992
  * @param {Date|string} [date] - 日期对象或日期字符串
5969
5993
  * @returns {number} 小时数(0-23)
5970
- */
5971
- var getHour = function getHour(date) {
5972
- if (!date) {
5973
- return new Date().getHours();
5974
- }
5975
- if (typeof date === 'string') {
5976
- date = new Date(date);
5977
- }
5978
- return date.getHours();
5979
- };
5980
-
5994
+ */
5995
+ const getHour = function (date) {
5996
+ if (!date) {
5997
+ return new Date().getHours();
5998
+ }
5999
+ if (typeof date === 'string') {
6000
+ date = new Date(date);
6001
+ }
6002
+ return date.getHours();
6003
+ };
6004
+
5981
6005
  /**
5982
6006
  * 获取分钟
5983
6007
  * @date 2022年5月7日
5984
6008
  * @param {Date|string} [date] - 日期对象或日期字符串
5985
6009
  * @returns {number} 分钟数(0-59)
5986
- */
5987
- var getMinute = function getMinute(date) {
5988
- if (!date) {
5989
- return new Date().getMinutes();
5990
- }
5991
- if (typeof date === 'string') {
5992
- date = new Date(date);
5993
- }
5994
- return date.getMinutes();
5995
- };
5996
-
6010
+ */
6011
+ const getMinute = function (date) {
6012
+ if (!date) {
6013
+ return new Date().getMinutes();
6014
+ }
6015
+ if (typeof date === 'string') {
6016
+ date = new Date(date);
6017
+ }
6018
+ return date.getMinutes();
6019
+ };
6020
+
5997
6021
  /**
5998
6022
  * 获取月份
5999
6023
  * @date 2022年5月7日
6000
6024
  * @param {Date|string} [date] - 日期对象或日期字符串
6001
6025
  * @returns {number} 月份数(1-12)
6002
- */
6003
- var getMonth = function getMonth(date) {
6004
- if (!date) {
6005
- return new Date().getMonth() + 1;
6006
- }
6007
- if (typeof date === 'string') {
6008
- date = new Date(date);
6009
- }
6010
- return date.getMonth() + 1;
6011
- };
6012
-
6026
+ */
6027
+ const getMonth = function (date) {
6028
+ if (!date) {
6029
+ return new Date().getMonth() + 1;
6030
+ }
6031
+ if (typeof date === 'string') {
6032
+ date = new Date(date);
6033
+ }
6034
+ return date.getMonth() + 1;
6035
+ };
6036
+
6013
6037
  /**
6014
6038
  * 获取秒
6015
6039
  * @date 2022年5月7日
6016
6040
  * @param {Date|string} [date] - 日期对象或日期字符串
6017
6041
  * @returns {number} 秒数(0-59)
6018
- */
6019
- var getSecond = function getSecond(date) {
6020
- if (!date) {
6021
- return new Date().getSeconds();
6022
- }
6023
- if (typeof date === 'string') {
6024
- date = new Date(date);
6025
- }
6026
- return date.getSeconds();
6027
- };
6028
-
6042
+ */
6043
+ const getSecond = function (date) {
6044
+ if (!date) {
6045
+ return new Date().getSeconds();
6046
+ }
6047
+ if (typeof date === 'string') {
6048
+ date = new Date(date);
6049
+ }
6050
+ return date.getSeconds();
6051
+ };
6052
+
6029
6053
  /**
6030
6054
  * 获取星期几
6031
6055
  * @date 2022年5月7日
6032
6056
  * @param {Date|string} [date] - 日期对象或日期字符串
6033
6057
  * @returns {number} 星期几(0-6,0表示星期日)
6034
- */
6035
- var getWeekday = function getWeekday(date) {
6036
- if (!date) {
6037
- return new Date().getDay();
6038
- }
6039
- if (typeof date === 'string') {
6040
- date = new Date(date);
6041
- }
6042
- return date.getDay();
6043
- };
6044
-
6058
+ */
6059
+ const getWeekday = function (date) {
6060
+ if (!date) {
6061
+ return new Date().getDay();
6062
+ }
6063
+ if (typeof date === 'string') {
6064
+ date = new Date(date);
6065
+ }
6066
+ return date.getDay();
6067
+ };
6068
+
6069
+
6045
6070
  /**
6046
6071
  * @desc 获取上午/下午/晚上
6047
6072
  * @author huangbo
6048
6073
  * @date 2022年5月7日
6049
6074
  * @param {String} [time] - 时间
6050
- **/
6051
- var timeCycle = function timeCycle(time) {
6052
- var hour = 0;
6053
- if (!time) {
6054
- hour = new Date().getHours();
6055
- } else if (typeof time === 'string') {
6056
- // 从时间字符串中提取小时
6057
- var match = time.match(/^(\d{1,2})/);
6058
- if (match) {
6059
- hour = parseInt(match[1], 10);
6060
- }
6061
- } else if (typeof time === 'number') {
6062
- hour = time;
6063
- }
6064
- // 判断时间段
6065
- if (hour >= 5 && hour < 12) {
6066
- return '上午';
6067
- } else if (hour >= 12 && hour < 18) {
6068
- return '下午';
6069
- } else {
6070
- return '晚上';
6071
- }
6075
+ **/
6076
+ const timeCycle = function (time) {
6077
+ let hour = 0;
6078
+ if (!time) {
6079
+ hour = new Date().getHours();
6080
+ } else if (typeof time === 'string') {
6081
+ // 从时间字符串中提取小时
6082
+ const match = time.match(/^(\d{1,2})/);
6083
+ if (match) {
6084
+ hour = parseInt(match[1], 10);
6085
+ }
6086
+ } else if (typeof time === 'number') {
6087
+ hour = time;
6088
+ }
6089
+ // 判断时间段
6090
+ if (hour >= 5 && hour < 12) {
6091
+ return '上午';
6092
+ } else if (hour >= 12 && hour < 18) {
6093
+ return '下午';
6094
+ } else {
6095
+ return '晚上';
6096
+ }
6072
6097
  };
6073
6098
 
6074
6099
  /***/ }),
@@ -6080,7 +6105,7 @@ module.exports = require("eoss/lib/message-box");
6080
6105
 
6081
6106
  /***/ }),
6082
6107
 
6083
- /***/ 93:
6108
+ /***/ 94:
6084
6109
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
6085
6110
 
6086
6111
  "use strict";