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