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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/lib/0.js +1 -1
  2. package/lib/1.js +1 -1
  3. package/lib/10.js +1 -1
  4. package/lib/11.js +1 -1
  5. package/lib/12.js +1 -1
  6. package/lib/13.js +1 -1
  7. package/lib/14.js +1 -1
  8. package/lib/15.js +1 -1
  9. package/lib/16.js +1 -1
  10. package/lib/17.js +1 -1
  11. package/lib/18.js +1 -1
  12. package/lib/19.js +1 -1
  13. package/lib/20.js +1 -1
  14. package/lib/21.js +1 -1
  15. package/lib/22.js +1 -1
  16. package/lib/23.js +1 -1
  17. package/lib/24.js +1 -1
  18. package/lib/25.js +1 -1
  19. package/lib/26.js +1 -1
  20. package/lib/27.js +1 -1
  21. package/lib/28.js +1 -1
  22. package/lib/29.js +1 -1
  23. package/lib/3.js +1 -1
  24. package/lib/30.js +1 -1
  25. package/lib/31.js +1 -1
  26. package/lib/32.js +1 -1
  27. package/lib/33.js +1 -1
  28. package/lib/34.js +1 -1
  29. package/lib/35.js +1 -1
  30. package/lib/36.js +1 -1
  31. package/lib/37.js +1 -1
  32. package/lib/38.js +1 -1
  33. package/lib/39.js +1 -1
  34. package/lib/4.js +1 -1
  35. package/lib/40.js +1 -1
  36. package/lib/41.js +1 -1
  37. package/lib/42.js +1 -1
  38. package/lib/43.js +1 -1
  39. package/lib/44.js +1 -1
  40. package/lib/45.js +1 -1
  41. package/lib/46.js +1 -1
  42. package/lib/47.js +1 -1
  43. package/lib/48.js +1 -1
  44. package/lib/49.js +1 -1
  45. package/lib/5.js +1 -1
  46. package/lib/50.js +1 -1
  47. package/lib/51.js +1 -1
  48. package/lib/52.js +1 -1
  49. package/lib/53.js +1 -1
  50. package/lib/54.js +1 -1
  51. package/lib/55.js +1 -1
  52. package/lib/56.js +1 -1
  53. package/lib/57.js +1 -1
  54. package/lib/58.js +1 -1
  55. package/lib/59.js +1 -1
  56. package/lib/6.js +1 -1
  57. package/lib/60.js +1 -1
  58. package/lib/61.js +1 -1
  59. package/lib/62.js +1 -1
  60. package/lib/63.js +1 -1
  61. package/lib/64.js +1 -1
  62. package/lib/65.js +1 -1
  63. package/lib/66.js +1 -1
  64. package/lib/67.js +1 -1
  65. package/lib/68.js +1 -1
  66. package/lib/69.js +1 -1
  67. package/lib/7.js +1 -1
  68. package/lib/70.js +1 -1
  69. package/lib/71.js +1 -1
  70. package/lib/72.js +1 -1
  71. package/lib/73.js +1 -1
  72. package/lib/74.js +1 -1
  73. package/lib/75.js +1 -1
  74. package/lib/76.js +1 -1
  75. package/lib/77.js +1 -1
  76. package/lib/78.js +1 -1
  77. package/lib/79.js +1 -1
  78. package/lib/8.js +1 -1
  79. package/lib/80.js +1 -1
  80. package/lib/81.js +1 -1
  81. package/lib/9.js +1 -1
  82. package/lib/account-login.js +837 -862
  83. package/lib/alert.js +2 -2
  84. package/lib/aside.js +2 -2
  85. package/lib/audit-trajectory.js +4 -4
  86. package/lib/autocomplete.js +1813 -1988
  87. package/lib/avatar.js +2 -2
  88. package/lib/backtop.js +2 -2
  89. package/lib/badge.js +2 -2
  90. package/lib/breadcrumb-item.js +4 -4
  91. package/lib/breadcrumb.js +4 -4
  92. package/lib/button-group.js +4 -4
  93. package/lib/button.js +2 -2
  94. package/lib/ca-login.js +837 -862
  95. package/lib/calendar.js +839 -864
  96. package/lib/card.js +2 -2
  97. package/lib/carousel-item.js +846 -871
  98. package/lib/carousel.js +839 -864
  99. package/lib/cascader-panel.js +852 -877
  100. package/lib/cascader.js +2048 -2223
  101. package/lib/checkbox-button.js +4 -4
  102. package/lib/checkbox-group.js +859 -884
  103. package/lib/checkbox.js +4 -4
  104. package/lib/col.js +2 -2
  105. package/lib/collapse-item.js +1040 -1065
  106. package/lib/collapse.js +1040 -1065
  107. package/lib/color-picker.js +972 -1122
  108. package/lib/container.js +2 -2
  109. package/lib/cron.js +12 -12
  110. package/lib/data-table.js +843 -868
  111. package/lib/date-picker.js +10520 -10695
  112. package/lib/descriptions-item.js +4 -4
  113. package/lib/descriptions.js +4 -4
  114. package/lib/dialog.js +837 -862
  115. package/lib/divider.js +2 -2
  116. package/lib/drawer.js +2 -2
  117. package/lib/dropdown-item.js +4 -4
  118. package/lib/dropdown-menu.js +974 -1124
  119. package/lib/dropdown.js +841 -866
  120. package/lib/email-login.js +837 -862
  121. package/lib/empty.js +2 -2
  122. package/lib/eoss.common.js +4023 -2668
  123. package/lib/flip.js +2 -2
  124. package/lib/flow-group.js +853 -878
  125. package/lib/flow.js +868 -893
  126. package/lib/flows.js +854 -879
  127. package/lib/footer.js +2 -2
  128. package/lib/form-item.js +860 -885
  129. package/lib/form.js +933 -950
  130. package/lib/guide.js +2 -2
  131. package/lib/header.js +2 -2
  132. package/lib/icon.js +837 -862
  133. package/lib/icons.js +2 -2
  134. package/lib/image-viewer.js +837 -862
  135. package/lib/image.js +4 -4
  136. package/lib/index.js +1 -1
  137. package/lib/infinite-scroll.js +2 -2
  138. package/lib/input-number.js +6 -6
  139. package/lib/input.js +839 -864
  140. package/lib/link.js +2 -2
  141. package/lib/loading.js +2 -2
  142. package/lib/login.js +867 -891
  143. package/lib/lowcode-view.js +1843 -1185
  144. package/lib/lowcode.js +3050 -1569
  145. package/lib/main.js +970 -988
  146. package/lib/marquee.js +837 -862
  147. package/lib/menu-item-group.js +15 -15
  148. package/lib/menu-item.js +6 -6
  149. package/lib/menu.js +2227 -2368
  150. package/lib/message-box.js +843 -868
  151. package/lib/message.js +839 -864
  152. package/lib/notification.js +861 -886
  153. package/lib/option-group.js +4 -4
  154. package/lib/option.js +839 -864
  155. package/lib/page-header.js +2 -2
  156. package/lib/pagination.js +839 -864
  157. package/lib/phone-login.js +847 -866
  158. package/lib/popconfirm.js +4 -4
  159. package/lib/popover.js +1831 -2006
  160. package/lib/process-config.js +839 -864
  161. package/lib/process-module.js +846 -871
  162. package/lib/process-rule.js +905 -930
  163. package/lib/progress.js +2 -2
  164. package/lib/qr-code.js +4 -4
  165. package/lib/qrcode-login.js +839 -864
  166. package/lib/radio-button.js +4 -4
  167. package/lib/radio-group.js +850 -875
  168. package/lib/radio.js +4 -4
  169. package/lib/rate.js +837 -862
  170. package/lib/retrial-auth.js +837 -862
  171. package/lib/row.js +2 -2
  172. package/lib/scrollbar.js +839 -864
  173. package/lib/select.js +2139 -2314
  174. package/lib/selector-panel.js +940 -965
  175. package/lib/selector.js +852 -877
  176. package/lib/slider.js +4 -4
  177. package/lib/step.js +32 -32
  178. package/lib/steps.js +874 -899
  179. package/lib/submenu.js +1269 -1385
  180. package/lib/switch.js +839 -864
  181. package/lib/tab-pane.js +4 -4
  182. package/lib/table-column.js +840 -865
  183. package/lib/table.js +1825 -2000
  184. package/lib/tabs.js +846 -871
  185. package/lib/tag.js +2 -2
  186. package/lib/theme-chalk/fonts/iconfont.ttf +0 -0
  187. package/lib/theme-chalk/fonts/iconfont.woff +0 -0
  188. package/lib/theme-chalk/index.css +1 -1
  189. package/lib/theme-chalk/lowcode.css +1 -1
  190. package/lib/time-picker.js +6471 -6646
  191. package/lib/time-select.js +5039 -5214
  192. package/lib/timeline-item.js +2 -2
  193. package/lib/timeline.js +2 -2
  194. package/lib/tips.js +837 -862
  195. package/lib/toolbar.js +4 -4
  196. package/lib/tooltip.js +1813 -1988
  197. package/lib/transfer.js +837 -862
  198. package/lib/tree-group.js +853 -878
  199. package/lib/tree.js +1026 -1051
  200. package/lib/update-history.js +4 -4
  201. package/lib/upload.js +859 -884
  202. package/lib/wujie.js +841 -866
  203. package/package.json +1 -1
  204. package/packages/flow-group/src/main.vue +2 -2
  205. package/packages/form/src/form-item-render.vue +1 -0
  206. package/packages/form/src/form-item.vue +12 -6
  207. package/packages/form/src/form.vue +5 -5
  208. package/packages/login/src/login.vue +1 -0
  209. package/packages/lowcode/src/attribute/function.vue +28 -9
  210. package/packages/lowcode/src/attribute/props.vue +202 -0
  211. package/packages/lowcode/src/attribute/styles.vue +79 -5
  212. package/packages/lowcode/src/attribute.vue +61 -4
  213. package/packages/lowcode/src/canvas.vue +159 -2
  214. package/packages/lowcode/src/form-render.vue +305 -0
  215. package/packages/lowcode/src/lowcode.vue +33 -13
  216. package/packages/lowcode/src/modules.vue +53 -37
  217. package/packages/lowcode/src/render.vue +80 -25
  218. package/packages/lowcode/src/util/components.js +100 -0
  219. package/packages/lowcode/src/util/props-util.js +67 -0
  220. package/packages/lowcode/src/util/source-generator.js +69 -9
  221. package/packages/lowcode/src/util/source-parser.js +64 -10
  222. package/packages/lowcode-view/src/render.vue +48 -18
  223. package/packages/main/src/components/userinfo.vue +0 -1
  224. package/packages/menu/src/menu-item-group.vue +1 -1
  225. package/packages/menu/src/mixins.js +8 -4
  226. package/packages/menu/src/submenu.vue +35 -5
  227. package/packages/phone-login/src/phone-login.vue +5 -2
  228. package/packages/theme-chalk/dist/fonts/iconfont.ttf +0 -0
  229. package/packages/theme-chalk/dist/fonts/iconfont.woff +0 -0
  230. package/packages/theme-chalk/src/fonts/iconfont.ttf +0 -0
  231. package/packages/theme-chalk/src/fonts/iconfont.woff +0 -0
  232. package/packages/theme-chalk/src/lowcode.scss +21 -2
  233. package/src/index.js +336 -336
@@ -82,7 +82,7 @@ module.exports =
82
82
  /******/
83
83
  /******/
84
84
  /******/ // Load entry module and return exports
85
- /******/ return __webpack_require__(__webpack_require__.s = 256);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 263);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -4769,7 +4769,7 @@ module.exports = require("fetch-request-source");
4769
4769
 
4770
4770
  /***/ }),
4771
4771
 
4772
- /***/ 256:
4772
+ /***/ 263:
4773
4773
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4774
4774
 
4775
4775
  "use strict";
@@ -6106,759 +6106,736 @@ var changeInTime = '/baseIssueRules/changeInTime';
6106
6106
  /* unused harmony export getSecond */
6107
6107
  /* unused harmony export getWeekday */
6108
6108
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
6109
- /* Modified from https://github.com/taylorhakes/fecha
6110
- *
6111
- * The MIT License (MIT)
6112
- *
6113
- * Copyright (c) 2015 Taylor Hakes
6114
- *
6115
- * Permission is hereby granted, free of charge, to any person obtaining a copy
6116
- * of this software and associated documentation files (the "Software"), to deal
6117
- * in the Software without restriction, including without limitation the rights
6118
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6119
- * copies of the Software, and to permit persons to whom the Software is
6120
- * furnished to do so, subject to the following conditions:
6121
- *
6122
- * The above copyright notice and this permission notice shall be included in all
6123
- * copies or substantial portions of the Software.
6124
- *
6125
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6126
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6127
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6128
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6129
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
6130
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
6131
- * SOFTWARE.
6132
- */
6133
-
6134
- /*eslint-disable*/
6135
- // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
6136
-
6137
-
6109
+
6110
+
6138
6111
  /**
6139
6112
  * Parse or format dates
6140
6113
  * @class fecha
6141
- */
6142
- const fecha = {};
6143
- const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
6144
- const twoDigits = '\\d\\d?';
6145
- const threeDigits = '\\d{3}';
6146
- const fourDigits = '\\d{4}';
6147
- const word = '[^\\s]+';
6148
- const literal = /\[([^]*?)\]/gm;
6149
- const noop = function () {};
6150
-
6151
- function regexEscape(str) {
6152
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
6153
- }
6154
-
6155
- function shorten(arr, sLen) {
6156
- const newArr = [];
6157
- for (let i = 0, len = arr.length; i < len; i++) {
6158
- newArr.push(arr[i].substr(0, sLen));
6159
- }
6160
- return newArr;
6161
- }
6162
-
6163
- function monthUpdate() {
6164
- return function (d, v) {
6165
- const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
6166
- if (~index) {
6167
- d.month = index;
6168
- }
6169
- };
6170
- }
6171
-
6172
- function pad(val, len) {
6173
- val = String(val);
6174
- len = len || 2;
6175
- while (val.length < len) {
6176
- val = '0' + val;
6177
- }
6178
- return val;
6179
- }
6180
-
6181
- // 直接使用中文日期名称常量
6182
- const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
6183
- const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
6184
- const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
6185
- const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
6186
- const amPm = ['上午', '下午'];
6187
- const DoFn = function DoFn(D) {
6188
- return D + '日';
6189
- };
6190
-
6191
- const formatFlags = {
6192
- D: function(dateObj) {
6193
- return dateObj.getDay();
6194
- },
6195
- DD: function(dateObj) {
6196
- return pad(dateObj.getDay());
6197
- },
6198
- Do: function(dateObj) {
6199
- return DoFn(dateObj.getDate());
6200
- },
6201
- d: function(dateObj) {
6202
- return dateObj.getDate();
6203
- },
6204
- dd: function(dateObj) {
6205
- return pad(dateObj.getDate());
6206
- },
6207
- ddd: function(dateObj) {
6208
- return dayNamesShort[dateObj.getDay()];
6209
- },
6210
- dddd: function(dateObj) {
6211
- return dayNames[dateObj.getDay()];
6212
- },
6213
- M: function(dateObj) {
6214
- return dateObj.getMonth() + 1;
6215
- },
6216
- MM: function(dateObj) {
6217
- return pad(dateObj.getMonth() + 1);
6218
- },
6219
- MMM: function(dateObj) {
6220
- return monthNamesShort[dateObj.getMonth()];
6221
- },
6222
- MMMM: function(dateObj) {
6223
- return monthNames[dateObj.getMonth()];
6224
- },
6225
- yy: function(dateObj) {
6226
- return pad(String(dateObj.getFullYear()), 4).substr(2);
6227
- },
6228
- yyyy: function(dateObj) {
6229
- return pad(dateObj.getFullYear(), 4);
6230
- },
6231
- h: function(dateObj) {
6232
- return dateObj.getHours() % 12 || 12;
6233
- },
6234
- hh: function(dateObj) {
6235
- return pad(dateObj.getHours() % 12 || 12);
6236
- },
6237
- H: function(dateObj) {
6238
- return dateObj.getHours();
6239
- },
6240
- HH: function(dateObj) {
6241
- return pad(dateObj.getHours());
6242
- },
6243
- m: function(dateObj) {
6244
- return dateObj.getMinutes();
6245
- },
6246
- mm: function(dateObj) {
6247
- return pad(dateObj.getMinutes());
6248
- },
6249
- s: function(dateObj) {
6250
- return dateObj.getSeconds();
6251
- },
6252
- ss: function(dateObj) {
6253
- return pad(dateObj.getSeconds());
6254
- },
6255
- S: function(dateObj) {
6256
- return Math.round(dateObj.getMilliseconds() / 100);
6257
- },
6258
- SS: function(dateObj) {
6259
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
6260
- },
6261
- SSS: function(dateObj) {
6262
- return pad(dateObj.getMilliseconds(), 3);
6263
- },
6264
- a: function(dateObj) {
6265
- return dateObj.getHours() < 12 ? '上午' : '下午';
6266
- },
6267
- A: function(dateObj) {
6268
- return dateObj.getHours() < 12 ? '上午' : '下午';
6269
- },
6270
- ZZ: function(dateObj) {
6271
- const o = dateObj.getTimezoneOffset();
6272
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
6273
- }
6274
- };
6275
-
6276
- const parseFlags = {
6277
- d: [twoDigits, function (d, v) {
6278
- d.day = v;
6279
- }],
6280
- Do: [twoDigits + word, function (d, v) {
6281
- d.day = parseInt(v, 10);
6282
- }],
6283
- M: [twoDigits, function (d, v) {
6284
- d.month = v - 1;
6285
- }],
6286
- yy: [twoDigits, function (d, v) {
6287
- const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
6288
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
6289
- }],
6290
- h: [twoDigits, function (d, v) {
6291
- d.hour = v;
6292
- }],
6293
- m: [twoDigits, function (d, v) {
6294
- d.minute = v;
6295
- }],
6296
- s: [twoDigits, function (d, v) {
6297
- d.second = v;
6298
- }],
6299
- yyyy: [fourDigits, function (d, v) {
6300
- d.year = v;
6301
- }],
6302
- S: ['\\d', function (d, v) {
6303
- d.millisecond = v * 100;
6304
- }],
6305
- SS: ['\\d{2}', function (d, v) {
6306
- d.millisecond = v * 10;
6307
- }],
6308
- SSS: [threeDigits, function (d, v) {
6309
- d.millisecond = v;
6310
- }],
6311
- D: [twoDigits, noop],
6312
- ddd: [word, noop],
6313
- MMM: [word, monthUpdate('monthNamesShort')],
6314
- MMMM: [word, monthUpdate('monthNames')],
6315
- a: [word, function (d, v) {
6316
- const val = v.toLowerCase();
6317
- if (val === '上午') {
6318
- d.isPm = false;
6319
- } else if (val === '下午') {
6320
- d.isPm = true;
6321
- }
6322
- }],
6323
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
6324
- let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
6325
-
6326
- if (parts) {
6327
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
6328
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
6329
- }
6330
- }]
6331
- };
6332
- parseFlags.dd = parseFlags.d;
6333
- parseFlags.dddd = parseFlags.ddd;
6334
- parseFlags.DD = parseFlags.D;
6335
- parseFlags.mm = parseFlags.m;
6336
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
6337
- parseFlags.MM = parseFlags.M;
6338
- parseFlags.ss = parseFlags.s;
6339
- parseFlags.A = parseFlags.a;
6340
-
6341
-
6342
- // Some common format strings
6343
- fecha.masks = {
6344
- default: 'ddd MMM dd yyyy HH:mm:ss',
6345
- shortDate: 'M/D/yy',
6346
- mediumDate: 'MMM d, yyyy',
6347
- longDate: 'MMMM d, yyyy',
6348
- fullDate: 'dddd, MMMM d, yyyy',
6349
- shortTime: 'HH:mm',
6350
- mediumTime: 'HH:mm:ss',
6351
- longTime: 'HH:mm:ss.SSS'
6352
- };
6353
-
6114
+ */
6115
+ var fecha = {};
6116
+ var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
6117
+ var twoDigits = '\\d\\d?';
6118
+ var threeDigits = '\\d{3}';
6119
+ var fourDigits = '\\d{4}';
6120
+ var word = '[^\\s]+';
6121
+ var literal = /\[([^]*?)\]/gm;
6122
+ var noop = function noop() {};
6123
+
6124
+ function regexEscape(str) {
6125
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
6126
+ }
6127
+
6128
+ function shorten(arr, sLen) {
6129
+ var newArr = [];
6130
+ for (var i = 0, len = arr.length; i < len; i++) {
6131
+ newArr.push(arr[i].substr(0, sLen));
6132
+ }
6133
+ return newArr;
6134
+ }
6135
+
6136
+ function monthUpdate() {
6137
+ return function (d, v) {
6138
+ var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
6139
+ if (~index) {
6140
+ d.month = index;
6141
+ }
6142
+ };
6143
+ }
6144
+
6145
+ function pad(val, len) {
6146
+ val = String(val);
6147
+ len = len || 2;
6148
+ while (val.length < len) {
6149
+ val = '0' + val;
6150
+ }
6151
+ return val;
6152
+ }
6153
+
6154
+ // 直接使用中文日期名称常量
6155
+ var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
6156
+ var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
6157
+ var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
6158
+ var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
6159
+ var amPm = ['上午', '下午'];
6160
+ var DoFn = function DoFn(D) {
6161
+ return D + '日';
6162
+ };
6163
+
6164
+ var formatFlags = {
6165
+ D: function D(dateObj) {
6166
+ return dateObj.getDay();
6167
+ },
6168
+ DD: function DD(dateObj) {
6169
+ return pad(dateObj.getDay());
6170
+ },
6171
+ Do: function Do(dateObj) {
6172
+ return DoFn(dateObj.getDate());
6173
+ },
6174
+ d: function d(dateObj) {
6175
+ return dateObj.getDate();
6176
+ },
6177
+ dd: function dd(dateObj) {
6178
+ return pad(dateObj.getDate());
6179
+ },
6180
+ ddd: function ddd(dateObj) {
6181
+ return dayNamesShort[dateObj.getDay()];
6182
+ },
6183
+ dddd: function dddd(dateObj) {
6184
+ return dayNames[dateObj.getDay()];
6185
+ },
6186
+ M: function M(dateObj) {
6187
+ return dateObj.getMonth() + 1;
6188
+ },
6189
+ MM: function MM(dateObj) {
6190
+ return pad(dateObj.getMonth() + 1);
6191
+ },
6192
+ MMM: function MMM(dateObj) {
6193
+ return monthNamesShort[dateObj.getMonth()];
6194
+ },
6195
+ MMMM: function MMMM(dateObj) {
6196
+ return monthNames[dateObj.getMonth()];
6197
+ },
6198
+ yy: function yy(dateObj) {
6199
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
6200
+ },
6201
+ yyyy: function yyyy(dateObj) {
6202
+ return pad(dateObj.getFullYear(), 4);
6203
+ },
6204
+ h: function h(dateObj) {
6205
+ return dateObj.getHours() % 12 || 12;
6206
+ },
6207
+ hh: function hh(dateObj) {
6208
+ return pad(dateObj.getHours() % 12 || 12);
6209
+ },
6210
+ H: function H(dateObj) {
6211
+ return dateObj.getHours();
6212
+ },
6213
+ HH: function HH(dateObj) {
6214
+ return pad(dateObj.getHours());
6215
+ },
6216
+ m: function m(dateObj) {
6217
+ return dateObj.getMinutes();
6218
+ },
6219
+ mm: function mm(dateObj) {
6220
+ return pad(dateObj.getMinutes());
6221
+ },
6222
+ s: function s(dateObj) {
6223
+ return dateObj.getSeconds();
6224
+ },
6225
+ ss: function ss(dateObj) {
6226
+ return pad(dateObj.getSeconds());
6227
+ },
6228
+ S: function S(dateObj) {
6229
+ return Math.round(dateObj.getMilliseconds() / 100);
6230
+ },
6231
+ SS: function SS(dateObj) {
6232
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
6233
+ },
6234
+ SSS: function SSS(dateObj) {
6235
+ return pad(dateObj.getMilliseconds(), 3);
6236
+ },
6237
+ a: function a(dateObj) {
6238
+ return dateObj.getHours() < 12 ? '上午' : '下午';
6239
+ },
6240
+ A: function A(dateObj) {
6241
+ return dateObj.getHours() < 12 ? '上午' : '下午';
6242
+ },
6243
+ ZZ: function ZZ(dateObj) {
6244
+ var o = dateObj.getTimezoneOffset();
6245
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
6246
+ }
6247
+ };
6248
+
6249
+ var parseFlags = {
6250
+ d: [twoDigits, function (d, v) {
6251
+ d.day = v;
6252
+ }],
6253
+ Do: [twoDigits + word, function (d, v) {
6254
+ d.day = parseInt(v, 10);
6255
+ }],
6256
+ M: [twoDigits, function (d, v) {
6257
+ d.month = v - 1;
6258
+ }],
6259
+ yy: [twoDigits, function (d, v) {
6260
+ var da = new Date(),
6261
+ cent = +('' + da.getFullYear()).substr(0, 2);
6262
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
6263
+ }],
6264
+ h: [twoDigits, function (d, v) {
6265
+ d.hour = v;
6266
+ }],
6267
+ m: [twoDigits, function (d, v) {
6268
+ d.minute = v;
6269
+ }],
6270
+ s: [twoDigits, function (d, v) {
6271
+ d.second = v;
6272
+ }],
6273
+ yyyy: [fourDigits, function (d, v) {
6274
+ d.year = v;
6275
+ }],
6276
+ S: ['\\d', function (d, v) {
6277
+ d.millisecond = v * 100;
6278
+ }],
6279
+ SS: ['\\d{2}', function (d, v) {
6280
+ d.millisecond = v * 10;
6281
+ }],
6282
+ SSS: [threeDigits, function (d, v) {
6283
+ d.millisecond = v;
6284
+ }],
6285
+ D: [twoDigits, noop],
6286
+ ddd: [word, noop],
6287
+ MMM: [word, monthUpdate('monthNamesShort')],
6288
+ MMMM: [word, monthUpdate('monthNames')],
6289
+ a: [word, function (d, v) {
6290
+ var val = v.toLowerCase();
6291
+ if (val === '上午') {
6292
+ d.isPm = false;
6293
+ } else if (val === '下午') {
6294
+ d.isPm = true;
6295
+ }
6296
+ }],
6297
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
6298
+ var parts = (v + '').match(/([+-]|\d\d)/gi),
6299
+ minutes = void 0;
6300
+
6301
+ if (parts) {
6302
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
6303
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
6304
+ }
6305
+ }]
6306
+ };
6307
+ parseFlags.dd = parseFlags.d;
6308
+ parseFlags.dddd = parseFlags.ddd;
6309
+ parseFlags.DD = parseFlags.D;
6310
+ parseFlags.mm = parseFlags.m;
6311
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
6312
+ parseFlags.MM = parseFlags.M;
6313
+ parseFlags.ss = parseFlags.s;
6314
+ parseFlags.A = parseFlags.a;
6315
+
6316
+ // Some common format strings
6317
+ fecha.masks = {
6318
+ default: 'ddd MMM dd yyyy HH:mm:ss',
6319
+ shortDate: 'M/D/yy',
6320
+ mediumDate: 'MMM d, yyyy',
6321
+ longDate: 'MMMM d, yyyy',
6322
+ fullDate: 'dddd, MMMM d, yyyy',
6323
+ shortTime: 'HH:mm',
6324
+ mediumTime: 'HH:mm:ss',
6325
+ longTime: 'HH:mm:ss.SSS'
6326
+ };
6327
+
6354
6328
  /***
6355
6329
  * Format a date
6356
6330
  * @method format
6357
6331
  * @param {Date|number} dateObj
6358
6332
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
6359
- */
6360
- fecha.format = function (dateObj, mask) {
6361
- if (typeof dateObj === 'number') {
6362
- dateObj = new Date(dateObj);
6363
- }
6364
-
6365
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
6366
- throw new Error('Invalid Date in fecha.format');
6367
- }
6368
-
6369
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
6370
-
6371
- const literals = [];
6372
-
6373
- // Make literals inactive by replacing them with ??
6374
- mask = mask.replace(literal, function($0, $1) {
6375
- literals.push($1);
6376
- return '@@@';
6377
- });
6378
- // Apply formatting rules
6379
- mask = mask.replace(token, function ($0) {
6380
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
6381
- });
6382
- // Inline literal values back into the formatted value
6383
- return mask.replace(/@@@/g, function() {
6384
- return literals.shift();
6385
- });
6386
- };
6387
-
6333
+ */
6334
+ fecha.format = function (dateObj, mask) {
6335
+ if (typeof dateObj === 'number') {
6336
+ dateObj = new Date(dateObj);
6337
+ }
6338
+
6339
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
6340
+ throw new Error('Invalid Date in fecha.format');
6341
+ }
6342
+
6343
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
6344
+
6345
+ var literals = [];
6346
+
6347
+ // Make literals inactive by replacing them with ??
6348
+ mask = mask.replace(literal, function ($0, $1) {
6349
+ literals.push($1);
6350
+ return '@@@';
6351
+ });
6352
+ // Apply formatting rules
6353
+ mask = mask.replace(token, function ($0) {
6354
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
6355
+ });
6356
+ // Inline literal values back into the formatted value
6357
+ return mask.replace(/@@@/g, function () {
6358
+ return literals.shift();
6359
+ });
6360
+ };
6361
+
6388
6362
  /**
6389
6363
  * Parse a date string into an object, changes - into /
6390
6364
  * @method parse
6391
6365
  * @param {string} dateStr Date string
6392
6366
  * @param {string} format Date parse format
6393
6367
  * @returns {Date|boolean}
6394
- */
6395
- fecha.parse = function (dateStr, format) {
6396
- if (typeof format !== 'string') {
6397
- throw new Error('Invalid format in fecha.parse');
6398
- }
6399
-
6400
- format = fecha.masks[format] || format;
6401
-
6402
- // Avoid regular expression denial of service, fail early for really long strings
6403
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
6404
- if (dateStr.length > 1000) {
6405
- return null;
6406
- }
6407
-
6408
- const dateInfo = {};
6409
- const parseInfo = [];
6410
- const literals = [];
6411
- format = format.replace(literal, function($0, $1) {
6412
- literals.push($1);
6413
- return '@@@';
6414
- });
6415
- let newFormat = regexEscape(format).replace(token, function ($0) {
6416
- if (parseFlags[$0]) {
6417
- const info = parseFlags[$0];
6418
- parseInfo.push(info[1]);
6419
- return '(' + info[0] + ')';
6420
- }
6421
-
6422
- return $0;
6423
- });
6424
- newFormat = newFormat.replace(/@@@/g, function() {
6425
- return literals.shift();
6426
- });
6427
- const matches = dateStr.match(new RegExp(newFormat, 'i'));
6428
- if (!matches) {
6429
- return null;
6430
- }
6431
-
6432
- for (let i = 1; i < matches.length; i++) {
6433
- parseInfo[i - 1](dateInfo, matches[i]);
6434
- }
6435
-
6436
- const today = new Date();
6437
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
6438
- dateInfo.hour = +dateInfo.hour + 12;
6439
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
6440
- dateInfo.hour = 0;
6441
- }
6442
-
6443
- let date;
6444
- if (dateInfo.timezoneOffset != null) {
6445
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
6446
- date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
6447
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
6448
- } else {
6449
- date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
6450
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
6451
- }
6452
- return date;
6453
- };
6454
-
6455
- // 导出fecha对象
6456
-
6457
-
6458
- // 以下是从date-util.js合并的函数
6459
- const newArray = function(start, end) {
6460
- let result = [];
6461
- for (let i = start; i <= end; i++) {
6462
- result.push(i);
6463
- }
6464
- return result;
6465
- };
6466
-
6467
- const getSettings = () => {
6468
- return {
6469
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
6470
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
6471
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
6472
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
6473
- amPm: ['上午', '下午']
6474
- };
6475
- };
6476
-
6477
- const toDate = function(date) {
6478
- return isDate(date) ? new Date(date) : null;
6479
- };
6480
-
6481
- const isDate = function(date) {
6482
- if (date === null || date === undefined) return false;
6483
- if (isNaN(new Date(date).getTime())) return false;
6484
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
6485
- return true;
6486
- };
6487
-
6488
- const isDateObject = function(val) {
6489
- return val instanceof Date;
6490
- };
6491
-
6492
- const formatDate = function (date, format = 'yyyy-MM-dd') {
6493
- // 处理多种输入类型
6494
- if (!date) return '';
6495
-
6496
- // 如果是时间戳,转成日期对象
6497
- if (typeof date === 'number') {
6498
- date = new Date(date);
6499
- }
6500
- // 如果是字符串,转成日期对象
6501
- if (typeof date === 'string') {
6502
- date = new Date(date);
6503
- }
6504
-
6505
- // 调用toDate进一步验证和转换
6506
- date = toDate(date);
6507
- if (!date) return '';
6508
-
6509
- // 兼容大写和小写的格式标记
6510
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
6511
- const lowercaseFormat = format
6512
- .replace(/YYYY/g, 'yyyy')
6513
- .replace(/D/g, 'd')
6514
-
6515
- // 使用fecha库进行格式化,支持中文配置
6516
- const str = fecha.format(date, lowercaseFormat, getSettings());
6517
- return str;
6518
- };
6519
-
6520
- const parseDate = function(string, format) {
6521
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
6522
- };
6523
-
6524
- const getDayCountOfMonth = function(year, month) {
6525
- if (month === 3 || month === 5 || month === 8 || month === 10) {
6526
- return 30;
6527
- }
6528
-
6529
- if (month === 1) {
6530
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
6531
- return 29;
6532
- } else {
6533
- return 28;
6534
- }
6535
- }
6536
-
6537
- return 31;
6538
- };
6539
-
6540
- const getDayCountOfYear = function(year) {
6541
- const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
6542
- return isLeapYear ? 366 : 365;
6543
- };
6544
-
6545
- const getFirstDayOfMonth = function(date) {
6546
- const temp = new Date(date.getTime());
6547
- temp.setDate(1);
6548
- return temp.getDay();
6549
- };
6550
-
6551
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
6552
- // {prev, next} Date should work for Daylight Saving Time
6553
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
6554
- const prevDate = function(date, amount = 1) {
6555
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
6556
- };
6557
-
6558
- const nextDate = function(date, amount = 1) {
6559
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
6560
- };
6561
-
6562
- const getStartDateOfMonth = function(year, month) {
6563
- const result = new Date(year, month, 1);
6564
- const day = result.getDay();
6565
-
6566
- if (day === 0) {
6567
- return prevDate(result, 7);
6568
- } else {
6569
- return prevDate(result, day);
6570
- }
6571
- };
6572
-
6573
- const getWeekNumber = function(date) {
6574
- // 支持多种输入类型
6575
- if (!date||!isDate(date)) {
6576
- date = new Date();
6577
- }
6578
- if (typeof date === 'string') {
6579
- date = new Date(date);
6580
- }
6581
-
6582
- // 验证日期有效性
6583
- if (!isDate(date)) return null;
6584
-
6585
- const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
6586
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
6587
- // 将星期日的星期数设为7
6588
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
6589
- // 获取当年的第一天
6590
- const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
6591
- // 计算到最近的星期四的完整周数
6592
- const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
6593
- // 返回周数
6594
- return weekNo;
6595
- };
6596
-
6597
- const getRangeHours = function(ranges) {
6598
- const hours = [];
6599
- let disabledHours = [];
6600
-
6601
- (ranges || []).forEach(range => {
6602
- const value = range.map(date => date.getHours());
6603
-
6604
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
6605
- });
6606
-
6607
- if (disabledHours.length) {
6608
- for (let i = 0; i < 24; i++) {
6609
- hours[i] = disabledHours.indexOf(i) === -1;
6610
- }
6611
- } else {
6612
- for (let i = 0; i < 24; i++) {
6613
- hours[i] = false;
6614
- }
6615
- }
6616
-
6617
- return hours;
6618
- };
6619
-
6620
- const getPrevMonthLastDays = (date, amount) => {
6621
- if (amount <= 0) return [];
6622
- const temp = new Date(date.getTime());
6623
- temp.setDate(0);
6624
- const lastDay = temp.getDate();
6625
- return range(amount).map((_, index) => lastDay - (amount - index - 1));
6626
- };
6627
-
6628
- const getMonthDays = (date) => {
6629
- const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
6630
- const days = temp.getDate();
6631
- return range(days).map((_, index) => index + 1);
6632
- };
6633
-
6634
- function setRangeData(arr, start, end, value) {
6635
- for (let i = start; i < end; i++) {
6636
- arr[i] = value;
6637
- }
6638
- }
6639
-
6640
- const getRangeMinutes = function(ranges, hour) {
6641
- const minutes = new Array(60);
6642
-
6643
- if (ranges.length > 0) {
6644
- ranges.forEach(range => {
6645
- const start = range[0];
6646
- const end = range[1];
6647
- const startHour = start.getHours();
6648
- const startMinute = start.getMinutes();
6649
- const endHour = end.getHours();
6650
- const endMinute = end.getMinutes();
6651
- if (startHour === hour && endHour !== hour) {
6652
- setRangeData(minutes, startMinute, 60, true);
6653
- } else if (startHour === hour && endHour === hour) {
6654
- setRangeData(minutes, startMinute, endMinute + 1, true);
6655
- } else if (startHour !== hour && endHour === hour) {
6656
- setRangeData(minutes, 0, endMinute + 1, true);
6657
- } else if (startHour < hour && endHour > hour) {
6658
- setRangeData(minutes, 0, 60, true);
6659
- }
6660
- });
6661
- } else {
6662
- setRangeData(minutes, 0, 60, true);
6663
- }
6664
- return minutes;
6665
- };
6666
-
6667
- const range = function(n) {
6668
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
6669
- return Array.apply(null, {length: n}).map((_, n) => n);
6670
- };
6671
-
6672
- const modifyDate = function(date, y, m, d) {
6673
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
6674
- };
6675
-
6676
- const modifyTime = function(date, h, m, s) {
6677
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
6678
- };
6679
-
6680
- const modifyWithTimeString = (date, time) => {
6681
- if (date == null || !time) {
6682
- return date;
6683
- }
6684
- time = parseDate(time, 'HH:mm:ss');
6685
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
6686
- };
6687
-
6688
- const clearTime = function(date) {
6689
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
6690
- };
6691
-
6692
- const clearMilliseconds = function(date) {
6693
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
6694
- };
6695
-
6696
- const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
6697
- // TODO: refactory a more elegant solution
6698
- if (ranges.length === 0) return date;
6699
- const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
6700
- const ndate = normalizeDate(date);
6701
- const nranges = ranges.map(range => range.map(normalizeDate));
6702
- if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
6703
-
6704
- let minDate = nranges[0][0];
6705
- let maxDate = nranges[0][0];
6706
-
6707
- nranges.forEach(nrange => {
6708
- minDate = new Date(Math.min(nrange[0], minDate));
6709
- maxDate = new Date(Math.max(nrange[1], minDate));
6710
- });
6711
-
6712
- const ret = ndate < minDate ? minDate : maxDate;
6713
- // preserve Year/Month/Date
6714
- return modifyDate(
6715
- ret,
6716
- date.getFullYear(),
6717
- date.getMonth(),
6718
- date.getDate()
6719
- );
6720
- };
6721
-
6722
- const timeWithinRange = function(date, selectableRange, format) {
6723
- const limitedDate = limitTimeRange(date, selectableRange, format);
6724
- return limitedDate.getTime() === date.getTime();
6725
- };
6726
-
6727
- const changeYearMonthAndClampDate = function(date, year, month) {
6728
- // clamp date to the number of days in `year`, `month`
6729
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
6730
- const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
6731
- return modifyDate(date, year, month, monthDate);
6732
- };
6733
-
6734
- const prevMonth = function(date) {
6735
- const year = date.getFullYear();
6736
- const month = date.getMonth();
6737
- return month === 0
6738
- ? changeYearMonthAndClampDate(date, year - 1, 11)
6739
- : changeYearMonthAndClampDate(date, year, month - 1);
6740
- };
6741
-
6742
- const nextMonth = function(date) {
6743
- const year = date.getFullYear();
6744
- const month = date.getMonth();
6745
- return month === 11
6746
- ? changeYearMonthAndClampDate(date, year + 1, 0)
6747
- : changeYearMonthAndClampDate(date, year, month + 1);
6748
- };
6749
-
6750
- const prevYear = function(date, amount = 1) {
6751
- const year = date.getFullYear();
6752
- const month = date.getMonth();
6753
- return changeYearMonthAndClampDate(date, year - amount, month);
6754
- };
6755
-
6756
- const nextYear = function(date, amount = 1) {
6757
- const year = date.getFullYear();
6758
- const month = date.getMonth();
6759
- return changeYearMonthAndClampDate(date, year + amount, month);
6760
- };
6761
-
6762
- const extractDateFormat = function(format) {
6763
- return format
6764
- .replace(/\W?m{1,2}|\W?ZZ/g, '')
6765
- .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
6766
- .trim();
6767
- };
6768
-
6769
- const extractTimeFormat = function(format) {
6770
- return format
6771
- .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
6772
- .trim();
6773
- };
6774
-
6775
- const validateRangeInOneMonth = function(start, end) {
6776
- return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
6777
- };
6778
-
6368
+ */
6369
+ fecha.parse = function (dateStr, format) {
6370
+ if (typeof format !== 'string') {
6371
+ throw new Error('Invalid format in fecha.parse');
6372
+ }
6373
+
6374
+ format = fecha.masks[format] || format;
6375
+
6376
+ // Avoid regular expression denial of service, fail early for really long strings
6377
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
6378
+ if (dateStr.length > 1000) {
6379
+ return null;
6380
+ }
6381
+
6382
+ var dateInfo = {};
6383
+ var parseInfo = [];
6384
+ var literals = [];
6385
+ format = format.replace(literal, function ($0, $1) {
6386
+ literals.push($1);
6387
+ return '@@@';
6388
+ });
6389
+ var newFormat = regexEscape(format).replace(token, function ($0) {
6390
+ if (parseFlags[$0]) {
6391
+ var info = parseFlags[$0];
6392
+ parseInfo.push(info[1]);
6393
+ return '(' + info[0] + ')';
6394
+ }
6395
+
6396
+ return $0;
6397
+ });
6398
+ newFormat = newFormat.replace(/@@@/g, function () {
6399
+ return literals.shift();
6400
+ });
6401
+ var matches = dateStr.match(new RegExp(newFormat, 'i'));
6402
+ if (!matches) {
6403
+ return null;
6404
+ }
6405
+
6406
+ for (var i = 1; i < matches.length; i++) {
6407
+ parseInfo[i - 1](dateInfo, matches[i]);
6408
+ }
6409
+
6410
+ var today = new Date();
6411
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
6412
+ dateInfo.hour = +dateInfo.hour + 12;
6413
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
6414
+ dateInfo.hour = 0;
6415
+ }
6416
+
6417
+ var date = void 0;
6418
+ if (dateInfo.timezoneOffset != null) {
6419
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
6420
+ 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));
6421
+ } else {
6422
+ 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);
6423
+ }
6424
+ return date;
6425
+ };
6426
+
6427
+ // 导出fecha对象
6428
+
6429
+
6430
+ // 以下是从date-util.js合并的函数
6431
+ var newArray = function newArray(start, end) {
6432
+ var result = [];
6433
+ for (var i = start; i <= end; i++) {
6434
+ result.push(i);
6435
+ }
6436
+ return result;
6437
+ };
6438
+
6439
+ var getSettings = function getSettings() {
6440
+ return {
6441
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
6442
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
6443
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
6444
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
6445
+ amPm: ['上午', '下午']
6446
+ };
6447
+ };
6448
+
6449
+ var toDate = function toDate(date) {
6450
+ return isDate(date) ? new Date(date) : null;
6451
+ };
6452
+
6453
+ var isDate = function isDate(date) {
6454
+ if (date === null || date === undefined) return false;
6455
+ if (isNaN(new Date(date).getTime())) return false;
6456
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
6457
+ return true;
6458
+ };
6459
+
6460
+ var isDateObject = function isDateObject(val) {
6461
+ return val instanceof Date;
6462
+ };
6463
+
6464
+ var formatDate = function formatDate(date) {
6465
+ var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
6466
+
6467
+ // 处理多种输入类型
6468
+ if (!date) return '';
6469
+
6470
+ // 如果是时间戳,转成日期对象
6471
+ if (typeof date === 'number') {
6472
+ date = new Date(date);
6473
+ }
6474
+ // 如果是字符串,转成日期对象
6475
+ if (typeof date === 'string') {
6476
+ date = new Date(date);
6477
+ }
6478
+
6479
+ // 调用toDate进一步验证和转换
6480
+ date = toDate(date);
6481
+ if (!date) return '';
6482
+
6483
+ // 兼容大写和小写的格式标记
6484
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
6485
+ var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
6486
+
6487
+ // 使用fecha库进行格式化,支持中文配置
6488
+ var str = fecha.format(date, lowercaseFormat, getSettings());
6489
+ return str;
6490
+ };
6491
+
6492
+ var parseDate = function parseDate(string, format) {
6493
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
6494
+ };
6495
+
6496
+ var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
6497
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
6498
+ return 30;
6499
+ }
6500
+
6501
+ if (month === 1) {
6502
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
6503
+ return 29;
6504
+ } else {
6505
+ return 28;
6506
+ }
6507
+ }
6508
+
6509
+ return 31;
6510
+ };
6511
+
6512
+ var getDayCountOfYear = function getDayCountOfYear(year) {
6513
+ var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
6514
+ return isLeapYear ? 366 : 365;
6515
+ };
6516
+
6517
+ var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
6518
+ var temp = new Date(date.getTime());
6519
+ temp.setDate(1);
6520
+ return temp.getDay();
6521
+ };
6522
+
6523
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
6524
+ // {prev, next} Date should work for Daylight Saving Time
6525
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
6526
+ var prevDate = function prevDate(date) {
6527
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6528
+
6529
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
6530
+ };
6531
+
6532
+ var nextDate = function nextDate(date) {
6533
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6534
+
6535
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
6536
+ };
6537
+
6538
+ var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
6539
+ var result = new Date(year, month, 1);
6540
+ var day = result.getDay();
6541
+
6542
+ if (day === 0) {
6543
+ return prevDate(result, 7);
6544
+ } else {
6545
+ return prevDate(result, day);
6546
+ }
6547
+ };
6548
+
6549
+ var getWeekNumber = function getWeekNumber(date) {
6550
+ // 支持多种输入类型
6551
+ if (!date || !isDate(date)) {
6552
+ date = new Date();
6553
+ }
6554
+ if (typeof date === 'string') {
6555
+ date = new Date(date);
6556
+ }
6557
+
6558
+ // 验证日期有效性
6559
+ if (!isDate(date)) return null;
6560
+
6561
+ var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
6562
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
6563
+ // 将星期日的星期数设为7
6564
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
6565
+ // 获取当年的第一天
6566
+ var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
6567
+ // 计算到最近的星期四的完整周数
6568
+ var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
6569
+ // 返回周数
6570
+ return weekNo;
6571
+ };
6572
+
6573
+ var getRangeHours = function getRangeHours(ranges) {
6574
+ var hours = [];
6575
+ var disabledHours = [];
6576
+
6577
+ (ranges || []).forEach(function (range) {
6578
+ var value = range.map(function (date) {
6579
+ return date.getHours();
6580
+ });
6581
+
6582
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
6583
+ });
6584
+
6585
+ if (disabledHours.length) {
6586
+ for (var i = 0; i < 24; i++) {
6587
+ hours[i] = disabledHours.indexOf(i) === -1;
6588
+ }
6589
+ } else {
6590
+ for (var _i = 0; _i < 24; _i++) {
6591
+ hours[_i] = false;
6592
+ }
6593
+ }
6594
+
6595
+ return hours;
6596
+ };
6597
+
6598
+ var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
6599
+ if (amount <= 0) return [];
6600
+ var temp = new Date(date.getTime());
6601
+ temp.setDate(0);
6602
+ var lastDay = temp.getDate();
6603
+ return range(amount).map(function (_, index) {
6604
+ return lastDay - (amount - index - 1);
6605
+ });
6606
+ };
6607
+
6608
+ var getMonthDays = function getMonthDays(date) {
6609
+ var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
6610
+ var days = temp.getDate();
6611
+ return range(days).map(function (_, index) {
6612
+ return index + 1;
6613
+ });
6614
+ };
6615
+
6616
+ function setRangeData(arr, start, end, value) {
6617
+ for (var i = start; i < end; i++) {
6618
+ arr[i] = value;
6619
+ }
6620
+ }
6621
+
6622
+ var getRangeMinutes = function getRangeMinutes(ranges, hour) {
6623
+ var minutes = new Array(60);
6624
+
6625
+ if (ranges.length > 0) {
6626
+ ranges.forEach(function (range) {
6627
+ var start = range[0];
6628
+ var end = range[1];
6629
+ var startHour = start.getHours();
6630
+ var startMinute = start.getMinutes();
6631
+ var endHour = end.getHours();
6632
+ var endMinute = end.getMinutes();
6633
+ if (startHour === hour && endHour !== hour) {
6634
+ setRangeData(minutes, startMinute, 60, true);
6635
+ } else if (startHour === hour && endHour === hour) {
6636
+ setRangeData(minutes, startMinute, endMinute + 1, true);
6637
+ } else if (startHour !== hour && endHour === hour) {
6638
+ setRangeData(minutes, 0, endMinute + 1, true);
6639
+ } else if (startHour < hour && endHour > hour) {
6640
+ setRangeData(minutes, 0, 60, true);
6641
+ }
6642
+ });
6643
+ } else {
6644
+ setRangeData(minutes, 0, 60, true);
6645
+ }
6646
+ return minutes;
6647
+ };
6648
+
6649
+ var range = function range(n) {
6650
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
6651
+ return Array.apply(null, { length: n }).map(function (_, n) {
6652
+ return n;
6653
+ });
6654
+ };
6655
+
6656
+ var modifyDate = function modifyDate(date, y, m, d) {
6657
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
6658
+ };
6659
+
6660
+ var modifyTime = function modifyTime(date, h, m, s) {
6661
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
6662
+ };
6663
+
6664
+ var modifyWithTimeString = function modifyWithTimeString(date, time) {
6665
+ if (date == null || !time) {
6666
+ return date;
6667
+ }
6668
+ time = parseDate(time, 'HH:mm:ss');
6669
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
6670
+ };
6671
+
6672
+ var clearTime = function clearTime(date) {
6673
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
6674
+ };
6675
+
6676
+ var clearMilliseconds = function clearMilliseconds(date) {
6677
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
6678
+ };
6679
+
6680
+ var limitTimeRange = function limitTimeRange(date, ranges) {
6681
+ var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
6682
+
6683
+ // TODO: refactory a more elegant solution
6684
+ if (ranges.length === 0) return date;
6685
+ var normalizeDate = function normalizeDate(date) {
6686
+ return fecha.parse(fecha.format(date, format), format);
6687
+ };
6688
+ var ndate = normalizeDate(date);
6689
+ var nranges = ranges.map(function (range) {
6690
+ return range.map(normalizeDate);
6691
+ });
6692
+ if (nranges.some(function (nrange) {
6693
+ return ndate >= nrange[0] && ndate <= nrange[1];
6694
+ })) return date;
6695
+
6696
+ var minDate = nranges[0][0];
6697
+ var maxDate = nranges[0][0];
6698
+
6699
+ nranges.forEach(function (nrange) {
6700
+ minDate = new Date(Math.min(nrange[0], minDate));
6701
+ maxDate = new Date(Math.max(nrange[1], minDate));
6702
+ });
6703
+
6704
+ var ret = ndate < minDate ? minDate : maxDate;
6705
+ // preserve Year/Month/Date
6706
+ return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
6707
+ };
6708
+
6709
+ var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
6710
+ var limitedDate = limitTimeRange(date, selectableRange, format);
6711
+ return limitedDate.getTime() === date.getTime();
6712
+ };
6713
+
6714
+ var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
6715
+ // clamp date to the number of days in `year`, `month`
6716
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
6717
+ var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
6718
+ return modifyDate(date, year, month, monthDate);
6719
+ };
6720
+
6721
+ var prevMonth = function prevMonth(date) {
6722
+ var year = date.getFullYear();
6723
+ var month = date.getMonth();
6724
+ return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
6725
+ };
6726
+
6727
+ var nextMonth = function nextMonth(date) {
6728
+ var year = date.getFullYear();
6729
+ var month = date.getMonth();
6730
+ return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
6731
+ };
6732
+
6733
+ var prevYear = function prevYear(date) {
6734
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6735
+
6736
+ var year = date.getFullYear();
6737
+ var month = date.getMonth();
6738
+ return changeYearMonthAndClampDate(date, year - amount, month);
6739
+ };
6740
+
6741
+ var nextYear = function nextYear(date) {
6742
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6743
+
6744
+ var year = date.getFullYear();
6745
+ var month = date.getMonth();
6746
+ return changeYearMonthAndClampDate(date, year + amount, month);
6747
+ };
6748
+
6749
+ var extractDateFormat = function extractDateFormat(format) {
6750
+ return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
6751
+ };
6752
+
6753
+ var extractTimeFormat = function extractTimeFormat(format) {
6754
+ return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
6755
+ };
6756
+
6757
+ var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
6758
+ return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
6759
+ };
6760
+
6779
6761
  /**
6780
6762
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
6781
6763
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
6782
6764
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
6783
6765
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
6784
6766
  * @returns {number} 工作日数量
6785
- */
6786
- const calculateNetworkDays = function (start_date, end_date, holidays = []) {
6787
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
6788
- throw new Error(
6789
- "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
6790
- );
6791
- }
6792
-
6793
- const startDateObj = new Date(start_date);
6794
- const endDateObj = new Date(end_date);
6795
-
6796
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
6797
- throw new Error(
6798
- "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
6799
- );
6800
- }
6801
-
6802
- if (startDateObj > endDateObj) {
6803
- throw new Error('Start date should be earlier than or equal to end date.');
6804
- }
6805
-
6806
- let workdays = 0;
6807
-
6808
- // Iterate through each day in the date range
6809
- for (
6810
- let currentDate = new Date(startDateObj);
6811
- currentDate <= endDateObj;
6812
- currentDate.setDate(currentDate.getDate() + 1)
6813
- ) {
6814
- // Check if the current day is a weekend (Saturday or Sunday)
6815
- const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
6816
-
6817
- // Check if the current day is a holiday
6818
- const isHoliday = holidays.some((holiday) => {
6819
- const holidayDate = new Date(holiday);
6820
- return currentDate.toDateString() === holidayDate.toDateString();
6821
- });
6822
-
6823
- // If it's a workday (not a weekend or holiday), increment the workdays count
6824
- if (!isWeekend && !isHoliday) {
6825
- workdays++;
6826
- }
6827
- }
6828
-
6829
- return workdays;
6830
- };
6831
-
6767
+ */
6768
+ var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
6769
+ var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
6770
+
6771
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
6772
+ throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
6773
+ }
6774
+
6775
+ var startDateObj = new Date(start_date);
6776
+ var endDateObj = new Date(end_date);
6777
+
6778
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
6779
+ throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
6780
+ }
6781
+
6782
+ if (startDateObj > endDateObj) {
6783
+ throw new Error('Start date should be earlier than or equal to end date.');
6784
+ }
6785
+
6786
+ var workdays = 0;
6787
+
6788
+ // Iterate through each day in the date range
6789
+
6790
+ var _loop = function _loop(currentDate) {
6791
+ // Check if the current day is a weekend (Saturday or Sunday)
6792
+ var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
6793
+
6794
+ // Check if the current day is a holiday
6795
+ var isHoliday = holidays.some(function (holiday) {
6796
+ var holidayDate = new Date(holiday);
6797
+ return currentDate.toDateString() === holidayDate.toDateString();
6798
+ });
6799
+
6800
+ // If it's a workday (not a weekend or holiday), increment the workdays count
6801
+ if (!isWeekend && !isHoliday) {
6802
+ workdays++;
6803
+ }
6804
+ };
6805
+
6806
+ for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
6807
+ _loop(currentDate);
6808
+ }
6809
+
6810
+ return workdays;
6811
+ };
6812
+
6832
6813
  /**
6833
6814
  * 日期加减天数
6834
6815
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
6835
6816
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
6836
6817
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
6837
- */
6838
- const dateAddDays = function (start_date, days) {
6839
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
6840
- throw new Error(
6841
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
6842
- );
6843
- }
6844
-
6845
- const startDateObj = new Date(start_date);
6846
- if (isNaN(startDateObj.getTime())) {
6847
- throw new Error(
6848
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
6849
- );
6850
- }
6851
-
6852
- const resultDateObj = new Date(startDateObj);
6853
- resultDateObj.setDate(resultDateObj.getDate() + days);
6854
-
6855
- const resultYear = resultDateObj.getFullYear();
6856
- const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
6857
- const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
6858
-
6859
- return `${resultYear}-${resultMonth}-${resultDay}`;
6860
- };
6861
-
6818
+ */
6819
+ var dateAddDays = function dateAddDays(start_date, days) {
6820
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
6821
+ 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.");
6822
+ }
6823
+
6824
+ var startDateObj = new Date(start_date);
6825
+ if (isNaN(startDateObj.getTime())) {
6826
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6827
+ }
6828
+
6829
+ var resultDateObj = new Date(startDateObj);
6830
+ resultDateObj.setDate(resultDateObj.getDate() + days);
6831
+
6832
+ var resultYear = resultDateObj.getFullYear();
6833
+ var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
6834
+ var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
6835
+
6836
+ return resultYear + '-' + resultMonth + '-' + resultDay;
6837
+ };
6838
+
6862
6839
  /**
6863
6840
  * 计算两个日期之间的差值
6864
6841
  * @date 2023年12月14日
@@ -6866,182 +6843,180 @@ const dateAddDays = function (start_date, days) {
6866
6843
  * @param {String} end_date - 结束日期字符串
6867
6844
  * @param {String} unit - 单位:year/month/day
6868
6845
  * @returns {Number} 差值
6869
- */
6870
- const dateDiff = function (start_date, end_date, unit = 'day') {
6871
- // Assuming date strings are in "YYYY-MM-DD" format
6872
- var startDate = new Date(start_date);
6873
- var endDate = new Date(end_date);
6874
-
6875
- // If the date is invalid, return 0
6876
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
6877
- return 0;
6878
- }
6879
-
6880
- if (unit === 'year') {
6881
- return endDate.getFullYear() - startDate.getFullYear();
6882
- } else if (unit === 'month') {
6883
- return (
6884
- (endDate.getFullYear() - startDate.getFullYear()) * 12 +
6885
- (endDate.getMonth() - startDate.getMonth())
6886
- );
6887
- } else {
6888
- // Default to day
6889
- var timeDifference = endDate - startDate;
6890
- // Calculate days (86400000 milliseconds per day)
6891
- return Math.floor(timeDifference / 86400000);
6892
- }
6893
- };
6894
-
6846
+ */
6847
+ var dateDiff = function dateDiff(start_date, end_date) {
6848
+ var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
6849
+
6850
+ // Assuming date strings are in "YYYY-MM-DD" format
6851
+ var startDate = new Date(start_date);
6852
+ var endDate = new Date(end_date);
6853
+
6854
+ // If the date is invalid, return 0
6855
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
6856
+ return 0;
6857
+ }
6858
+
6859
+ if (unit === 'year') {
6860
+ return endDate.getFullYear() - startDate.getFullYear();
6861
+ } else if (unit === 'month') {
6862
+ return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
6863
+ } else {
6864
+ // Default to day
6865
+ var timeDifference = endDate - startDate;
6866
+ // Calculate days (86400000 milliseconds per day)
6867
+ return Math.floor(timeDifference / 86400000);
6868
+ }
6869
+ };
6870
+
6895
6871
  /**
6896
6872
  * 获取月份中的日期
6897
6873
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
6898
6874
  * @returns {number} 月份中的日期(1-31)
6899
- */
6900
- const dayOfMonth = function (date) {
6901
- if (typeof date !== 'string') {
6902
- throw new Error(
6903
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
6904
- );
6905
- }
6906
-
6907
- const dateObj = new Date(date);
6908
- if (isNaN(dateObj.getTime())) {
6909
- throw new Error(
6910
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
6911
- );
6912
- }
6913
-
6914
- return dateObj.getDate();
6915
- };
6916
-
6875
+ */
6876
+ var dayOfMonth = function dayOfMonth(date) {
6877
+ if (typeof date !== 'string') {
6878
+ throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6879
+ }
6880
+
6881
+ var dateObj = new Date(date);
6882
+ if (isNaN(dateObj.getTime())) {
6883
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6884
+ }
6885
+
6886
+ return dateObj.getDate();
6887
+ };
6888
+
6917
6889
  /**
6918
6890
  * 获取当前日期
6919
6891
  * @date 2022年5月7日
6920
6892
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
6921
6893
  * @returns {string} 当前日期的格式化字符串
6922
- */
6923
- const getCurrentDate = function (format = 'YYYY-MM-DD') {
6924
- return formatDate(new Date(), format);
6925
- };
6926
-
6894
+ */
6895
+ var getCurrentDate = function getCurrentDate() {
6896
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
6897
+
6898
+ return formatDate(new Date(), format);
6899
+ };
6900
+
6927
6901
  /**
6928
6902
  * 获取当前日期时间
6929
6903
  * @date 2022年5月7日
6930
6904
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
6931
6905
  * @returns {string} 当前日期时间的格式化字符串
6932
- */
6933
- const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
6934
- return formatDate(new Date(), format);
6935
- };
6936
-
6906
+ */
6907
+ var getCurrentDateTime = function getCurrentDateTime() {
6908
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
6909
+
6910
+ return formatDate(new Date(), format);
6911
+ };
6912
+
6937
6913
  /**
6938
6914
  * 获取小时
6939
6915
  * @date 2022年5月7日
6940
6916
  * @param {Date|string} [date] - 日期对象或日期字符串
6941
6917
  * @returns {number} 小时数(0-23)
6942
- */
6943
- const getHour = function (date) {
6944
- if (!date) {
6945
- return new Date().getHours();
6946
- }
6947
- if (typeof date === 'string') {
6948
- date = new Date(date);
6949
- }
6950
- return date.getHours();
6951
- };
6952
-
6918
+ */
6919
+ var getHour = function getHour(date) {
6920
+ if (!date) {
6921
+ return new Date().getHours();
6922
+ }
6923
+ if (typeof date === 'string') {
6924
+ date = new Date(date);
6925
+ }
6926
+ return date.getHours();
6927
+ };
6928
+
6953
6929
  /**
6954
6930
  * 获取分钟
6955
6931
  * @date 2022年5月7日
6956
6932
  * @param {Date|string} [date] - 日期对象或日期字符串
6957
6933
  * @returns {number} 分钟数(0-59)
6958
- */
6959
- const getMinute = function (date) {
6960
- if (!date) {
6961
- return new Date().getMinutes();
6962
- }
6963
- if (typeof date === 'string') {
6964
- date = new Date(date);
6965
- }
6966
- return date.getMinutes();
6967
- };
6968
-
6934
+ */
6935
+ var getMinute = function getMinute(date) {
6936
+ if (!date) {
6937
+ return new Date().getMinutes();
6938
+ }
6939
+ if (typeof date === 'string') {
6940
+ date = new Date(date);
6941
+ }
6942
+ return date.getMinutes();
6943
+ };
6944
+
6969
6945
  /**
6970
6946
  * 获取月份
6971
6947
  * @date 2022年5月7日
6972
6948
  * @param {Date|string} [date] - 日期对象或日期字符串
6973
6949
  * @returns {number} 月份数(1-12)
6974
- */
6975
- const getMonth = function (date) {
6976
- if (!date) {
6977
- return new Date().getMonth() + 1;
6978
- }
6979
- if (typeof date === 'string') {
6980
- date = new Date(date);
6981
- }
6982
- return date.getMonth() + 1;
6983
- };
6984
-
6950
+ */
6951
+ var getMonth = function getMonth(date) {
6952
+ if (!date) {
6953
+ return new Date().getMonth() + 1;
6954
+ }
6955
+ if (typeof date === 'string') {
6956
+ date = new Date(date);
6957
+ }
6958
+ return date.getMonth() + 1;
6959
+ };
6960
+
6985
6961
  /**
6986
6962
  * 获取秒
6987
6963
  * @date 2022年5月7日
6988
6964
  * @param {Date|string} [date] - 日期对象或日期字符串
6989
6965
  * @returns {number} 秒数(0-59)
6990
- */
6991
- const getSecond = function (date) {
6992
- if (!date) {
6993
- return new Date().getSeconds();
6994
- }
6995
- if (typeof date === 'string') {
6996
- date = new Date(date);
6997
- }
6998
- return date.getSeconds();
6999
- };
7000
-
6966
+ */
6967
+ var getSecond = function getSecond(date) {
6968
+ if (!date) {
6969
+ return new Date().getSeconds();
6970
+ }
6971
+ if (typeof date === 'string') {
6972
+ date = new Date(date);
6973
+ }
6974
+ return date.getSeconds();
6975
+ };
6976
+
7001
6977
  /**
7002
6978
  * 获取星期几
7003
6979
  * @date 2022年5月7日
7004
6980
  * @param {Date|string} [date] - 日期对象或日期字符串
7005
6981
  * @returns {number} 星期几(0-6,0表示星期日)
7006
- */
7007
- const getWeekday = function (date) {
7008
- if (!date) {
7009
- return new Date().getDay();
7010
- }
7011
- if (typeof date === 'string') {
7012
- date = new Date(date);
7013
- }
7014
- return date.getDay();
7015
- };
7016
-
7017
-
6982
+ */
6983
+ var getWeekday = function getWeekday(date) {
6984
+ if (!date) {
6985
+ return new Date().getDay();
6986
+ }
6987
+ if (typeof date === 'string') {
6988
+ date = new Date(date);
6989
+ }
6990
+ return date.getDay();
6991
+ };
6992
+
7018
6993
  /**
7019
6994
  * @desc 获取上午/下午/晚上
7020
6995
  * @author huangbo
7021
6996
  * @date 2022年5月7日
7022
6997
  * @param {String} [time] - 时间
7023
- **/
7024
- const timeCycle = function (time) {
7025
- let hour = 0;
7026
- if (!time) {
7027
- hour = new Date().getHours();
7028
- } else if (typeof time === 'string') {
7029
- // 从时间字符串中提取小时
7030
- const match = time.match(/^(\d{1,2})/);
7031
- if (match) {
7032
- hour = parseInt(match[1], 10);
7033
- }
7034
- } else if (typeof time === 'number') {
7035
- hour = time;
7036
- }
7037
- // 判断时间段
7038
- if (hour >= 5 && hour < 12) {
7039
- return '上午';
7040
- } else if (hour >= 12 && hour < 18) {
7041
- return '下午';
7042
- } else {
7043
- return '晚上';
7044
- }
6998
+ **/
6999
+ var timeCycle = function timeCycle(time) {
7000
+ var hour = 0;
7001
+ if (!time) {
7002
+ hour = new Date().getHours();
7003
+ } else if (typeof time === 'string') {
7004
+ // 从时间字符串中提取小时
7005
+ var match = time.match(/^(\d{1,2})/);
7006
+ if (match) {
7007
+ hour = parseInt(match[1], 10);
7008
+ }
7009
+ } else if (typeof time === 'number') {
7010
+ hour = time;
7011
+ }
7012
+ // 判断时间段
7013
+ if (hour >= 5 && hour < 12) {
7014
+ return '上午';
7015
+ } else if (hour >= 12 && hour < 18) {
7016
+ return '下午';
7017
+ } else {
7018
+ return '晚上';
7019
+ }
7045
7020
  };
7046
7021
 
7047
7022
  /***/ }),