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 = 218);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 225);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -4783,7 +4783,7 @@ module.exports = require("fetch-request-source");
4783
4783
 
4784
4784
  /***/ }),
4785
4785
 
4786
- /***/ 218:
4786
+ /***/ 225:
4787
4787
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4788
4788
 
4789
4789
  "use strict";
@@ -6366,759 +6366,736 @@ var changeInTime = '/baseIssueRules/changeInTime';
6366
6366
  /* unused harmony export getSecond */
6367
6367
  /* unused harmony export getWeekday */
6368
6368
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
6369
- /* Modified from https://github.com/taylorhakes/fecha
6370
- *
6371
- * The MIT License (MIT)
6372
- *
6373
- * Copyright (c) 2015 Taylor Hakes
6374
- *
6375
- * Permission is hereby granted, free of charge, to any person obtaining a copy
6376
- * of this software and associated documentation files (the "Software"), to deal
6377
- * in the Software without restriction, including without limitation the rights
6378
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6379
- * copies of the Software, and to permit persons to whom the Software is
6380
- * furnished to do so, subject to the following conditions:
6381
- *
6382
- * The above copyright notice and this permission notice shall be included in all
6383
- * copies or substantial portions of the Software.
6384
- *
6385
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6386
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6387
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6388
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6389
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
6390
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
6391
- * SOFTWARE.
6392
- */
6393
-
6394
- /*eslint-disable*/
6395
- // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
6396
-
6397
-
6369
+
6370
+
6398
6371
  /**
6399
6372
  * Parse or format dates
6400
6373
  * @class fecha
6401
- */
6402
- const fecha = {};
6403
- const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
6404
- const twoDigits = '\\d\\d?';
6405
- const threeDigits = '\\d{3}';
6406
- const fourDigits = '\\d{4}';
6407
- const word = '[^\\s]+';
6408
- const literal = /\[([^]*?)\]/gm;
6409
- const noop = function () {};
6410
-
6411
- function regexEscape(str) {
6412
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
6413
- }
6414
-
6415
- function shorten(arr, sLen) {
6416
- const newArr = [];
6417
- for (let i = 0, len = arr.length; i < len; i++) {
6418
- newArr.push(arr[i].substr(0, sLen));
6419
- }
6420
- return newArr;
6421
- }
6422
-
6423
- function monthUpdate() {
6424
- return function (d, v) {
6425
- const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
6426
- if (~index) {
6427
- d.month = index;
6428
- }
6429
- };
6430
- }
6431
-
6432
- function pad(val, len) {
6433
- val = String(val);
6434
- len = len || 2;
6435
- while (val.length < len) {
6436
- val = '0' + val;
6437
- }
6438
- return val;
6439
- }
6440
-
6441
- // 直接使用中文日期名称常量
6442
- const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
6443
- const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
6444
- const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
6445
- const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
6446
- const amPm = ['上午', '下午'];
6447
- const DoFn = function DoFn(D) {
6448
- return D + '日';
6449
- };
6450
-
6451
- const formatFlags = {
6452
- D: function(dateObj) {
6453
- return dateObj.getDay();
6454
- },
6455
- DD: function(dateObj) {
6456
- return pad(dateObj.getDay());
6457
- },
6458
- Do: function(dateObj) {
6459
- return DoFn(dateObj.getDate());
6460
- },
6461
- d: function(dateObj) {
6462
- return dateObj.getDate();
6463
- },
6464
- dd: function(dateObj) {
6465
- return pad(dateObj.getDate());
6466
- },
6467
- ddd: function(dateObj) {
6468
- return dayNamesShort[dateObj.getDay()];
6469
- },
6470
- dddd: function(dateObj) {
6471
- return dayNames[dateObj.getDay()];
6472
- },
6473
- M: function(dateObj) {
6474
- return dateObj.getMonth() + 1;
6475
- },
6476
- MM: function(dateObj) {
6477
- return pad(dateObj.getMonth() + 1);
6478
- },
6479
- MMM: function(dateObj) {
6480
- return monthNamesShort[dateObj.getMonth()];
6481
- },
6482
- MMMM: function(dateObj) {
6483
- return monthNames[dateObj.getMonth()];
6484
- },
6485
- yy: function(dateObj) {
6486
- return pad(String(dateObj.getFullYear()), 4).substr(2);
6487
- },
6488
- yyyy: function(dateObj) {
6489
- return pad(dateObj.getFullYear(), 4);
6490
- },
6491
- h: function(dateObj) {
6492
- return dateObj.getHours() % 12 || 12;
6493
- },
6494
- hh: function(dateObj) {
6495
- return pad(dateObj.getHours() % 12 || 12);
6496
- },
6497
- H: function(dateObj) {
6498
- return dateObj.getHours();
6499
- },
6500
- HH: function(dateObj) {
6501
- return pad(dateObj.getHours());
6502
- },
6503
- m: function(dateObj) {
6504
- return dateObj.getMinutes();
6505
- },
6506
- mm: function(dateObj) {
6507
- return pad(dateObj.getMinutes());
6508
- },
6509
- s: function(dateObj) {
6510
- return dateObj.getSeconds();
6511
- },
6512
- ss: function(dateObj) {
6513
- return pad(dateObj.getSeconds());
6514
- },
6515
- S: function(dateObj) {
6516
- return Math.round(dateObj.getMilliseconds() / 100);
6517
- },
6518
- SS: function(dateObj) {
6519
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
6520
- },
6521
- SSS: function(dateObj) {
6522
- return pad(dateObj.getMilliseconds(), 3);
6523
- },
6524
- a: function(dateObj) {
6525
- return dateObj.getHours() < 12 ? '上午' : '下午';
6526
- },
6527
- A: function(dateObj) {
6528
- return dateObj.getHours() < 12 ? '上午' : '下午';
6529
- },
6530
- ZZ: function(dateObj) {
6531
- const o = dateObj.getTimezoneOffset();
6532
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
6533
- }
6534
- };
6535
-
6536
- const parseFlags = {
6537
- d: [twoDigits, function (d, v) {
6538
- d.day = v;
6539
- }],
6540
- Do: [twoDigits + word, function (d, v) {
6541
- d.day = parseInt(v, 10);
6542
- }],
6543
- M: [twoDigits, function (d, v) {
6544
- d.month = v - 1;
6545
- }],
6546
- yy: [twoDigits, function (d, v) {
6547
- const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
6548
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
6549
- }],
6550
- h: [twoDigits, function (d, v) {
6551
- d.hour = v;
6552
- }],
6553
- m: [twoDigits, function (d, v) {
6554
- d.minute = v;
6555
- }],
6556
- s: [twoDigits, function (d, v) {
6557
- d.second = v;
6558
- }],
6559
- yyyy: [fourDigits, function (d, v) {
6560
- d.year = v;
6561
- }],
6562
- S: ['\\d', function (d, v) {
6563
- d.millisecond = v * 100;
6564
- }],
6565
- SS: ['\\d{2}', function (d, v) {
6566
- d.millisecond = v * 10;
6567
- }],
6568
- SSS: [threeDigits, function (d, v) {
6569
- d.millisecond = v;
6570
- }],
6571
- D: [twoDigits, noop],
6572
- ddd: [word, noop],
6573
- MMM: [word, monthUpdate('monthNamesShort')],
6574
- MMMM: [word, monthUpdate('monthNames')],
6575
- a: [word, function (d, v) {
6576
- const val = v.toLowerCase();
6577
- if (val === '上午') {
6578
- d.isPm = false;
6579
- } else if (val === '下午') {
6580
- d.isPm = true;
6581
- }
6582
- }],
6583
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
6584
- let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
6585
-
6586
- if (parts) {
6587
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
6588
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
6589
- }
6590
- }]
6591
- };
6592
- parseFlags.dd = parseFlags.d;
6593
- parseFlags.dddd = parseFlags.ddd;
6594
- parseFlags.DD = parseFlags.D;
6595
- parseFlags.mm = parseFlags.m;
6596
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
6597
- parseFlags.MM = parseFlags.M;
6598
- parseFlags.ss = parseFlags.s;
6599
- parseFlags.A = parseFlags.a;
6600
-
6601
-
6602
- // Some common format strings
6603
- fecha.masks = {
6604
- default: 'ddd MMM dd yyyy HH:mm:ss',
6605
- shortDate: 'M/D/yy',
6606
- mediumDate: 'MMM d, yyyy',
6607
- longDate: 'MMMM d, yyyy',
6608
- fullDate: 'dddd, MMMM d, yyyy',
6609
- shortTime: 'HH:mm',
6610
- mediumTime: 'HH:mm:ss',
6611
- longTime: 'HH:mm:ss.SSS'
6612
- };
6613
-
6374
+ */
6375
+ var fecha = {};
6376
+ var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
6377
+ var twoDigits = '\\d\\d?';
6378
+ var threeDigits = '\\d{3}';
6379
+ var fourDigits = '\\d{4}';
6380
+ var word = '[^\\s]+';
6381
+ var literal = /\[([^]*?)\]/gm;
6382
+ var noop = function noop() {};
6383
+
6384
+ function regexEscape(str) {
6385
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
6386
+ }
6387
+
6388
+ function shorten(arr, sLen) {
6389
+ var newArr = [];
6390
+ for (var i = 0, len = arr.length; i < len; i++) {
6391
+ newArr.push(arr[i].substr(0, sLen));
6392
+ }
6393
+ return newArr;
6394
+ }
6395
+
6396
+ function monthUpdate() {
6397
+ return function (d, v) {
6398
+ var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
6399
+ if (~index) {
6400
+ d.month = index;
6401
+ }
6402
+ };
6403
+ }
6404
+
6405
+ function pad(val, len) {
6406
+ val = String(val);
6407
+ len = len || 2;
6408
+ while (val.length < len) {
6409
+ val = '0' + val;
6410
+ }
6411
+ return val;
6412
+ }
6413
+
6414
+ // 直接使用中文日期名称常量
6415
+ var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
6416
+ var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
6417
+ var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
6418
+ var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
6419
+ var amPm = ['上午', '下午'];
6420
+ var DoFn = function DoFn(D) {
6421
+ return D + '日';
6422
+ };
6423
+
6424
+ var formatFlags = {
6425
+ D: function D(dateObj) {
6426
+ return dateObj.getDay();
6427
+ },
6428
+ DD: function DD(dateObj) {
6429
+ return pad(dateObj.getDay());
6430
+ },
6431
+ Do: function Do(dateObj) {
6432
+ return DoFn(dateObj.getDate());
6433
+ },
6434
+ d: function d(dateObj) {
6435
+ return dateObj.getDate();
6436
+ },
6437
+ dd: function dd(dateObj) {
6438
+ return pad(dateObj.getDate());
6439
+ },
6440
+ ddd: function ddd(dateObj) {
6441
+ return dayNamesShort[dateObj.getDay()];
6442
+ },
6443
+ dddd: function dddd(dateObj) {
6444
+ return dayNames[dateObj.getDay()];
6445
+ },
6446
+ M: function M(dateObj) {
6447
+ return dateObj.getMonth() + 1;
6448
+ },
6449
+ MM: function MM(dateObj) {
6450
+ return pad(dateObj.getMonth() + 1);
6451
+ },
6452
+ MMM: function MMM(dateObj) {
6453
+ return monthNamesShort[dateObj.getMonth()];
6454
+ },
6455
+ MMMM: function MMMM(dateObj) {
6456
+ return monthNames[dateObj.getMonth()];
6457
+ },
6458
+ yy: function yy(dateObj) {
6459
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
6460
+ },
6461
+ yyyy: function yyyy(dateObj) {
6462
+ return pad(dateObj.getFullYear(), 4);
6463
+ },
6464
+ h: function h(dateObj) {
6465
+ return dateObj.getHours() % 12 || 12;
6466
+ },
6467
+ hh: function hh(dateObj) {
6468
+ return pad(dateObj.getHours() % 12 || 12);
6469
+ },
6470
+ H: function H(dateObj) {
6471
+ return dateObj.getHours();
6472
+ },
6473
+ HH: function HH(dateObj) {
6474
+ return pad(dateObj.getHours());
6475
+ },
6476
+ m: function m(dateObj) {
6477
+ return dateObj.getMinutes();
6478
+ },
6479
+ mm: function mm(dateObj) {
6480
+ return pad(dateObj.getMinutes());
6481
+ },
6482
+ s: function s(dateObj) {
6483
+ return dateObj.getSeconds();
6484
+ },
6485
+ ss: function ss(dateObj) {
6486
+ return pad(dateObj.getSeconds());
6487
+ },
6488
+ S: function S(dateObj) {
6489
+ return Math.round(dateObj.getMilliseconds() / 100);
6490
+ },
6491
+ SS: function SS(dateObj) {
6492
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
6493
+ },
6494
+ SSS: function SSS(dateObj) {
6495
+ return pad(dateObj.getMilliseconds(), 3);
6496
+ },
6497
+ a: function a(dateObj) {
6498
+ return dateObj.getHours() < 12 ? '上午' : '下午';
6499
+ },
6500
+ A: function A(dateObj) {
6501
+ return dateObj.getHours() < 12 ? '上午' : '下午';
6502
+ },
6503
+ ZZ: function ZZ(dateObj) {
6504
+ var o = dateObj.getTimezoneOffset();
6505
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
6506
+ }
6507
+ };
6508
+
6509
+ var parseFlags = {
6510
+ d: [twoDigits, function (d, v) {
6511
+ d.day = v;
6512
+ }],
6513
+ Do: [twoDigits + word, function (d, v) {
6514
+ d.day = parseInt(v, 10);
6515
+ }],
6516
+ M: [twoDigits, function (d, v) {
6517
+ d.month = v - 1;
6518
+ }],
6519
+ yy: [twoDigits, function (d, v) {
6520
+ var da = new Date(),
6521
+ cent = +('' + da.getFullYear()).substr(0, 2);
6522
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
6523
+ }],
6524
+ h: [twoDigits, function (d, v) {
6525
+ d.hour = v;
6526
+ }],
6527
+ m: [twoDigits, function (d, v) {
6528
+ d.minute = v;
6529
+ }],
6530
+ s: [twoDigits, function (d, v) {
6531
+ d.second = v;
6532
+ }],
6533
+ yyyy: [fourDigits, function (d, v) {
6534
+ d.year = v;
6535
+ }],
6536
+ S: ['\\d', function (d, v) {
6537
+ d.millisecond = v * 100;
6538
+ }],
6539
+ SS: ['\\d{2}', function (d, v) {
6540
+ d.millisecond = v * 10;
6541
+ }],
6542
+ SSS: [threeDigits, function (d, v) {
6543
+ d.millisecond = v;
6544
+ }],
6545
+ D: [twoDigits, noop],
6546
+ ddd: [word, noop],
6547
+ MMM: [word, monthUpdate('monthNamesShort')],
6548
+ MMMM: [word, monthUpdate('monthNames')],
6549
+ a: [word, function (d, v) {
6550
+ var val = v.toLowerCase();
6551
+ if (val === '上午') {
6552
+ d.isPm = false;
6553
+ } else if (val === '下午') {
6554
+ d.isPm = true;
6555
+ }
6556
+ }],
6557
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
6558
+ var parts = (v + '').match(/([+-]|\d\d)/gi),
6559
+ minutes = void 0;
6560
+
6561
+ if (parts) {
6562
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
6563
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
6564
+ }
6565
+ }]
6566
+ };
6567
+ parseFlags.dd = parseFlags.d;
6568
+ parseFlags.dddd = parseFlags.ddd;
6569
+ parseFlags.DD = parseFlags.D;
6570
+ parseFlags.mm = parseFlags.m;
6571
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
6572
+ parseFlags.MM = parseFlags.M;
6573
+ parseFlags.ss = parseFlags.s;
6574
+ parseFlags.A = parseFlags.a;
6575
+
6576
+ // Some common format strings
6577
+ fecha.masks = {
6578
+ default: 'ddd MMM dd yyyy HH:mm:ss',
6579
+ shortDate: 'M/D/yy',
6580
+ mediumDate: 'MMM d, yyyy',
6581
+ longDate: 'MMMM d, yyyy',
6582
+ fullDate: 'dddd, MMMM d, yyyy',
6583
+ shortTime: 'HH:mm',
6584
+ mediumTime: 'HH:mm:ss',
6585
+ longTime: 'HH:mm:ss.SSS'
6586
+ };
6587
+
6614
6588
  /***
6615
6589
  * Format a date
6616
6590
  * @method format
6617
6591
  * @param {Date|number} dateObj
6618
6592
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
6619
- */
6620
- fecha.format = function (dateObj, mask) {
6621
- if (typeof dateObj === 'number') {
6622
- dateObj = new Date(dateObj);
6623
- }
6624
-
6625
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
6626
- throw new Error('Invalid Date in fecha.format');
6627
- }
6628
-
6629
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
6630
-
6631
- const literals = [];
6632
-
6633
- // Make literals inactive by replacing them with ??
6634
- mask = mask.replace(literal, function($0, $1) {
6635
- literals.push($1);
6636
- return '@@@';
6637
- });
6638
- // Apply formatting rules
6639
- mask = mask.replace(token, function ($0) {
6640
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
6641
- });
6642
- // Inline literal values back into the formatted value
6643
- return mask.replace(/@@@/g, function() {
6644
- return literals.shift();
6645
- });
6646
- };
6647
-
6593
+ */
6594
+ fecha.format = function (dateObj, mask) {
6595
+ if (typeof dateObj === 'number') {
6596
+ dateObj = new Date(dateObj);
6597
+ }
6598
+
6599
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
6600
+ throw new Error('Invalid Date in fecha.format');
6601
+ }
6602
+
6603
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
6604
+
6605
+ var literals = [];
6606
+
6607
+ // Make literals inactive by replacing them with ??
6608
+ mask = mask.replace(literal, function ($0, $1) {
6609
+ literals.push($1);
6610
+ return '@@@';
6611
+ });
6612
+ // Apply formatting rules
6613
+ mask = mask.replace(token, function ($0) {
6614
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
6615
+ });
6616
+ // Inline literal values back into the formatted value
6617
+ return mask.replace(/@@@/g, function () {
6618
+ return literals.shift();
6619
+ });
6620
+ };
6621
+
6648
6622
  /**
6649
6623
  * Parse a date string into an object, changes - into /
6650
6624
  * @method parse
6651
6625
  * @param {string} dateStr Date string
6652
6626
  * @param {string} format Date parse format
6653
6627
  * @returns {Date|boolean}
6654
- */
6655
- fecha.parse = function (dateStr, format) {
6656
- if (typeof format !== 'string') {
6657
- throw new Error('Invalid format in fecha.parse');
6658
- }
6659
-
6660
- format = fecha.masks[format] || format;
6661
-
6662
- // Avoid regular expression denial of service, fail early for really long strings
6663
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
6664
- if (dateStr.length > 1000) {
6665
- return null;
6666
- }
6667
-
6668
- const dateInfo = {};
6669
- const parseInfo = [];
6670
- const literals = [];
6671
- format = format.replace(literal, function($0, $1) {
6672
- literals.push($1);
6673
- return '@@@';
6674
- });
6675
- let newFormat = regexEscape(format).replace(token, function ($0) {
6676
- if (parseFlags[$0]) {
6677
- const info = parseFlags[$0];
6678
- parseInfo.push(info[1]);
6679
- return '(' + info[0] + ')';
6680
- }
6681
-
6682
- return $0;
6683
- });
6684
- newFormat = newFormat.replace(/@@@/g, function() {
6685
- return literals.shift();
6686
- });
6687
- const matches = dateStr.match(new RegExp(newFormat, 'i'));
6688
- if (!matches) {
6689
- return null;
6690
- }
6691
-
6692
- for (let i = 1; i < matches.length; i++) {
6693
- parseInfo[i - 1](dateInfo, matches[i]);
6694
- }
6695
-
6696
- const today = new Date();
6697
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
6698
- dateInfo.hour = +dateInfo.hour + 12;
6699
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
6700
- dateInfo.hour = 0;
6701
- }
6702
-
6703
- let date;
6704
- if (dateInfo.timezoneOffset != null) {
6705
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
6706
- date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
6707
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
6708
- } else {
6709
- date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
6710
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
6711
- }
6712
- return date;
6713
- };
6714
-
6715
- // 导出fecha对象
6716
-
6717
-
6718
- // 以下是从date-util.js合并的函数
6719
- const newArray = function(start, end) {
6720
- let result = [];
6721
- for (let i = start; i <= end; i++) {
6722
- result.push(i);
6723
- }
6724
- return result;
6725
- };
6726
-
6727
- const getSettings = () => {
6728
- return {
6729
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
6730
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
6731
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
6732
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
6733
- amPm: ['上午', '下午']
6734
- };
6735
- };
6736
-
6737
- const toDate = function(date) {
6738
- return isDate(date) ? new Date(date) : null;
6739
- };
6740
-
6741
- const isDate = function(date) {
6742
- if (date === null || date === undefined) return false;
6743
- if (isNaN(new Date(date).getTime())) return false;
6744
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
6745
- return true;
6746
- };
6747
-
6748
- const isDateObject = function(val) {
6749
- return val instanceof Date;
6750
- };
6751
-
6752
- const formatDate = function (date, format = 'yyyy-MM-dd') {
6753
- // 处理多种输入类型
6754
- if (!date) return '';
6755
-
6756
- // 如果是时间戳,转成日期对象
6757
- if (typeof date === 'number') {
6758
- date = new Date(date);
6759
- }
6760
- // 如果是字符串,转成日期对象
6761
- if (typeof date === 'string') {
6762
- date = new Date(date);
6763
- }
6764
-
6765
- // 调用toDate进一步验证和转换
6766
- date = toDate(date);
6767
- if (!date) return '';
6768
-
6769
- // 兼容大写和小写的格式标记
6770
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
6771
- const lowercaseFormat = format
6772
- .replace(/YYYY/g, 'yyyy')
6773
- .replace(/D/g, 'd')
6774
-
6775
- // 使用fecha库进行格式化,支持中文配置
6776
- const str = fecha.format(date, lowercaseFormat, getSettings());
6777
- return str;
6778
- };
6779
-
6780
- const parseDate = function(string, format) {
6781
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
6782
- };
6783
-
6784
- const getDayCountOfMonth = function(year, month) {
6785
- if (month === 3 || month === 5 || month === 8 || month === 10) {
6786
- return 30;
6787
- }
6788
-
6789
- if (month === 1) {
6790
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
6791
- return 29;
6792
- } else {
6793
- return 28;
6794
- }
6795
- }
6796
-
6797
- return 31;
6798
- };
6799
-
6800
- const getDayCountOfYear = function(year) {
6801
- const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
6802
- return isLeapYear ? 366 : 365;
6803
- };
6804
-
6805
- const getFirstDayOfMonth = function(date) {
6806
- const temp = new Date(date.getTime());
6807
- temp.setDate(1);
6808
- return temp.getDay();
6809
- };
6810
-
6811
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
6812
- // {prev, next} Date should work for Daylight Saving Time
6813
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
6814
- const prevDate = function(date, amount = 1) {
6815
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
6816
- };
6817
-
6818
- const nextDate = function(date, amount = 1) {
6819
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
6820
- };
6821
-
6822
- const getStartDateOfMonth = function(year, month) {
6823
- const result = new Date(year, month, 1);
6824
- const day = result.getDay();
6825
-
6826
- if (day === 0) {
6827
- return prevDate(result, 7);
6828
- } else {
6829
- return prevDate(result, day);
6830
- }
6831
- };
6832
-
6833
- const getWeekNumber = function(date) {
6834
- // 支持多种输入类型
6835
- if (!date||!isDate(date)) {
6836
- date = new Date();
6837
- }
6838
- if (typeof date === 'string') {
6839
- date = new Date(date);
6840
- }
6841
-
6842
- // 验证日期有效性
6843
- if (!isDate(date)) return null;
6844
-
6845
- const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
6846
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
6847
- // 将星期日的星期数设为7
6848
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
6849
- // 获取当年的第一天
6850
- const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
6851
- // 计算到最近的星期四的完整周数
6852
- const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
6853
- // 返回周数
6854
- return weekNo;
6855
- };
6856
-
6857
- const getRangeHours = function(ranges) {
6858
- const hours = [];
6859
- let disabledHours = [];
6860
-
6861
- (ranges || []).forEach(range => {
6862
- const value = range.map(date => date.getHours());
6863
-
6864
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
6865
- });
6866
-
6867
- if (disabledHours.length) {
6868
- for (let i = 0; i < 24; i++) {
6869
- hours[i] = disabledHours.indexOf(i) === -1;
6870
- }
6871
- } else {
6872
- for (let i = 0; i < 24; i++) {
6873
- hours[i] = false;
6874
- }
6875
- }
6876
-
6877
- return hours;
6878
- };
6879
-
6880
- const getPrevMonthLastDays = (date, amount) => {
6881
- if (amount <= 0) return [];
6882
- const temp = new Date(date.getTime());
6883
- temp.setDate(0);
6884
- const lastDay = temp.getDate();
6885
- return range(amount).map((_, index) => lastDay - (amount - index - 1));
6886
- };
6887
-
6888
- const getMonthDays = (date) => {
6889
- const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
6890
- const days = temp.getDate();
6891
- return range(days).map((_, index) => index + 1);
6892
- };
6893
-
6894
- function setRangeData(arr, start, end, value) {
6895
- for (let i = start; i < end; i++) {
6896
- arr[i] = value;
6897
- }
6898
- }
6899
-
6900
- const getRangeMinutes = function(ranges, hour) {
6901
- const minutes = new Array(60);
6902
-
6903
- if (ranges.length > 0) {
6904
- ranges.forEach(range => {
6905
- const start = range[0];
6906
- const end = range[1];
6907
- const startHour = start.getHours();
6908
- const startMinute = start.getMinutes();
6909
- const endHour = end.getHours();
6910
- const endMinute = end.getMinutes();
6911
- if (startHour === hour && endHour !== hour) {
6912
- setRangeData(minutes, startMinute, 60, true);
6913
- } else if (startHour === hour && endHour === hour) {
6914
- setRangeData(minutes, startMinute, endMinute + 1, true);
6915
- } else if (startHour !== hour && endHour === hour) {
6916
- setRangeData(minutes, 0, endMinute + 1, true);
6917
- } else if (startHour < hour && endHour > hour) {
6918
- setRangeData(minutes, 0, 60, true);
6919
- }
6920
- });
6921
- } else {
6922
- setRangeData(minutes, 0, 60, true);
6923
- }
6924
- return minutes;
6925
- };
6926
-
6927
- const range = function(n) {
6928
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
6929
- return Array.apply(null, {length: n}).map((_, n) => n);
6930
- };
6931
-
6932
- const modifyDate = function(date, y, m, d) {
6933
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
6934
- };
6935
-
6936
- const modifyTime = function(date, h, m, s) {
6937
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
6938
- };
6939
-
6940
- const modifyWithTimeString = (date, time) => {
6941
- if (date == null || !time) {
6942
- return date;
6943
- }
6944
- time = parseDate(time, 'HH:mm:ss');
6945
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
6946
- };
6947
-
6948
- const clearTime = function(date) {
6949
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
6950
- };
6951
-
6952
- const clearMilliseconds = function(date) {
6953
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
6954
- };
6955
-
6956
- const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
6957
- // TODO: refactory a more elegant solution
6958
- if (ranges.length === 0) return date;
6959
- const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
6960
- const ndate = normalizeDate(date);
6961
- const nranges = ranges.map(range => range.map(normalizeDate));
6962
- if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
6963
-
6964
- let minDate = nranges[0][0];
6965
- let maxDate = nranges[0][0];
6966
-
6967
- nranges.forEach(nrange => {
6968
- minDate = new Date(Math.min(nrange[0], minDate));
6969
- maxDate = new Date(Math.max(nrange[1], minDate));
6970
- });
6971
-
6972
- const ret = ndate < minDate ? minDate : maxDate;
6973
- // preserve Year/Month/Date
6974
- return modifyDate(
6975
- ret,
6976
- date.getFullYear(),
6977
- date.getMonth(),
6978
- date.getDate()
6979
- );
6980
- };
6981
-
6982
- const timeWithinRange = function(date, selectableRange, format) {
6983
- const limitedDate = limitTimeRange(date, selectableRange, format);
6984
- return limitedDate.getTime() === date.getTime();
6985
- };
6986
-
6987
- const changeYearMonthAndClampDate = function(date, year, month) {
6988
- // clamp date to the number of days in `year`, `month`
6989
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
6990
- const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
6991
- return modifyDate(date, year, month, monthDate);
6992
- };
6993
-
6994
- const prevMonth = function(date) {
6995
- const year = date.getFullYear();
6996
- const month = date.getMonth();
6997
- return month === 0
6998
- ? changeYearMonthAndClampDate(date, year - 1, 11)
6999
- : changeYearMonthAndClampDate(date, year, month - 1);
7000
- };
7001
-
7002
- const nextMonth = function(date) {
7003
- const year = date.getFullYear();
7004
- const month = date.getMonth();
7005
- return month === 11
7006
- ? changeYearMonthAndClampDate(date, year + 1, 0)
7007
- : changeYearMonthAndClampDate(date, year, month + 1);
7008
- };
7009
-
7010
- const prevYear = function(date, amount = 1) {
7011
- const year = date.getFullYear();
7012
- const month = date.getMonth();
7013
- return changeYearMonthAndClampDate(date, year - amount, month);
7014
- };
7015
-
7016
- const nextYear = function(date, amount = 1) {
7017
- const year = date.getFullYear();
7018
- const month = date.getMonth();
7019
- return changeYearMonthAndClampDate(date, year + amount, month);
7020
- };
7021
-
7022
- const extractDateFormat = function(format) {
7023
- return format
7024
- .replace(/\W?m{1,2}|\W?ZZ/g, '')
7025
- .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
7026
- .trim();
7027
- };
7028
-
7029
- const extractTimeFormat = function(format) {
7030
- return format
7031
- .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
7032
- .trim();
7033
- };
7034
-
7035
- const validateRangeInOneMonth = function(start, end) {
7036
- return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
7037
- };
7038
-
6628
+ */
6629
+ fecha.parse = function (dateStr, format) {
6630
+ if (typeof format !== 'string') {
6631
+ throw new Error('Invalid format in fecha.parse');
6632
+ }
6633
+
6634
+ format = fecha.masks[format] || format;
6635
+
6636
+ // Avoid regular expression denial of service, fail early for really long strings
6637
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
6638
+ if (dateStr.length > 1000) {
6639
+ return null;
6640
+ }
6641
+
6642
+ var dateInfo = {};
6643
+ var parseInfo = [];
6644
+ var literals = [];
6645
+ format = format.replace(literal, function ($0, $1) {
6646
+ literals.push($1);
6647
+ return '@@@';
6648
+ });
6649
+ var newFormat = regexEscape(format).replace(token, function ($0) {
6650
+ if (parseFlags[$0]) {
6651
+ var info = parseFlags[$0];
6652
+ parseInfo.push(info[1]);
6653
+ return '(' + info[0] + ')';
6654
+ }
6655
+
6656
+ return $0;
6657
+ });
6658
+ newFormat = newFormat.replace(/@@@/g, function () {
6659
+ return literals.shift();
6660
+ });
6661
+ var matches = dateStr.match(new RegExp(newFormat, 'i'));
6662
+ if (!matches) {
6663
+ return null;
6664
+ }
6665
+
6666
+ for (var i = 1; i < matches.length; i++) {
6667
+ parseInfo[i - 1](dateInfo, matches[i]);
6668
+ }
6669
+
6670
+ var today = new Date();
6671
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
6672
+ dateInfo.hour = +dateInfo.hour + 12;
6673
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
6674
+ dateInfo.hour = 0;
6675
+ }
6676
+
6677
+ var date = void 0;
6678
+ if (dateInfo.timezoneOffset != null) {
6679
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
6680
+ 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));
6681
+ } else {
6682
+ 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);
6683
+ }
6684
+ return date;
6685
+ };
6686
+
6687
+ // 导出fecha对象
6688
+
6689
+
6690
+ // 以下是从date-util.js合并的函数
6691
+ var newArray = function newArray(start, end) {
6692
+ var result = [];
6693
+ for (var i = start; i <= end; i++) {
6694
+ result.push(i);
6695
+ }
6696
+ return result;
6697
+ };
6698
+
6699
+ var getSettings = function getSettings() {
6700
+ return {
6701
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
6702
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
6703
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
6704
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
6705
+ amPm: ['上午', '下午']
6706
+ };
6707
+ };
6708
+
6709
+ var toDate = function toDate(date) {
6710
+ return isDate(date) ? new Date(date) : null;
6711
+ };
6712
+
6713
+ var isDate = function isDate(date) {
6714
+ if (date === null || date === undefined) return false;
6715
+ if (isNaN(new Date(date).getTime())) return false;
6716
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
6717
+ return true;
6718
+ };
6719
+
6720
+ var isDateObject = function isDateObject(val) {
6721
+ return val instanceof Date;
6722
+ };
6723
+
6724
+ var formatDate = function formatDate(date) {
6725
+ var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
6726
+
6727
+ // 处理多种输入类型
6728
+ if (!date) return '';
6729
+
6730
+ // 如果是时间戳,转成日期对象
6731
+ if (typeof date === 'number') {
6732
+ date = new Date(date);
6733
+ }
6734
+ // 如果是字符串,转成日期对象
6735
+ if (typeof date === 'string') {
6736
+ date = new Date(date);
6737
+ }
6738
+
6739
+ // 调用toDate进一步验证和转换
6740
+ date = toDate(date);
6741
+ if (!date) return '';
6742
+
6743
+ // 兼容大写和小写的格式标记
6744
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
6745
+ var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
6746
+
6747
+ // 使用fecha库进行格式化,支持中文配置
6748
+ var str = fecha.format(date, lowercaseFormat, getSettings());
6749
+ return str;
6750
+ };
6751
+
6752
+ var parseDate = function parseDate(string, format) {
6753
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
6754
+ };
6755
+
6756
+ var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
6757
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
6758
+ return 30;
6759
+ }
6760
+
6761
+ if (month === 1) {
6762
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
6763
+ return 29;
6764
+ } else {
6765
+ return 28;
6766
+ }
6767
+ }
6768
+
6769
+ return 31;
6770
+ };
6771
+
6772
+ var getDayCountOfYear = function getDayCountOfYear(year) {
6773
+ var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
6774
+ return isLeapYear ? 366 : 365;
6775
+ };
6776
+
6777
+ var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
6778
+ var temp = new Date(date.getTime());
6779
+ temp.setDate(1);
6780
+ return temp.getDay();
6781
+ };
6782
+
6783
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
6784
+ // {prev, next} Date should work for Daylight Saving Time
6785
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
6786
+ var prevDate = function prevDate(date) {
6787
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6788
+
6789
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
6790
+ };
6791
+
6792
+ var nextDate = function nextDate(date) {
6793
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6794
+
6795
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
6796
+ };
6797
+
6798
+ var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
6799
+ var result = new Date(year, month, 1);
6800
+ var day = result.getDay();
6801
+
6802
+ if (day === 0) {
6803
+ return prevDate(result, 7);
6804
+ } else {
6805
+ return prevDate(result, day);
6806
+ }
6807
+ };
6808
+
6809
+ var getWeekNumber = function getWeekNumber(date) {
6810
+ // 支持多种输入类型
6811
+ if (!date || !isDate(date)) {
6812
+ date = new Date();
6813
+ }
6814
+ if (typeof date === 'string') {
6815
+ date = new Date(date);
6816
+ }
6817
+
6818
+ // 验证日期有效性
6819
+ if (!isDate(date)) return null;
6820
+
6821
+ var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
6822
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
6823
+ // 将星期日的星期数设为7
6824
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
6825
+ // 获取当年的第一天
6826
+ var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
6827
+ // 计算到最近的星期四的完整周数
6828
+ var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
6829
+ // 返回周数
6830
+ return weekNo;
6831
+ };
6832
+
6833
+ var getRangeHours = function getRangeHours(ranges) {
6834
+ var hours = [];
6835
+ var disabledHours = [];
6836
+
6837
+ (ranges || []).forEach(function (range) {
6838
+ var value = range.map(function (date) {
6839
+ return date.getHours();
6840
+ });
6841
+
6842
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
6843
+ });
6844
+
6845
+ if (disabledHours.length) {
6846
+ for (var i = 0; i < 24; i++) {
6847
+ hours[i] = disabledHours.indexOf(i) === -1;
6848
+ }
6849
+ } else {
6850
+ for (var _i = 0; _i < 24; _i++) {
6851
+ hours[_i] = false;
6852
+ }
6853
+ }
6854
+
6855
+ return hours;
6856
+ };
6857
+
6858
+ var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
6859
+ if (amount <= 0) return [];
6860
+ var temp = new Date(date.getTime());
6861
+ temp.setDate(0);
6862
+ var lastDay = temp.getDate();
6863
+ return range(amount).map(function (_, index) {
6864
+ return lastDay - (amount - index - 1);
6865
+ });
6866
+ };
6867
+
6868
+ var getMonthDays = function getMonthDays(date) {
6869
+ var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
6870
+ var days = temp.getDate();
6871
+ return range(days).map(function (_, index) {
6872
+ return index + 1;
6873
+ });
6874
+ };
6875
+
6876
+ function setRangeData(arr, start, end, value) {
6877
+ for (var i = start; i < end; i++) {
6878
+ arr[i] = value;
6879
+ }
6880
+ }
6881
+
6882
+ var getRangeMinutes = function getRangeMinutes(ranges, hour) {
6883
+ var minutes = new Array(60);
6884
+
6885
+ if (ranges.length > 0) {
6886
+ ranges.forEach(function (range) {
6887
+ var start = range[0];
6888
+ var end = range[1];
6889
+ var startHour = start.getHours();
6890
+ var startMinute = start.getMinutes();
6891
+ var endHour = end.getHours();
6892
+ var endMinute = end.getMinutes();
6893
+ if (startHour === hour && endHour !== hour) {
6894
+ setRangeData(minutes, startMinute, 60, true);
6895
+ } else if (startHour === hour && endHour === hour) {
6896
+ setRangeData(minutes, startMinute, endMinute + 1, true);
6897
+ } else if (startHour !== hour && endHour === hour) {
6898
+ setRangeData(minutes, 0, endMinute + 1, true);
6899
+ } else if (startHour < hour && endHour > hour) {
6900
+ setRangeData(minutes, 0, 60, true);
6901
+ }
6902
+ });
6903
+ } else {
6904
+ setRangeData(minutes, 0, 60, true);
6905
+ }
6906
+ return minutes;
6907
+ };
6908
+
6909
+ var range = function range(n) {
6910
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
6911
+ return Array.apply(null, { length: n }).map(function (_, n) {
6912
+ return n;
6913
+ });
6914
+ };
6915
+
6916
+ var modifyDate = function modifyDate(date, y, m, d) {
6917
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
6918
+ };
6919
+
6920
+ var modifyTime = function modifyTime(date, h, m, s) {
6921
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
6922
+ };
6923
+
6924
+ var modifyWithTimeString = function modifyWithTimeString(date, time) {
6925
+ if (date == null || !time) {
6926
+ return date;
6927
+ }
6928
+ time = parseDate(time, 'HH:mm:ss');
6929
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
6930
+ };
6931
+
6932
+ var clearTime = function clearTime(date) {
6933
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
6934
+ };
6935
+
6936
+ var clearMilliseconds = function clearMilliseconds(date) {
6937
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
6938
+ };
6939
+
6940
+ var limitTimeRange = function limitTimeRange(date, ranges) {
6941
+ var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
6942
+
6943
+ // TODO: refactory a more elegant solution
6944
+ if (ranges.length === 0) return date;
6945
+ var normalizeDate = function normalizeDate(date) {
6946
+ return fecha.parse(fecha.format(date, format), format);
6947
+ };
6948
+ var ndate = normalizeDate(date);
6949
+ var nranges = ranges.map(function (range) {
6950
+ return range.map(normalizeDate);
6951
+ });
6952
+ if (nranges.some(function (nrange) {
6953
+ return ndate >= nrange[0] && ndate <= nrange[1];
6954
+ })) return date;
6955
+
6956
+ var minDate = nranges[0][0];
6957
+ var maxDate = nranges[0][0];
6958
+
6959
+ nranges.forEach(function (nrange) {
6960
+ minDate = new Date(Math.min(nrange[0], minDate));
6961
+ maxDate = new Date(Math.max(nrange[1], minDate));
6962
+ });
6963
+
6964
+ var ret = ndate < minDate ? minDate : maxDate;
6965
+ // preserve Year/Month/Date
6966
+ return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
6967
+ };
6968
+
6969
+ var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
6970
+ var limitedDate = limitTimeRange(date, selectableRange, format);
6971
+ return limitedDate.getTime() === date.getTime();
6972
+ };
6973
+
6974
+ var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
6975
+ // clamp date to the number of days in `year`, `month`
6976
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
6977
+ var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
6978
+ return modifyDate(date, year, month, monthDate);
6979
+ };
6980
+
6981
+ var prevMonth = function prevMonth(date) {
6982
+ var year = date.getFullYear();
6983
+ var month = date.getMonth();
6984
+ return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
6985
+ };
6986
+
6987
+ var nextMonth = function nextMonth(date) {
6988
+ var year = date.getFullYear();
6989
+ var month = date.getMonth();
6990
+ return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
6991
+ };
6992
+
6993
+ var prevYear = function prevYear(date) {
6994
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6995
+
6996
+ var year = date.getFullYear();
6997
+ var month = date.getMonth();
6998
+ return changeYearMonthAndClampDate(date, year - amount, month);
6999
+ };
7000
+
7001
+ var nextYear = function nextYear(date) {
7002
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
7003
+
7004
+ var year = date.getFullYear();
7005
+ var month = date.getMonth();
7006
+ return changeYearMonthAndClampDate(date, year + amount, month);
7007
+ };
7008
+
7009
+ var extractDateFormat = function extractDateFormat(format) {
7010
+ return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
7011
+ };
7012
+
7013
+ var extractTimeFormat = function extractTimeFormat(format) {
7014
+ return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
7015
+ };
7016
+
7017
+ var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
7018
+ return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
7019
+ };
7020
+
7039
7021
  /**
7040
7022
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
7041
7023
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
7042
7024
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
7043
7025
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
7044
7026
  * @returns {number} 工作日数量
7045
- */
7046
- const calculateNetworkDays = function (start_date, end_date, holidays = []) {
7047
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
7048
- throw new Error(
7049
- "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
7050
- );
7051
- }
7052
-
7053
- const startDateObj = new Date(start_date);
7054
- const endDateObj = new Date(end_date);
7055
-
7056
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
7057
- throw new Error(
7058
- "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
7059
- );
7060
- }
7061
-
7062
- if (startDateObj > endDateObj) {
7063
- throw new Error('Start date should be earlier than or equal to end date.');
7064
- }
7065
-
7066
- let workdays = 0;
7067
-
7068
- // Iterate through each day in the date range
7069
- for (
7070
- let currentDate = new Date(startDateObj);
7071
- currentDate <= endDateObj;
7072
- currentDate.setDate(currentDate.getDate() + 1)
7073
- ) {
7074
- // Check if the current day is a weekend (Saturday or Sunday)
7075
- const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
7076
-
7077
- // Check if the current day is a holiday
7078
- const isHoliday = holidays.some((holiday) => {
7079
- const holidayDate = new Date(holiday);
7080
- return currentDate.toDateString() === holidayDate.toDateString();
7081
- });
7082
-
7083
- // If it's a workday (not a weekend or holiday), increment the workdays count
7084
- if (!isWeekend && !isHoliday) {
7085
- workdays++;
7086
- }
7087
- }
7088
-
7089
- return workdays;
7090
- };
7091
-
7027
+ */
7028
+ var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
7029
+ var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
7030
+
7031
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
7032
+ throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
7033
+ }
7034
+
7035
+ var startDateObj = new Date(start_date);
7036
+ var endDateObj = new Date(end_date);
7037
+
7038
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
7039
+ throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
7040
+ }
7041
+
7042
+ if (startDateObj > endDateObj) {
7043
+ throw new Error('Start date should be earlier than or equal to end date.');
7044
+ }
7045
+
7046
+ var workdays = 0;
7047
+
7048
+ // Iterate through each day in the date range
7049
+
7050
+ var _loop = function _loop(currentDate) {
7051
+ // Check if the current day is a weekend (Saturday or Sunday)
7052
+ var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
7053
+
7054
+ // Check if the current day is a holiday
7055
+ var isHoliday = holidays.some(function (holiday) {
7056
+ var holidayDate = new Date(holiday);
7057
+ return currentDate.toDateString() === holidayDate.toDateString();
7058
+ });
7059
+
7060
+ // If it's a workday (not a weekend or holiday), increment the workdays count
7061
+ if (!isWeekend && !isHoliday) {
7062
+ workdays++;
7063
+ }
7064
+ };
7065
+
7066
+ for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
7067
+ _loop(currentDate);
7068
+ }
7069
+
7070
+ return workdays;
7071
+ };
7072
+
7092
7073
  /**
7093
7074
  * 日期加减天数
7094
7075
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
7095
7076
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
7096
7077
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
7097
- */
7098
- const dateAddDays = function (start_date, days) {
7099
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
7100
- throw new Error(
7101
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
7102
- );
7103
- }
7104
-
7105
- const startDateObj = new Date(start_date);
7106
- if (isNaN(startDateObj.getTime())) {
7107
- throw new Error(
7108
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
7109
- );
7110
- }
7111
-
7112
- const resultDateObj = new Date(startDateObj);
7113
- resultDateObj.setDate(resultDateObj.getDate() + days);
7114
-
7115
- const resultYear = resultDateObj.getFullYear();
7116
- const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
7117
- const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
7118
-
7119
- return `${resultYear}-${resultMonth}-${resultDay}`;
7120
- };
7121
-
7078
+ */
7079
+ var dateAddDays = function dateAddDays(start_date, days) {
7080
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
7081
+ 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.");
7082
+ }
7083
+
7084
+ var startDateObj = new Date(start_date);
7085
+ if (isNaN(startDateObj.getTime())) {
7086
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
7087
+ }
7088
+
7089
+ var resultDateObj = new Date(startDateObj);
7090
+ resultDateObj.setDate(resultDateObj.getDate() + days);
7091
+
7092
+ var resultYear = resultDateObj.getFullYear();
7093
+ var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
7094
+ var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
7095
+
7096
+ return resultYear + '-' + resultMonth + '-' + resultDay;
7097
+ };
7098
+
7122
7099
  /**
7123
7100
  * 计算两个日期之间的差值
7124
7101
  * @date 2023年12月14日
@@ -7126,182 +7103,180 @@ const dateAddDays = function (start_date, days) {
7126
7103
  * @param {String} end_date - 结束日期字符串
7127
7104
  * @param {String} unit - 单位:year/month/day
7128
7105
  * @returns {Number} 差值
7129
- */
7130
- const dateDiff = function (start_date, end_date, unit = 'day') {
7131
- // Assuming date strings are in "YYYY-MM-DD" format
7132
- var startDate = new Date(start_date);
7133
- var endDate = new Date(end_date);
7134
-
7135
- // If the date is invalid, return 0
7136
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
7137
- return 0;
7138
- }
7139
-
7140
- if (unit === 'year') {
7141
- return endDate.getFullYear() - startDate.getFullYear();
7142
- } else if (unit === 'month') {
7143
- return (
7144
- (endDate.getFullYear() - startDate.getFullYear()) * 12 +
7145
- (endDate.getMonth() - startDate.getMonth())
7146
- );
7147
- } else {
7148
- // Default to day
7149
- var timeDifference = endDate - startDate;
7150
- // Calculate days (86400000 milliseconds per day)
7151
- return Math.floor(timeDifference / 86400000);
7152
- }
7153
- };
7154
-
7106
+ */
7107
+ var dateDiff = function dateDiff(start_date, end_date) {
7108
+ var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
7109
+
7110
+ // Assuming date strings are in "YYYY-MM-DD" format
7111
+ var startDate = new Date(start_date);
7112
+ var endDate = new Date(end_date);
7113
+
7114
+ // If the date is invalid, return 0
7115
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
7116
+ return 0;
7117
+ }
7118
+
7119
+ if (unit === 'year') {
7120
+ return endDate.getFullYear() - startDate.getFullYear();
7121
+ } else if (unit === 'month') {
7122
+ return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
7123
+ } else {
7124
+ // Default to day
7125
+ var timeDifference = endDate - startDate;
7126
+ // Calculate days (86400000 milliseconds per day)
7127
+ return Math.floor(timeDifference / 86400000);
7128
+ }
7129
+ };
7130
+
7155
7131
  /**
7156
7132
  * 获取月份中的日期
7157
7133
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
7158
7134
  * @returns {number} 月份中的日期(1-31)
7159
- */
7160
- const dayOfMonth = function (date) {
7161
- if (typeof date !== 'string') {
7162
- throw new Error(
7163
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
7164
- );
7165
- }
7166
-
7167
- const dateObj = new Date(date);
7168
- if (isNaN(dateObj.getTime())) {
7169
- throw new Error(
7170
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
7171
- );
7172
- }
7173
-
7174
- return dateObj.getDate();
7175
- };
7176
-
7135
+ */
7136
+ var dayOfMonth = function dayOfMonth(date) {
7137
+ if (typeof date !== 'string') {
7138
+ throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
7139
+ }
7140
+
7141
+ var dateObj = new Date(date);
7142
+ if (isNaN(dateObj.getTime())) {
7143
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
7144
+ }
7145
+
7146
+ return dateObj.getDate();
7147
+ };
7148
+
7177
7149
  /**
7178
7150
  * 获取当前日期
7179
7151
  * @date 2022年5月7日
7180
7152
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
7181
7153
  * @returns {string} 当前日期的格式化字符串
7182
- */
7183
- const getCurrentDate = function (format = 'YYYY-MM-DD') {
7184
- return formatDate(new Date(), format);
7185
- };
7186
-
7154
+ */
7155
+ var getCurrentDate = function getCurrentDate() {
7156
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
7157
+
7158
+ return formatDate(new Date(), format);
7159
+ };
7160
+
7187
7161
  /**
7188
7162
  * 获取当前日期时间
7189
7163
  * @date 2022年5月7日
7190
7164
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
7191
7165
  * @returns {string} 当前日期时间的格式化字符串
7192
- */
7193
- const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
7194
- return formatDate(new Date(), format);
7195
- };
7196
-
7166
+ */
7167
+ var getCurrentDateTime = function getCurrentDateTime() {
7168
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
7169
+
7170
+ return formatDate(new Date(), format);
7171
+ };
7172
+
7197
7173
  /**
7198
7174
  * 获取小时
7199
7175
  * @date 2022年5月7日
7200
7176
  * @param {Date|string} [date] - 日期对象或日期字符串
7201
7177
  * @returns {number} 小时数(0-23)
7202
- */
7203
- const getHour = function (date) {
7204
- if (!date) {
7205
- return new Date().getHours();
7206
- }
7207
- if (typeof date === 'string') {
7208
- date = new Date(date);
7209
- }
7210
- return date.getHours();
7211
- };
7212
-
7178
+ */
7179
+ var getHour = function getHour(date) {
7180
+ if (!date) {
7181
+ return new Date().getHours();
7182
+ }
7183
+ if (typeof date === 'string') {
7184
+ date = new Date(date);
7185
+ }
7186
+ return date.getHours();
7187
+ };
7188
+
7213
7189
  /**
7214
7190
  * 获取分钟
7215
7191
  * @date 2022年5月7日
7216
7192
  * @param {Date|string} [date] - 日期对象或日期字符串
7217
7193
  * @returns {number} 分钟数(0-59)
7218
- */
7219
- const getMinute = function (date) {
7220
- if (!date) {
7221
- return new Date().getMinutes();
7222
- }
7223
- if (typeof date === 'string') {
7224
- date = new Date(date);
7225
- }
7226
- return date.getMinutes();
7227
- };
7228
-
7194
+ */
7195
+ var getMinute = function getMinute(date) {
7196
+ if (!date) {
7197
+ return new Date().getMinutes();
7198
+ }
7199
+ if (typeof date === 'string') {
7200
+ date = new Date(date);
7201
+ }
7202
+ return date.getMinutes();
7203
+ };
7204
+
7229
7205
  /**
7230
7206
  * 获取月份
7231
7207
  * @date 2022年5月7日
7232
7208
  * @param {Date|string} [date] - 日期对象或日期字符串
7233
7209
  * @returns {number} 月份数(1-12)
7234
- */
7235
- const getMonth = function (date) {
7236
- if (!date) {
7237
- return new Date().getMonth() + 1;
7238
- }
7239
- if (typeof date === 'string') {
7240
- date = new Date(date);
7241
- }
7242
- return date.getMonth() + 1;
7243
- };
7244
-
7210
+ */
7211
+ var getMonth = function getMonth(date) {
7212
+ if (!date) {
7213
+ return new Date().getMonth() + 1;
7214
+ }
7215
+ if (typeof date === 'string') {
7216
+ date = new Date(date);
7217
+ }
7218
+ return date.getMonth() + 1;
7219
+ };
7220
+
7245
7221
  /**
7246
7222
  * 获取秒
7247
7223
  * @date 2022年5月7日
7248
7224
  * @param {Date|string} [date] - 日期对象或日期字符串
7249
7225
  * @returns {number} 秒数(0-59)
7250
- */
7251
- const getSecond = function (date) {
7252
- if (!date) {
7253
- return new Date().getSeconds();
7254
- }
7255
- if (typeof date === 'string') {
7256
- date = new Date(date);
7257
- }
7258
- return date.getSeconds();
7259
- };
7260
-
7226
+ */
7227
+ var getSecond = function getSecond(date) {
7228
+ if (!date) {
7229
+ return new Date().getSeconds();
7230
+ }
7231
+ if (typeof date === 'string') {
7232
+ date = new Date(date);
7233
+ }
7234
+ return date.getSeconds();
7235
+ };
7236
+
7261
7237
  /**
7262
7238
  * 获取星期几
7263
7239
  * @date 2022年5月7日
7264
7240
  * @param {Date|string} [date] - 日期对象或日期字符串
7265
7241
  * @returns {number} 星期几(0-6,0表示星期日)
7266
- */
7267
- const getWeekday = function (date) {
7268
- if (!date) {
7269
- return new Date().getDay();
7270
- }
7271
- if (typeof date === 'string') {
7272
- date = new Date(date);
7273
- }
7274
- return date.getDay();
7275
- };
7276
-
7277
-
7242
+ */
7243
+ var getWeekday = function getWeekday(date) {
7244
+ if (!date) {
7245
+ return new Date().getDay();
7246
+ }
7247
+ if (typeof date === 'string') {
7248
+ date = new Date(date);
7249
+ }
7250
+ return date.getDay();
7251
+ };
7252
+
7278
7253
  /**
7279
7254
  * @desc 获取上午/下午/晚上
7280
7255
  * @author huangbo
7281
7256
  * @date 2022年5月7日
7282
7257
  * @param {String} [time] - 时间
7283
- **/
7284
- const timeCycle = function (time) {
7285
- let hour = 0;
7286
- if (!time) {
7287
- hour = new Date().getHours();
7288
- } else if (typeof time === 'string') {
7289
- // 从时间字符串中提取小时
7290
- const match = time.match(/^(\d{1,2})/);
7291
- if (match) {
7292
- hour = parseInt(match[1], 10);
7293
- }
7294
- } else if (typeof time === 'number') {
7295
- hour = time;
7296
- }
7297
- // 判断时间段
7298
- if (hour >= 5 && hour < 12) {
7299
- return '上午';
7300
- } else if (hour >= 12 && hour < 18) {
7301
- return '下午';
7302
- } else {
7303
- return '晚上';
7304
- }
7258
+ **/
7259
+ var timeCycle = function timeCycle(time) {
7260
+ var hour = 0;
7261
+ if (!time) {
7262
+ hour = new Date().getHours();
7263
+ } else if (typeof time === 'string') {
7264
+ // 从时间字符串中提取小时
7265
+ var match = time.match(/^(\d{1,2})/);
7266
+ if (match) {
7267
+ hour = parseInt(match[1], 10);
7268
+ }
7269
+ } else if (typeof time === 'number') {
7270
+ hour = time;
7271
+ }
7272
+ // 判断时间段
7273
+ if (hour >= 5 && hour < 12) {
7274
+ return '上午';
7275
+ } else if (hour >= 12 && hour < 18) {
7276
+ return '下午';
7277
+ } else {
7278
+ return '晚上';
7279
+ }
7305
7280
  };
7306
7281
 
7307
7282
  /***/ }),