eoss 0.1.0-alpha.35 → 0.1.0-alpha.36

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 (136) hide show
  1. package/lib/account-login.js +912 -856
  2. package/lib/alert.js +2 -2
  3. package/lib/aside.js +2 -2
  4. package/lib/audit-trajectory.js +2 -2
  5. package/lib/autocomplete.js +2001 -1777
  6. package/lib/avatar.js +2 -2
  7. package/lib/backtop.js +2 -2
  8. package/lib/badge.js +2 -2
  9. package/lib/breadcrumb-item.js +4 -4
  10. package/lib/breadcrumb.js +4 -4
  11. package/lib/button-group.js +2 -2
  12. package/lib/button.js +2 -2
  13. package/lib/ca-login.js +862 -837
  14. package/lib/calendar.js +862 -837
  15. package/lib/card.js +2 -2
  16. package/lib/carousel-item.js +864 -839
  17. package/lib/carousel.js +864 -839
  18. package/lib/cascader-panel.js +864 -839
  19. package/lib/cascader.js +2003 -1779
  20. package/lib/checkbox-button.js +2 -2
  21. package/lib/checkbox-group.js +864 -839
  22. package/lib/checkbox.js +2 -2
  23. package/lib/col.js +2 -2
  24. package/lib/collapse-item.js +864 -839
  25. package/lib/collapse.js +864 -839
  26. package/lib/color-picker.js +1141 -942
  27. package/lib/container.js +2 -2
  28. package/lib/cron.js +2 -2
  29. package/lib/data-table.js +871 -846
  30. package/lib/date-picker.js +2003 -1779
  31. package/lib/descriptions-item.js +144 -0
  32. package/lib/descriptions.js +561 -0
  33. package/lib/dialog.js +862 -837
  34. package/lib/divider.js +2 -2
  35. package/lib/drawer.js +2 -2
  36. package/lib/dropdown-item.js +4 -4
  37. package/lib/dropdown-menu.js +1141 -942
  38. package/lib/dropdown.js +862 -837
  39. package/lib/email-login.js +862 -837
  40. package/lib/empty.js +2 -2
  41. package/lib/eoss.common.js +2485 -1819
  42. package/lib/flip.js +2 -2
  43. package/lib/flow-group.js +866 -841
  44. package/lib/flow.js +871 -846
  45. package/lib/flows.js +862 -837
  46. package/lib/footer.js +2 -2
  47. package/lib/form-item.js +875 -850
  48. package/lib/form.js +876 -849
  49. package/lib/guide.js +2 -2
  50. package/lib/header.js +2 -2
  51. package/lib/icon.js +862 -837
  52. package/lib/icons.js +2 -2
  53. package/lib/image-viewer.js +862 -837
  54. package/lib/image.js +4 -4
  55. package/lib/index.js +1 -1
  56. package/lib/infinite-scroll.js +2 -2
  57. package/lib/input-number.js +2 -2
  58. package/lib/input.js +884 -859
  59. package/lib/link.js +2 -2
  60. package/lib/loading.js +2 -2
  61. package/lib/login.js +913 -873
  62. package/lib/lowcode-view.js +862 -837
  63. package/lib/lowcode.js +901 -876
  64. package/lib/main.js +908 -880
  65. package/lib/marquee.js +862 -837
  66. package/lib/menu-item-group.js +2 -2
  67. package/lib/menu-item.js +2 -2
  68. package/lib/menu.js +2003 -1779
  69. package/lib/message-box.js +862 -837
  70. package/lib/message.js +884 -859
  71. package/lib/notification.js +862 -837
  72. package/lib/option-group.js +4 -4
  73. package/lib/option.js +871 -846
  74. package/lib/page-header.js +2 -2
  75. package/lib/pagination.js +862 -837
  76. package/lib/phone-login.js +862 -837
  77. package/lib/popconfirm.js +4 -4
  78. package/lib/popover.js +2001 -1777
  79. package/lib/process-config.js +869 -844
  80. package/lib/process-module.js +862 -837
  81. package/lib/process-rule.js +862 -837
  82. package/lib/progress.js +2 -2
  83. package/lib/qr-code.js +4 -4
  84. package/lib/qrcode-login.js +870 -845
  85. package/lib/radio-button.js +2 -2
  86. package/lib/radio-group.js +871 -846
  87. package/lib/radio.js +2 -2
  88. package/lib/rate.js +862 -837
  89. package/lib/row.js +2 -2
  90. package/lib/scrollbar.js +862 -837
  91. package/lib/select.js +2005 -1781
  92. package/lib/selector-panel.js +873 -848
  93. package/lib/selector.js +866 -841
  94. package/lib/slider.js +2 -2
  95. package/lib/step.js +5 -5
  96. package/lib/steps.js +865 -840
  97. package/lib/submenu.js +1143 -944
  98. package/lib/switch.js +862 -837
  99. package/lib/tab-pane.js +4 -4
  100. package/lib/table-column.js +862 -837
  101. package/lib/table.js +2003 -1779
  102. package/lib/tabs.js +864 -839
  103. package/lib/tag.js +2 -2
  104. package/lib/theme-chalk/base.css +1 -1
  105. package/lib/theme-chalk/descriptions.css +1 -1
  106. package/lib/theme-chalk/index.css +1 -1
  107. package/lib/theme-chalk/main.css +1 -1
  108. package/lib/time-picker.js +2004 -1780
  109. package/lib/time-select.js +2001 -1777
  110. package/lib/timeline-item.js +2 -2
  111. package/lib/timeline.js +2 -2
  112. package/lib/tips.js +862 -837
  113. package/lib/toolbar.js +2 -2
  114. package/lib/tooltip.js +2003 -1779
  115. package/lib/transfer.js +869 -844
  116. package/lib/tree-group.js +862 -837
  117. package/lib/tree.js +862 -837
  118. package/lib/update-history.js +2 -2
  119. package/lib/upload.js +868 -843
  120. package/lib/utils/popper.js +97 -48
  121. package/lib/wujie.js +866 -841
  122. package/package.json +1 -1
  123. package/packages/account-login/src/account-login.vue +29 -0
  124. package/packages/descriptions/index.js +8 -0
  125. package/packages/descriptions/src/index.js +181 -0
  126. package/packages/descriptions/src/item.js +30 -0
  127. package/packages/descriptions/src/row.js +120 -0
  128. package/packages/descriptions-item/index.js +8 -0
  129. package/packages/login/src/login.vue +8 -0
  130. package/packages/login/src/mixins.js +3 -1
  131. package/packages/main/src/minxs.js +1 -0
  132. package/packages/theme-chalk/src/base.scss +2 -1
  133. package/packages/theme-chalk/src/descriptions.scss +0 -1
  134. package/packages/theme-chalk/src/index.scss +2 -0
  135. package/src/index.js +333 -327
  136. package/src/utils/popper.js +109 -70
package/lib/scrollbar.js CHANGED
@@ -82,7 +82,7 @@ module.exports =
82
82
  /******/
83
83
  /******/
84
84
  /******/ // Load entry module and return exports
85
- /******/ return __webpack_require__(__webpack_require__.s = 267);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 270);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -3673,7 +3673,7 @@ module.exports = require("throttle-debounce");
3673
3673
 
3674
3674
  /***/ }),
3675
3675
 
3676
- /***/ 267:
3676
+ /***/ 270:
3677
3677
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3678
3678
 
3679
3679
  "use strict";
@@ -5469,736 +5469,759 @@ function renderThumbStyle(_ref3) {
5469
5469
  /* unused harmony export getSecond */
5470
5470
  /* unused harmony export getWeekday */
5471
5471
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
5472
-
5473
-
5472
+ /* Modified from https://github.com/taylorhakes/fecha
5473
+ *
5474
+ * The MIT License (MIT)
5475
+ *
5476
+ * Copyright (c) 2015 Taylor Hakes
5477
+ *
5478
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5479
+ * of this software and associated documentation files (the "Software"), to deal
5480
+ * in the Software without restriction, including without limitation the rights
5481
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5482
+ * copies of the Software, and to permit persons to whom the Software is
5483
+ * furnished to do so, subject to the following conditions:
5484
+ *
5485
+ * The above copyright notice and this permission notice shall be included in all
5486
+ * copies or substantial portions of the Software.
5487
+ *
5488
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5489
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5490
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5491
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5492
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5493
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
5494
+ * SOFTWARE.
5495
+ */
5496
+
5497
+ /*eslint-disable*/
5498
+ // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
5499
+
5500
+
5474
5501
  /**
5475
5502
  * Parse or format dates
5476
5503
  * @class fecha
5477
- */
5478
- var fecha = {};
5479
- var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
5480
- var twoDigits = '\\d\\d?';
5481
- var threeDigits = '\\d{3}';
5482
- var fourDigits = '\\d{4}';
5483
- var word = '[^\\s]+';
5484
- var literal = /\[([^]*?)\]/gm;
5485
- var noop = function noop() {};
5486
-
5487
- function regexEscape(str) {
5488
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
5489
- }
5490
-
5491
- function shorten(arr, sLen) {
5492
- var newArr = [];
5493
- for (var i = 0, len = arr.length; i < len; i++) {
5494
- newArr.push(arr[i].substr(0, sLen));
5495
- }
5496
- return newArr;
5497
- }
5498
-
5499
- function monthUpdate() {
5500
- return function (d, v) {
5501
- var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
5502
- if (~index) {
5503
- d.month = index;
5504
- }
5505
- };
5506
- }
5507
-
5508
- function pad(val, len) {
5509
- val = String(val);
5510
- len = len || 2;
5511
- while (val.length < len) {
5512
- val = '0' + val;
5513
- }
5514
- return val;
5515
- }
5516
-
5517
- // 直接使用中文日期名称常量
5518
- var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
5519
- var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
5520
- var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
5521
- var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
5522
- var amPm = ['上午', '下午'];
5523
- var DoFn = function DoFn(D) {
5524
- return D + '日';
5525
- };
5526
-
5527
- var formatFlags = {
5528
- D: function D(dateObj) {
5529
- return dateObj.getDay();
5530
- },
5531
- DD: function DD(dateObj) {
5532
- return pad(dateObj.getDay());
5533
- },
5534
- Do: function Do(dateObj) {
5535
- return DoFn(dateObj.getDate());
5536
- },
5537
- d: function d(dateObj) {
5538
- return dateObj.getDate();
5539
- },
5540
- dd: function dd(dateObj) {
5541
- return pad(dateObj.getDate());
5542
- },
5543
- ddd: function ddd(dateObj) {
5544
- return dayNamesShort[dateObj.getDay()];
5545
- },
5546
- dddd: function dddd(dateObj) {
5547
- return dayNames[dateObj.getDay()];
5548
- },
5549
- M: function M(dateObj) {
5550
- return dateObj.getMonth() + 1;
5551
- },
5552
- MM: function MM(dateObj) {
5553
- return pad(dateObj.getMonth() + 1);
5554
- },
5555
- MMM: function MMM(dateObj) {
5556
- return monthNamesShort[dateObj.getMonth()];
5557
- },
5558
- MMMM: function MMMM(dateObj) {
5559
- return monthNames[dateObj.getMonth()];
5560
- },
5561
- yy: function yy(dateObj) {
5562
- return pad(String(dateObj.getFullYear()), 4).substr(2);
5563
- },
5564
- yyyy: function yyyy(dateObj) {
5565
- return pad(dateObj.getFullYear(), 4);
5566
- },
5567
- h: function h(dateObj) {
5568
- return dateObj.getHours() % 12 || 12;
5569
- },
5570
- hh: function hh(dateObj) {
5571
- return pad(dateObj.getHours() % 12 || 12);
5572
- },
5573
- H: function H(dateObj) {
5574
- return dateObj.getHours();
5575
- },
5576
- HH: function HH(dateObj) {
5577
- return pad(dateObj.getHours());
5578
- },
5579
- m: function m(dateObj) {
5580
- return dateObj.getMinutes();
5581
- },
5582
- mm: function mm(dateObj) {
5583
- return pad(dateObj.getMinutes());
5584
- },
5585
- s: function s(dateObj) {
5586
- return dateObj.getSeconds();
5587
- },
5588
- ss: function ss(dateObj) {
5589
- return pad(dateObj.getSeconds());
5590
- },
5591
- S: function S(dateObj) {
5592
- return Math.round(dateObj.getMilliseconds() / 100);
5593
- },
5594
- SS: function SS(dateObj) {
5595
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
5596
- },
5597
- SSS: function SSS(dateObj) {
5598
- return pad(dateObj.getMilliseconds(), 3);
5599
- },
5600
- a: function a(dateObj) {
5601
- return dateObj.getHours() < 12 ? '上午' : '下午';
5602
- },
5603
- A: function A(dateObj) {
5604
- return dateObj.getHours() < 12 ? '上午' : '下午';
5605
- },
5606
- ZZ: function ZZ(dateObj) {
5607
- var o = dateObj.getTimezoneOffset();
5608
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
5609
- }
5610
- };
5611
-
5612
- var parseFlags = {
5613
- d: [twoDigits, function (d, v) {
5614
- d.day = v;
5615
- }],
5616
- Do: [twoDigits + word, function (d, v) {
5617
- d.day = parseInt(v, 10);
5618
- }],
5619
- M: [twoDigits, function (d, v) {
5620
- d.month = v - 1;
5621
- }],
5622
- yy: [twoDigits, function (d, v) {
5623
- var da = new Date(),
5624
- cent = +('' + da.getFullYear()).substr(0, 2);
5625
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
5626
- }],
5627
- h: [twoDigits, function (d, v) {
5628
- d.hour = v;
5629
- }],
5630
- m: [twoDigits, function (d, v) {
5631
- d.minute = v;
5632
- }],
5633
- s: [twoDigits, function (d, v) {
5634
- d.second = v;
5635
- }],
5636
- yyyy: [fourDigits, function (d, v) {
5637
- d.year = v;
5638
- }],
5639
- S: ['\\d', function (d, v) {
5640
- d.millisecond = v * 100;
5641
- }],
5642
- SS: ['\\d{2}', function (d, v) {
5643
- d.millisecond = v * 10;
5644
- }],
5645
- SSS: [threeDigits, function (d, v) {
5646
- d.millisecond = v;
5647
- }],
5648
- D: [twoDigits, noop],
5649
- ddd: [word, noop],
5650
- MMM: [word, monthUpdate('monthNamesShort')],
5651
- MMMM: [word, monthUpdate('monthNames')],
5652
- a: [word, function (d, v) {
5653
- var val = v.toLowerCase();
5654
- if (val === '上午') {
5655
- d.isPm = false;
5656
- } else if (val === '下午') {
5657
- d.isPm = true;
5658
- }
5659
- }],
5660
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
5661
- var parts = (v + '').match(/([+-]|\d\d)/gi),
5662
- minutes = void 0;
5663
-
5664
- if (parts) {
5665
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
5666
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
5667
- }
5668
- }]
5669
- };
5670
- parseFlags.dd = parseFlags.d;
5671
- parseFlags.dddd = parseFlags.ddd;
5672
- parseFlags.DD = parseFlags.D;
5673
- parseFlags.mm = parseFlags.m;
5674
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
5675
- parseFlags.MM = parseFlags.M;
5676
- parseFlags.ss = parseFlags.s;
5677
- parseFlags.A = parseFlags.a;
5678
-
5679
- // Some common format strings
5680
- fecha.masks = {
5681
- default: 'ddd MMM dd yyyy HH:mm:ss',
5682
- shortDate: 'M/D/yy',
5683
- mediumDate: 'MMM d, yyyy',
5684
- longDate: 'MMMM d, yyyy',
5685
- fullDate: 'dddd, MMMM d, yyyy',
5686
- shortTime: 'HH:mm',
5687
- mediumTime: 'HH:mm:ss',
5688
- longTime: 'HH:mm:ss.SSS'
5689
- };
5690
-
5504
+ */
5505
+ const fecha = {};
5506
+ const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
5507
+ const twoDigits = '\\d\\d?';
5508
+ const threeDigits = '\\d{3}';
5509
+ const fourDigits = '\\d{4}';
5510
+ const word = '[^\\s]+';
5511
+ const literal = /\[([^]*?)\]/gm;
5512
+ const noop = function () {};
5513
+
5514
+ function regexEscape(str) {
5515
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
5516
+ }
5517
+
5518
+ function shorten(arr, sLen) {
5519
+ const newArr = [];
5520
+ for (let i = 0, len = arr.length; i < len; i++) {
5521
+ newArr.push(arr[i].substr(0, sLen));
5522
+ }
5523
+ return newArr;
5524
+ }
5525
+
5526
+ function monthUpdate() {
5527
+ return function (d, v) {
5528
+ const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
5529
+ if (~index) {
5530
+ d.month = index;
5531
+ }
5532
+ };
5533
+ }
5534
+
5535
+ function pad(val, len) {
5536
+ val = String(val);
5537
+ len = len || 2;
5538
+ while (val.length < len) {
5539
+ val = '0' + val;
5540
+ }
5541
+ return val;
5542
+ }
5543
+
5544
+ // 直接使用中文日期名称常量
5545
+ const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
5546
+ const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
5547
+ const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
5548
+ const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
5549
+ const amPm = ['上午', '下午'];
5550
+ const DoFn = function DoFn(D) {
5551
+ return D + '日';
5552
+ };
5553
+
5554
+ const formatFlags = {
5555
+ D: function(dateObj) {
5556
+ return dateObj.getDay();
5557
+ },
5558
+ DD: function(dateObj) {
5559
+ return pad(dateObj.getDay());
5560
+ },
5561
+ Do: function(dateObj) {
5562
+ return DoFn(dateObj.getDate());
5563
+ },
5564
+ d: function(dateObj) {
5565
+ return dateObj.getDate();
5566
+ },
5567
+ dd: function(dateObj) {
5568
+ return pad(dateObj.getDate());
5569
+ },
5570
+ ddd: function(dateObj) {
5571
+ return dayNamesShort[dateObj.getDay()];
5572
+ },
5573
+ dddd: function(dateObj) {
5574
+ return dayNames[dateObj.getDay()];
5575
+ },
5576
+ M: function(dateObj) {
5577
+ return dateObj.getMonth() + 1;
5578
+ },
5579
+ MM: function(dateObj) {
5580
+ return pad(dateObj.getMonth() + 1);
5581
+ },
5582
+ MMM: function(dateObj) {
5583
+ return monthNamesShort[dateObj.getMonth()];
5584
+ },
5585
+ MMMM: function(dateObj) {
5586
+ return monthNames[dateObj.getMonth()];
5587
+ },
5588
+ yy: function(dateObj) {
5589
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
5590
+ },
5591
+ yyyy: function(dateObj) {
5592
+ return pad(dateObj.getFullYear(), 4);
5593
+ },
5594
+ h: function(dateObj) {
5595
+ return dateObj.getHours() % 12 || 12;
5596
+ },
5597
+ hh: function(dateObj) {
5598
+ return pad(dateObj.getHours() % 12 || 12);
5599
+ },
5600
+ H: function(dateObj) {
5601
+ return dateObj.getHours();
5602
+ },
5603
+ HH: function(dateObj) {
5604
+ return pad(dateObj.getHours());
5605
+ },
5606
+ m: function(dateObj) {
5607
+ return dateObj.getMinutes();
5608
+ },
5609
+ mm: function(dateObj) {
5610
+ return pad(dateObj.getMinutes());
5611
+ },
5612
+ s: function(dateObj) {
5613
+ return dateObj.getSeconds();
5614
+ },
5615
+ ss: function(dateObj) {
5616
+ return pad(dateObj.getSeconds());
5617
+ },
5618
+ S: function(dateObj) {
5619
+ return Math.round(dateObj.getMilliseconds() / 100);
5620
+ },
5621
+ SS: function(dateObj) {
5622
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
5623
+ },
5624
+ SSS: function(dateObj) {
5625
+ return pad(dateObj.getMilliseconds(), 3);
5626
+ },
5627
+ a: function(dateObj) {
5628
+ return dateObj.getHours() < 12 ? '上午' : '下午';
5629
+ },
5630
+ A: function(dateObj) {
5631
+ return dateObj.getHours() < 12 ? '上午' : '下午';
5632
+ },
5633
+ ZZ: function(dateObj) {
5634
+ const o = dateObj.getTimezoneOffset();
5635
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
5636
+ }
5637
+ };
5638
+
5639
+ const parseFlags = {
5640
+ d: [twoDigits, function (d, v) {
5641
+ d.day = v;
5642
+ }],
5643
+ Do: [twoDigits + word, function (d, v) {
5644
+ d.day = parseInt(v, 10);
5645
+ }],
5646
+ M: [twoDigits, function (d, v) {
5647
+ d.month = v - 1;
5648
+ }],
5649
+ yy: [twoDigits, function (d, v) {
5650
+ const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
5651
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
5652
+ }],
5653
+ h: [twoDigits, function (d, v) {
5654
+ d.hour = v;
5655
+ }],
5656
+ m: [twoDigits, function (d, v) {
5657
+ d.minute = v;
5658
+ }],
5659
+ s: [twoDigits, function (d, v) {
5660
+ d.second = v;
5661
+ }],
5662
+ yyyy: [fourDigits, function (d, v) {
5663
+ d.year = v;
5664
+ }],
5665
+ S: ['\\d', function (d, v) {
5666
+ d.millisecond = v * 100;
5667
+ }],
5668
+ SS: ['\\d{2}', function (d, v) {
5669
+ d.millisecond = v * 10;
5670
+ }],
5671
+ SSS: [threeDigits, function (d, v) {
5672
+ d.millisecond = v;
5673
+ }],
5674
+ D: [twoDigits, noop],
5675
+ ddd: [word, noop],
5676
+ MMM: [word, monthUpdate('monthNamesShort')],
5677
+ MMMM: [word, monthUpdate('monthNames')],
5678
+ a: [word, function (d, v) {
5679
+ const val = v.toLowerCase();
5680
+ if (val === '上午') {
5681
+ d.isPm = false;
5682
+ } else if (val === '下午') {
5683
+ d.isPm = true;
5684
+ }
5685
+ }],
5686
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
5687
+ let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
5688
+
5689
+ if (parts) {
5690
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
5691
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
5692
+ }
5693
+ }]
5694
+ };
5695
+ parseFlags.dd = parseFlags.d;
5696
+ parseFlags.dddd = parseFlags.ddd;
5697
+ parseFlags.DD = parseFlags.D;
5698
+ parseFlags.mm = parseFlags.m;
5699
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
5700
+ parseFlags.MM = parseFlags.M;
5701
+ parseFlags.ss = parseFlags.s;
5702
+ parseFlags.A = parseFlags.a;
5703
+
5704
+
5705
+ // Some common format strings
5706
+ fecha.masks = {
5707
+ default: 'ddd MMM dd yyyy HH:mm:ss',
5708
+ shortDate: 'M/D/yy',
5709
+ mediumDate: 'MMM d, yyyy',
5710
+ longDate: 'MMMM d, yyyy',
5711
+ fullDate: 'dddd, MMMM d, yyyy',
5712
+ shortTime: 'HH:mm',
5713
+ mediumTime: 'HH:mm:ss',
5714
+ longTime: 'HH:mm:ss.SSS'
5715
+ };
5716
+
5691
5717
  /***
5692
5718
  * Format a date
5693
5719
  * @method format
5694
5720
  * @param {Date|number} dateObj
5695
5721
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
5696
- */
5697
- fecha.format = function (dateObj, mask) {
5698
- if (typeof dateObj === 'number') {
5699
- dateObj = new Date(dateObj);
5700
- }
5701
-
5702
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
5703
- throw new Error('Invalid Date in fecha.format');
5704
- }
5705
-
5706
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
5707
-
5708
- var literals = [];
5709
-
5710
- // Make literals inactive by replacing them with ??
5711
- mask = mask.replace(literal, function ($0, $1) {
5712
- literals.push($1);
5713
- return '@@@';
5714
- });
5715
- // Apply formatting rules
5716
- mask = mask.replace(token, function ($0) {
5717
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
5718
- });
5719
- // Inline literal values back into the formatted value
5720
- return mask.replace(/@@@/g, function () {
5721
- return literals.shift();
5722
- });
5723
- };
5724
-
5722
+ */
5723
+ fecha.format = function (dateObj, mask) {
5724
+ if (typeof dateObj === 'number') {
5725
+ dateObj = new Date(dateObj);
5726
+ }
5727
+
5728
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
5729
+ throw new Error('Invalid Date in fecha.format');
5730
+ }
5731
+
5732
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
5733
+
5734
+ const literals = [];
5735
+
5736
+ // Make literals inactive by replacing them with ??
5737
+ mask = mask.replace(literal, function($0, $1) {
5738
+ literals.push($1);
5739
+ return '@@@';
5740
+ });
5741
+ // Apply formatting rules
5742
+ mask = mask.replace(token, function ($0) {
5743
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
5744
+ });
5745
+ // Inline literal values back into the formatted value
5746
+ return mask.replace(/@@@/g, function() {
5747
+ return literals.shift();
5748
+ });
5749
+ };
5750
+
5725
5751
  /**
5726
5752
  * Parse a date string into an object, changes - into /
5727
5753
  * @method parse
5728
5754
  * @param {string} dateStr Date string
5729
5755
  * @param {string} format Date parse format
5730
5756
  * @returns {Date|boolean}
5731
- */
5732
- fecha.parse = function (dateStr, format) {
5733
- if (typeof format !== 'string') {
5734
- throw new Error('Invalid format in fecha.parse');
5735
- }
5736
-
5737
- format = fecha.masks[format] || format;
5738
-
5739
- // Avoid regular expression denial of service, fail early for really long strings
5740
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
5741
- if (dateStr.length > 1000) {
5742
- return null;
5743
- }
5744
-
5745
- var dateInfo = {};
5746
- var parseInfo = [];
5747
- var literals = [];
5748
- format = format.replace(literal, function ($0, $1) {
5749
- literals.push($1);
5750
- return '@@@';
5751
- });
5752
- var newFormat = regexEscape(format).replace(token, function ($0) {
5753
- if (parseFlags[$0]) {
5754
- var info = parseFlags[$0];
5755
- parseInfo.push(info[1]);
5756
- return '(' + info[0] + ')';
5757
- }
5758
-
5759
- return $0;
5760
- });
5761
- newFormat = newFormat.replace(/@@@/g, function () {
5762
- return literals.shift();
5763
- });
5764
- var matches = dateStr.match(new RegExp(newFormat, 'i'));
5765
- if (!matches) {
5766
- return null;
5767
- }
5768
-
5769
- for (var i = 1; i < matches.length; i++) {
5770
- parseInfo[i - 1](dateInfo, matches[i]);
5771
- }
5772
-
5773
- var today = new Date();
5774
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
5775
- dateInfo.hour = +dateInfo.hour + 12;
5776
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
5777
- dateInfo.hour = 0;
5778
- }
5779
-
5780
- var date = void 0;
5781
- if (dateInfo.timezoneOffset != null) {
5782
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
5783
- 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));
5784
- } else {
5785
- 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);
5786
- }
5787
- return date;
5788
- };
5789
-
5790
- // 导出fecha对象
5791
-
5792
-
5793
- // 以下是从date-util.js合并的函数
5794
- var newArray = function newArray(start, end) {
5795
- var result = [];
5796
- for (var i = start; i <= end; i++) {
5797
- result.push(i);
5798
- }
5799
- return result;
5800
- };
5801
-
5802
- var getSettings = function getSettings() {
5803
- return {
5804
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
5805
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
5806
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
5807
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
5808
- amPm: ['上午', '下午']
5809
- };
5810
- };
5811
-
5812
- var toDate = function toDate(date) {
5813
- return isDate(date) ? new Date(date) : null;
5814
- };
5815
-
5816
- var isDate = function isDate(date) {
5817
- if (date === null || date === undefined) return false;
5818
- if (isNaN(new Date(date).getTime())) return false;
5819
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
5820
- return true;
5821
- };
5822
-
5823
- var isDateObject = function isDateObject(val) {
5824
- return val instanceof Date;
5825
- };
5826
-
5827
- var formatDate = function formatDate(date) {
5828
- var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
5829
-
5830
- // 处理多种输入类型
5831
- if (!date) return '';
5832
-
5833
- // 如果是时间戳,转成日期对象
5834
- if (typeof date === 'number') {
5835
- date = new Date(date);
5836
- }
5837
- // 如果是字符串,转成日期对象
5838
- if (typeof date === 'string') {
5839
- date = new Date(date);
5840
- }
5841
-
5842
- // 调用toDate进一步验证和转换
5843
- date = toDate(date);
5844
- if (!date) return '';
5845
-
5846
- // 兼容大写和小写的格式标记
5847
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
5848
- var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
5849
-
5850
- // 使用fecha库进行格式化,支持中文配置
5851
- var str = fecha.format(date, lowercaseFormat, getSettings());
5852
- return str;
5853
- };
5854
-
5855
- var parseDate = function parseDate(string, format) {
5856
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
5857
- };
5858
-
5859
- var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
5860
- if (month === 3 || month === 5 || month === 8 || month === 10) {
5861
- return 30;
5862
- }
5863
-
5864
- if (month === 1) {
5865
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
5866
- return 29;
5867
- } else {
5868
- return 28;
5869
- }
5870
- }
5871
-
5872
- return 31;
5873
- };
5874
-
5875
- var getDayCountOfYear = function getDayCountOfYear(year) {
5876
- var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
5877
- return isLeapYear ? 366 : 365;
5878
- };
5879
-
5880
- var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
5881
- var temp = new Date(date.getTime());
5882
- temp.setDate(1);
5883
- return temp.getDay();
5884
- };
5885
-
5886
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
5887
- // {prev, next} Date should work for Daylight Saving Time
5888
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
5889
- var prevDate = function prevDate(date) {
5890
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5891
-
5892
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
5893
- };
5894
-
5895
- var nextDate = function nextDate(date) {
5896
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5897
-
5898
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
5899
- };
5900
-
5901
- var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
5902
- var result = new Date(year, month, 1);
5903
- var day = result.getDay();
5904
-
5905
- if (day === 0) {
5906
- return prevDate(result, 7);
5907
- } else {
5908
- return prevDate(result, day);
5909
- }
5910
- };
5911
-
5912
- var getWeekNumber = function getWeekNumber(date) {
5913
- // 支持多种输入类型
5914
- if (!date || !isDate(date)) {
5915
- date = new Date();
5916
- }
5917
- if (typeof date === 'string') {
5918
- date = new Date(date);
5919
- }
5920
-
5921
- // 验证日期有效性
5922
- if (!isDate(date)) return null;
5923
-
5924
- var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
5925
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
5926
- // 将星期日的星期数设为7
5927
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
5928
- // 获取当年的第一天
5929
- var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
5930
- // 计算到最近的星期四的完整周数
5931
- var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
5932
- // 返回周数
5933
- return weekNo;
5934
- };
5935
-
5936
- var getRangeHours = function getRangeHours(ranges) {
5937
- var hours = [];
5938
- var disabledHours = [];
5939
-
5940
- (ranges || []).forEach(function (range) {
5941
- var value = range.map(function (date) {
5942
- return date.getHours();
5943
- });
5944
-
5945
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
5946
- });
5947
-
5948
- if (disabledHours.length) {
5949
- for (var i = 0; i < 24; i++) {
5950
- hours[i] = disabledHours.indexOf(i) === -1;
5951
- }
5952
- } else {
5953
- for (var _i = 0; _i < 24; _i++) {
5954
- hours[_i] = false;
5955
- }
5956
- }
5957
-
5958
- return hours;
5959
- };
5960
-
5961
- var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
5962
- if (amount <= 0) return [];
5963
- var temp = new Date(date.getTime());
5964
- temp.setDate(0);
5965
- var lastDay = temp.getDate();
5966
- return range(amount).map(function (_, index) {
5967
- return lastDay - (amount - index - 1);
5968
- });
5969
- };
5970
-
5971
- var getMonthDays = function getMonthDays(date) {
5972
- var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
5973
- var days = temp.getDate();
5974
- return range(days).map(function (_, index) {
5975
- return index + 1;
5976
- });
5977
- };
5978
-
5979
- function setRangeData(arr, start, end, value) {
5980
- for (var i = start; i < end; i++) {
5981
- arr[i] = value;
5982
- }
5983
- }
5984
-
5985
- var getRangeMinutes = function getRangeMinutes(ranges, hour) {
5986
- var minutes = new Array(60);
5987
-
5988
- if (ranges.length > 0) {
5989
- ranges.forEach(function (range) {
5990
- var start = range[0];
5991
- var end = range[1];
5992
- var startHour = start.getHours();
5993
- var startMinute = start.getMinutes();
5994
- var endHour = end.getHours();
5995
- var endMinute = end.getMinutes();
5996
- if (startHour === hour && endHour !== hour) {
5997
- setRangeData(minutes, startMinute, 60, true);
5998
- } else if (startHour === hour && endHour === hour) {
5999
- setRangeData(minutes, startMinute, endMinute + 1, true);
6000
- } else if (startHour !== hour && endHour === hour) {
6001
- setRangeData(minutes, 0, endMinute + 1, true);
6002
- } else if (startHour < hour && endHour > hour) {
6003
- setRangeData(minutes, 0, 60, true);
6004
- }
6005
- });
6006
- } else {
6007
- setRangeData(minutes, 0, 60, true);
6008
- }
6009
- return minutes;
6010
- };
6011
-
6012
- var range = function range(n) {
6013
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
6014
- return Array.apply(null, { length: n }).map(function (_, n) {
6015
- return n;
6016
- });
6017
- };
6018
-
6019
- var modifyDate = function modifyDate(date, y, m, d) {
6020
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
6021
- };
6022
-
6023
- var modifyTime = function modifyTime(date, h, m, s) {
6024
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
6025
- };
6026
-
6027
- var modifyWithTimeString = function modifyWithTimeString(date, time) {
6028
- if (date == null || !time) {
6029
- return date;
6030
- }
6031
- time = parseDate(time, 'HH:mm:ss');
6032
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
6033
- };
6034
-
6035
- var clearTime = function clearTime(date) {
6036
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
6037
- };
6038
-
6039
- var clearMilliseconds = function clearMilliseconds(date) {
6040
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
6041
- };
6042
-
6043
- var limitTimeRange = function limitTimeRange(date, ranges) {
6044
- var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
6045
-
6046
- // TODO: refactory a more elegant solution
6047
- if (ranges.length === 0) return date;
6048
- var normalizeDate = function normalizeDate(date) {
6049
- return fecha.parse(fecha.format(date, format), format);
6050
- };
6051
- var ndate = normalizeDate(date);
6052
- var nranges = ranges.map(function (range) {
6053
- return range.map(normalizeDate);
6054
- });
6055
- if (nranges.some(function (nrange) {
6056
- return ndate >= nrange[0] && ndate <= nrange[1];
6057
- })) return date;
6058
-
6059
- var minDate = nranges[0][0];
6060
- var maxDate = nranges[0][0];
6061
-
6062
- nranges.forEach(function (nrange) {
6063
- minDate = new Date(Math.min(nrange[0], minDate));
6064
- maxDate = new Date(Math.max(nrange[1], minDate));
6065
- });
6066
-
6067
- var ret = ndate < minDate ? minDate : maxDate;
6068
- // preserve Year/Month/Date
6069
- return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
6070
- };
6071
-
6072
- var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
6073
- var limitedDate = limitTimeRange(date, selectableRange, format);
6074
- return limitedDate.getTime() === date.getTime();
6075
- };
6076
-
6077
- var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
6078
- // clamp date to the number of days in `year`, `month`
6079
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
6080
- var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
6081
- return modifyDate(date, year, month, monthDate);
6082
- };
6083
-
6084
- var prevMonth = function prevMonth(date) {
6085
- var year = date.getFullYear();
6086
- var month = date.getMonth();
6087
- return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
6088
- };
6089
-
6090
- var nextMonth = function nextMonth(date) {
6091
- var year = date.getFullYear();
6092
- var month = date.getMonth();
6093
- return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
6094
- };
6095
-
6096
- var prevYear = function prevYear(date) {
6097
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6098
-
6099
- var year = date.getFullYear();
6100
- var month = date.getMonth();
6101
- return changeYearMonthAndClampDate(date, year - amount, month);
6102
- };
6103
-
6104
- var nextYear = function nextYear(date) {
6105
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
6106
-
6107
- var year = date.getFullYear();
6108
- var month = date.getMonth();
6109
- return changeYearMonthAndClampDate(date, year + amount, month);
6110
- };
6111
-
6112
- var extractDateFormat = function extractDateFormat(format) {
6113
- return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
6114
- };
6115
-
6116
- var extractTimeFormat = function extractTimeFormat(format) {
6117
- return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
6118
- };
6119
-
6120
- var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
6121
- return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
6122
- };
6123
-
5757
+ */
5758
+ fecha.parse = function (dateStr, format) {
5759
+ if (typeof format !== 'string') {
5760
+ throw new Error('Invalid format in fecha.parse');
5761
+ }
5762
+
5763
+ format = fecha.masks[format] || format;
5764
+
5765
+ // Avoid regular expression denial of service, fail early for really long strings
5766
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
5767
+ if (dateStr.length > 1000) {
5768
+ return null;
5769
+ }
5770
+
5771
+ const dateInfo = {};
5772
+ const parseInfo = [];
5773
+ const literals = [];
5774
+ format = format.replace(literal, function($0, $1) {
5775
+ literals.push($1);
5776
+ return '@@@';
5777
+ });
5778
+ let newFormat = regexEscape(format).replace(token, function ($0) {
5779
+ if (parseFlags[$0]) {
5780
+ const info = parseFlags[$0];
5781
+ parseInfo.push(info[1]);
5782
+ return '(' + info[0] + ')';
5783
+ }
5784
+
5785
+ return $0;
5786
+ });
5787
+ newFormat = newFormat.replace(/@@@/g, function() {
5788
+ return literals.shift();
5789
+ });
5790
+ const matches = dateStr.match(new RegExp(newFormat, 'i'));
5791
+ if (!matches) {
5792
+ return null;
5793
+ }
5794
+
5795
+ for (let i = 1; i < matches.length; i++) {
5796
+ parseInfo[i - 1](dateInfo, matches[i]);
5797
+ }
5798
+
5799
+ const today = new Date();
5800
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
5801
+ dateInfo.hour = +dateInfo.hour + 12;
5802
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
5803
+ dateInfo.hour = 0;
5804
+ }
5805
+
5806
+ let date;
5807
+ if (dateInfo.timezoneOffset != null) {
5808
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
5809
+ date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
5810
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
5811
+ } else {
5812
+ date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
5813
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
5814
+ }
5815
+ return date;
5816
+ };
5817
+
5818
+ // 导出fecha对象
5819
+
5820
+
5821
+ // 以下是从date-util.js合并的函数
5822
+ const newArray = function(start, end) {
5823
+ let result = [];
5824
+ for (let i = start; i <= end; i++) {
5825
+ result.push(i);
5826
+ }
5827
+ return result;
5828
+ };
5829
+
5830
+ const getSettings = () => {
5831
+ return {
5832
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
5833
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
5834
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
5835
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
5836
+ amPm: ['上午', '下午']
5837
+ };
5838
+ };
5839
+
5840
+ const toDate = function(date) {
5841
+ return isDate(date) ? new Date(date) : null;
5842
+ };
5843
+
5844
+ const isDate = function(date) {
5845
+ if (date === null || date === undefined) return false;
5846
+ if (isNaN(new Date(date).getTime())) return false;
5847
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
5848
+ return true;
5849
+ };
5850
+
5851
+ const isDateObject = function(val) {
5852
+ return val instanceof Date;
5853
+ };
5854
+
5855
+ const formatDate = function (date, format = 'yyyy-MM-dd') {
5856
+ // 处理多种输入类型
5857
+ if (!date) return '';
5858
+
5859
+ // 如果是时间戳,转成日期对象
5860
+ if (typeof date === 'number') {
5861
+ date = new Date(date);
5862
+ }
5863
+ // 如果是字符串,转成日期对象
5864
+ if (typeof date === 'string') {
5865
+ date = new Date(date);
5866
+ }
5867
+
5868
+ // 调用toDate进一步验证和转换
5869
+ date = toDate(date);
5870
+ if (!date) return '';
5871
+
5872
+ // 兼容大写和小写的格式标记
5873
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
5874
+ const lowercaseFormat = format
5875
+ .replace(/YYYY/g, 'yyyy')
5876
+ .replace(/D/g, 'd')
5877
+
5878
+ // 使用fecha库进行格式化,支持中文配置
5879
+ const str = fecha.format(date, lowercaseFormat, getSettings());
5880
+ return str;
5881
+ };
5882
+
5883
+ const parseDate = function(string, format) {
5884
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
5885
+ };
5886
+
5887
+ const getDayCountOfMonth = function(year, month) {
5888
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
5889
+ return 30;
5890
+ }
5891
+
5892
+ if (month === 1) {
5893
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
5894
+ return 29;
5895
+ } else {
5896
+ return 28;
5897
+ }
5898
+ }
5899
+
5900
+ return 31;
5901
+ };
5902
+
5903
+ const getDayCountOfYear = function(year) {
5904
+ const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
5905
+ return isLeapYear ? 366 : 365;
5906
+ };
5907
+
5908
+ const getFirstDayOfMonth = function(date) {
5909
+ const temp = new Date(date.getTime());
5910
+ temp.setDate(1);
5911
+ return temp.getDay();
5912
+ };
5913
+
5914
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
5915
+ // {prev, next} Date should work for Daylight Saving Time
5916
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
5917
+ const prevDate = function(date, amount = 1) {
5918
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
5919
+ };
5920
+
5921
+ const nextDate = function(date, amount = 1) {
5922
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
5923
+ };
5924
+
5925
+ const getStartDateOfMonth = function(year, month) {
5926
+ const result = new Date(year, month, 1);
5927
+ const day = result.getDay();
5928
+
5929
+ if (day === 0) {
5930
+ return prevDate(result, 7);
5931
+ } else {
5932
+ return prevDate(result, day);
5933
+ }
5934
+ };
5935
+
5936
+ const getWeekNumber = function(date) {
5937
+ // 支持多种输入类型
5938
+ if (!date||!isDate(date)) {
5939
+ date = new Date();
5940
+ }
5941
+ if (typeof date === 'string') {
5942
+ date = new Date(date);
5943
+ }
5944
+
5945
+ // 验证日期有效性
5946
+ if (!isDate(date)) return null;
5947
+
5948
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
5949
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
5950
+ // 将星期日的星期数设为7
5951
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
5952
+ // 获取当年的第一天
5953
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
5954
+ // 计算到最近的星期四的完整周数
5955
+ const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
5956
+ // 返回周数
5957
+ return weekNo;
5958
+ };
5959
+
5960
+ const getRangeHours = function(ranges) {
5961
+ const hours = [];
5962
+ let disabledHours = [];
5963
+
5964
+ (ranges || []).forEach(range => {
5965
+ const value = range.map(date => date.getHours());
5966
+
5967
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
5968
+ });
5969
+
5970
+ if (disabledHours.length) {
5971
+ for (let i = 0; i < 24; i++) {
5972
+ hours[i] = disabledHours.indexOf(i) === -1;
5973
+ }
5974
+ } else {
5975
+ for (let i = 0; i < 24; i++) {
5976
+ hours[i] = false;
5977
+ }
5978
+ }
5979
+
5980
+ return hours;
5981
+ };
5982
+
5983
+ const getPrevMonthLastDays = (date, amount) => {
5984
+ if (amount <= 0) return [];
5985
+ const temp = new Date(date.getTime());
5986
+ temp.setDate(0);
5987
+ const lastDay = temp.getDate();
5988
+ return range(amount).map((_, index) => lastDay - (amount - index - 1));
5989
+ };
5990
+
5991
+ const getMonthDays = (date) => {
5992
+ const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
5993
+ const days = temp.getDate();
5994
+ return range(days).map((_, index) => index + 1);
5995
+ };
5996
+
5997
+ function setRangeData(arr, start, end, value) {
5998
+ for (let i = start; i < end; i++) {
5999
+ arr[i] = value;
6000
+ }
6001
+ }
6002
+
6003
+ const getRangeMinutes = function(ranges, hour) {
6004
+ const minutes = new Array(60);
6005
+
6006
+ if (ranges.length > 0) {
6007
+ ranges.forEach(range => {
6008
+ const start = range[0];
6009
+ const end = range[1];
6010
+ const startHour = start.getHours();
6011
+ const startMinute = start.getMinutes();
6012
+ const endHour = end.getHours();
6013
+ const endMinute = end.getMinutes();
6014
+ if (startHour === hour && endHour !== hour) {
6015
+ setRangeData(minutes, startMinute, 60, true);
6016
+ } else if (startHour === hour && endHour === hour) {
6017
+ setRangeData(minutes, startMinute, endMinute + 1, true);
6018
+ } else if (startHour !== hour && endHour === hour) {
6019
+ setRangeData(minutes, 0, endMinute + 1, true);
6020
+ } else if (startHour < hour && endHour > hour) {
6021
+ setRangeData(minutes, 0, 60, true);
6022
+ }
6023
+ });
6024
+ } else {
6025
+ setRangeData(minutes, 0, 60, true);
6026
+ }
6027
+ return minutes;
6028
+ };
6029
+
6030
+ const range = function(n) {
6031
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
6032
+ return Array.apply(null, {length: n}).map((_, n) => n);
6033
+ };
6034
+
6035
+ const modifyDate = function(date, y, m, d) {
6036
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
6037
+ };
6038
+
6039
+ const modifyTime = function(date, h, m, s) {
6040
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
6041
+ };
6042
+
6043
+ const modifyWithTimeString = (date, time) => {
6044
+ if (date == null || !time) {
6045
+ return date;
6046
+ }
6047
+ time = parseDate(time, 'HH:mm:ss');
6048
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
6049
+ };
6050
+
6051
+ const clearTime = function(date) {
6052
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
6053
+ };
6054
+
6055
+ const clearMilliseconds = function(date) {
6056
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
6057
+ };
6058
+
6059
+ const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
6060
+ // TODO: refactory a more elegant solution
6061
+ if (ranges.length === 0) return date;
6062
+ const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
6063
+ const ndate = normalizeDate(date);
6064
+ const nranges = ranges.map(range => range.map(normalizeDate));
6065
+ if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
6066
+
6067
+ let minDate = nranges[0][0];
6068
+ let maxDate = nranges[0][0];
6069
+
6070
+ nranges.forEach(nrange => {
6071
+ minDate = new Date(Math.min(nrange[0], minDate));
6072
+ maxDate = new Date(Math.max(nrange[1], minDate));
6073
+ });
6074
+
6075
+ const ret = ndate < minDate ? minDate : maxDate;
6076
+ // preserve Year/Month/Date
6077
+ return modifyDate(
6078
+ ret,
6079
+ date.getFullYear(),
6080
+ date.getMonth(),
6081
+ date.getDate()
6082
+ );
6083
+ };
6084
+
6085
+ const timeWithinRange = function(date, selectableRange, format) {
6086
+ const limitedDate = limitTimeRange(date, selectableRange, format);
6087
+ return limitedDate.getTime() === date.getTime();
6088
+ };
6089
+
6090
+ const changeYearMonthAndClampDate = function(date, year, month) {
6091
+ // clamp date to the number of days in `year`, `month`
6092
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
6093
+ const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
6094
+ return modifyDate(date, year, month, monthDate);
6095
+ };
6096
+
6097
+ const prevMonth = function(date) {
6098
+ const year = date.getFullYear();
6099
+ const month = date.getMonth();
6100
+ return month === 0
6101
+ ? changeYearMonthAndClampDate(date, year - 1, 11)
6102
+ : changeYearMonthAndClampDate(date, year, month - 1);
6103
+ };
6104
+
6105
+ const nextMonth = function(date) {
6106
+ const year = date.getFullYear();
6107
+ const month = date.getMonth();
6108
+ return month === 11
6109
+ ? changeYearMonthAndClampDate(date, year + 1, 0)
6110
+ : changeYearMonthAndClampDate(date, year, month + 1);
6111
+ };
6112
+
6113
+ const prevYear = function(date, amount = 1) {
6114
+ const year = date.getFullYear();
6115
+ const month = date.getMonth();
6116
+ return changeYearMonthAndClampDate(date, year - amount, month);
6117
+ };
6118
+
6119
+ const nextYear = function(date, amount = 1) {
6120
+ const year = date.getFullYear();
6121
+ const month = date.getMonth();
6122
+ return changeYearMonthAndClampDate(date, year + amount, month);
6123
+ };
6124
+
6125
+ const extractDateFormat = function(format) {
6126
+ return format
6127
+ .replace(/\W?m{1,2}|\W?ZZ/g, '')
6128
+ .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
6129
+ .trim();
6130
+ };
6131
+
6132
+ const extractTimeFormat = function(format) {
6133
+ return format
6134
+ .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
6135
+ .trim();
6136
+ };
6137
+
6138
+ const validateRangeInOneMonth = function(start, end) {
6139
+ return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
6140
+ };
6141
+
6124
6142
  /**
6125
6143
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
6126
6144
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
6127
6145
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
6128
6146
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
6129
6147
  * @returns {number} 工作日数量
6130
- */
6131
- var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
6132
- var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
6133
-
6134
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
6135
- throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
6136
- }
6137
-
6138
- var startDateObj = new Date(start_date);
6139
- var endDateObj = new Date(end_date);
6140
-
6141
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
6142
- throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
6143
- }
6144
-
6145
- if (startDateObj > endDateObj) {
6146
- throw new Error('Start date should be earlier than or equal to end date.');
6147
- }
6148
-
6149
- var workdays = 0;
6150
-
6151
- // Iterate through each day in the date range
6152
-
6153
- var _loop = function _loop(currentDate) {
6154
- // Check if the current day is a weekend (Saturday or Sunday)
6155
- var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
6156
-
6157
- // Check if the current day is a holiday
6158
- var isHoliday = holidays.some(function (holiday) {
6159
- var holidayDate = new Date(holiday);
6160
- return currentDate.toDateString() === holidayDate.toDateString();
6161
- });
6162
-
6163
- // If it's a workday (not a weekend or holiday), increment the workdays count
6164
- if (!isWeekend && !isHoliday) {
6165
- workdays++;
6166
- }
6167
- };
6168
-
6169
- for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
6170
- _loop(currentDate);
6171
- }
6172
-
6173
- return workdays;
6174
- };
6175
-
6148
+ */
6149
+ const calculateNetworkDays = function (start_date, end_date, holidays = []) {
6150
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
6151
+ throw new Error(
6152
+ "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
6153
+ );
6154
+ }
6155
+
6156
+ const startDateObj = new Date(start_date);
6157
+ const endDateObj = new Date(end_date);
6158
+
6159
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
6160
+ throw new Error(
6161
+ "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
6162
+ );
6163
+ }
6164
+
6165
+ if (startDateObj > endDateObj) {
6166
+ throw new Error('Start date should be earlier than or equal to end date.');
6167
+ }
6168
+
6169
+ let workdays = 0;
6170
+
6171
+ // Iterate through each day in the date range
6172
+ for (
6173
+ let currentDate = new Date(startDateObj);
6174
+ currentDate <= endDateObj;
6175
+ currentDate.setDate(currentDate.getDate() + 1)
6176
+ ) {
6177
+ // Check if the current day is a weekend (Saturday or Sunday)
6178
+ const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
6179
+
6180
+ // Check if the current day is a holiday
6181
+ const isHoliday = holidays.some((holiday) => {
6182
+ const holidayDate = new Date(holiday);
6183
+ return currentDate.toDateString() === holidayDate.toDateString();
6184
+ });
6185
+
6186
+ // If it's a workday (not a weekend or holiday), increment the workdays count
6187
+ if (!isWeekend && !isHoliday) {
6188
+ workdays++;
6189
+ }
6190
+ }
6191
+
6192
+ return workdays;
6193
+ };
6194
+
6176
6195
  /**
6177
6196
  * 日期加减天数
6178
6197
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
6179
6198
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
6180
6199
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
6181
- */
6182
- var dateAddDays = function dateAddDays(start_date, days) {
6183
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
6184
- 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.");
6185
- }
6186
-
6187
- var startDateObj = new Date(start_date);
6188
- if (isNaN(startDateObj.getTime())) {
6189
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6190
- }
6191
-
6192
- var resultDateObj = new Date(startDateObj);
6193
- resultDateObj.setDate(resultDateObj.getDate() + days);
6194
-
6195
- var resultYear = resultDateObj.getFullYear();
6196
- var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
6197
- var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
6198
-
6199
- return resultYear + '-' + resultMonth + '-' + resultDay;
6200
- };
6201
-
6200
+ */
6201
+ const dateAddDays = function (start_date, days) {
6202
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
6203
+ throw new Error(
6204
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
6205
+ );
6206
+ }
6207
+
6208
+ const startDateObj = new Date(start_date);
6209
+ if (isNaN(startDateObj.getTime())) {
6210
+ throw new Error(
6211
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
6212
+ );
6213
+ }
6214
+
6215
+ const resultDateObj = new Date(startDateObj);
6216
+ resultDateObj.setDate(resultDateObj.getDate() + days);
6217
+
6218
+ const resultYear = resultDateObj.getFullYear();
6219
+ const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
6220
+ const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
6221
+
6222
+ return `${resultYear}-${resultMonth}-${resultDay}`;
6223
+ };
6224
+
6202
6225
  /**
6203
6226
  * 计算两个日期之间的差值
6204
6227
  * @date 2023年12月14日
@@ -6206,180 +6229,182 @@ var dateAddDays = function dateAddDays(start_date, days) {
6206
6229
  * @param {String} end_date - 结束日期字符串
6207
6230
  * @param {String} unit - 单位:year/month/day
6208
6231
  * @returns {Number} 差值
6209
- */
6210
- var dateDiff = function dateDiff(start_date, end_date) {
6211
- var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
6212
-
6213
- // Assuming date strings are in "YYYY-MM-DD" format
6214
- var startDate = new Date(start_date);
6215
- var endDate = new Date(end_date);
6216
-
6217
- // If the date is invalid, return 0
6218
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
6219
- return 0;
6220
- }
6221
-
6222
- if (unit === 'year') {
6223
- return endDate.getFullYear() - startDate.getFullYear();
6224
- } else if (unit === 'month') {
6225
- return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
6226
- } else {
6227
- // Default to day
6228
- var timeDifference = endDate - startDate;
6229
- // Calculate days (86400000 milliseconds per day)
6230
- return Math.floor(timeDifference / 86400000);
6231
- }
6232
- };
6233
-
6232
+ */
6233
+ const dateDiff = function (start_date, end_date, unit = 'day') {
6234
+ // Assuming date strings are in "YYYY-MM-DD" format
6235
+ var startDate = new Date(start_date);
6236
+ var endDate = new Date(end_date);
6237
+
6238
+ // If the date is invalid, return 0
6239
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
6240
+ return 0;
6241
+ }
6242
+
6243
+ if (unit === 'year') {
6244
+ return endDate.getFullYear() - startDate.getFullYear();
6245
+ } else if (unit === 'month') {
6246
+ return (
6247
+ (endDate.getFullYear() - startDate.getFullYear()) * 12 +
6248
+ (endDate.getMonth() - startDate.getMonth())
6249
+ );
6250
+ } else {
6251
+ // Default to day
6252
+ var timeDifference = endDate - startDate;
6253
+ // Calculate days (86400000 milliseconds per day)
6254
+ return Math.floor(timeDifference / 86400000);
6255
+ }
6256
+ };
6257
+
6234
6258
  /**
6235
6259
  * 获取月份中的日期
6236
6260
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
6237
6261
  * @returns {number} 月份中的日期(1-31)
6238
- */
6239
- var dayOfMonth = function dayOfMonth(date) {
6240
- if (typeof date !== 'string') {
6241
- throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6242
- }
6243
-
6244
- var dateObj = new Date(date);
6245
- if (isNaN(dateObj.getTime())) {
6246
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6247
- }
6248
-
6249
- return dateObj.getDate();
6250
- };
6251
-
6262
+ */
6263
+ const dayOfMonth = function (date) {
6264
+ if (typeof date !== 'string') {
6265
+ throw new Error(
6266
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
6267
+ );
6268
+ }
6269
+
6270
+ const dateObj = new Date(date);
6271
+ if (isNaN(dateObj.getTime())) {
6272
+ throw new Error(
6273
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
6274
+ );
6275
+ }
6276
+
6277
+ return dateObj.getDate();
6278
+ };
6279
+
6252
6280
  /**
6253
6281
  * 获取当前日期
6254
6282
  * @date 2022年5月7日
6255
6283
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
6256
6284
  * @returns {string} 当前日期的格式化字符串
6257
- */
6258
- var getCurrentDate = function getCurrentDate() {
6259
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
6260
-
6261
- return formatDate(new Date(), format);
6262
- };
6263
-
6285
+ */
6286
+ const getCurrentDate = function (format = 'YYYY-MM-DD') {
6287
+ return formatDate(new Date(), format);
6288
+ };
6289
+
6264
6290
  /**
6265
6291
  * 获取当前日期时间
6266
6292
  * @date 2022年5月7日
6267
6293
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
6268
6294
  * @returns {string} 当前日期时间的格式化字符串
6269
- */
6270
- var getCurrentDateTime = function getCurrentDateTime() {
6271
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
6272
-
6273
- return formatDate(new Date(), format);
6274
- };
6275
-
6295
+ */
6296
+ const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
6297
+ return formatDate(new Date(), format);
6298
+ };
6299
+
6276
6300
  /**
6277
6301
  * 获取小时
6278
6302
  * @date 2022年5月7日
6279
6303
  * @param {Date|string} [date] - 日期对象或日期字符串
6280
6304
  * @returns {number} 小时数(0-23)
6281
- */
6282
- var getHour = function getHour(date) {
6283
- if (!date) {
6284
- return new Date().getHours();
6285
- }
6286
- if (typeof date === 'string') {
6287
- date = new Date(date);
6288
- }
6289
- return date.getHours();
6290
- };
6291
-
6305
+ */
6306
+ const getHour = function (date) {
6307
+ if (!date) {
6308
+ return new Date().getHours();
6309
+ }
6310
+ if (typeof date === 'string') {
6311
+ date = new Date(date);
6312
+ }
6313
+ return date.getHours();
6314
+ };
6315
+
6292
6316
  /**
6293
6317
  * 获取分钟
6294
6318
  * @date 2022年5月7日
6295
6319
  * @param {Date|string} [date] - 日期对象或日期字符串
6296
6320
  * @returns {number} 分钟数(0-59)
6297
- */
6298
- var getMinute = function getMinute(date) {
6299
- if (!date) {
6300
- return new Date().getMinutes();
6301
- }
6302
- if (typeof date === 'string') {
6303
- date = new Date(date);
6304
- }
6305
- return date.getMinutes();
6306
- };
6307
-
6321
+ */
6322
+ const getMinute = function (date) {
6323
+ if (!date) {
6324
+ return new Date().getMinutes();
6325
+ }
6326
+ if (typeof date === 'string') {
6327
+ date = new Date(date);
6328
+ }
6329
+ return date.getMinutes();
6330
+ };
6331
+
6308
6332
  /**
6309
6333
  * 获取月份
6310
6334
  * @date 2022年5月7日
6311
6335
  * @param {Date|string} [date] - 日期对象或日期字符串
6312
6336
  * @returns {number} 月份数(1-12)
6313
- */
6314
- var getMonth = function getMonth(date) {
6315
- if (!date) {
6316
- return new Date().getMonth() + 1;
6317
- }
6318
- if (typeof date === 'string') {
6319
- date = new Date(date);
6320
- }
6321
- return date.getMonth() + 1;
6322
- };
6323
-
6337
+ */
6338
+ const getMonth = function (date) {
6339
+ if (!date) {
6340
+ return new Date().getMonth() + 1;
6341
+ }
6342
+ if (typeof date === 'string') {
6343
+ date = new Date(date);
6344
+ }
6345
+ return date.getMonth() + 1;
6346
+ };
6347
+
6324
6348
  /**
6325
6349
  * 获取秒
6326
6350
  * @date 2022年5月7日
6327
6351
  * @param {Date|string} [date] - 日期对象或日期字符串
6328
6352
  * @returns {number} 秒数(0-59)
6329
- */
6330
- var getSecond = function getSecond(date) {
6331
- if (!date) {
6332
- return new Date().getSeconds();
6333
- }
6334
- if (typeof date === 'string') {
6335
- date = new Date(date);
6336
- }
6337
- return date.getSeconds();
6338
- };
6339
-
6353
+ */
6354
+ const getSecond = function (date) {
6355
+ if (!date) {
6356
+ return new Date().getSeconds();
6357
+ }
6358
+ if (typeof date === 'string') {
6359
+ date = new Date(date);
6360
+ }
6361
+ return date.getSeconds();
6362
+ };
6363
+
6340
6364
  /**
6341
6365
  * 获取星期几
6342
6366
  * @date 2022年5月7日
6343
6367
  * @param {Date|string} [date] - 日期对象或日期字符串
6344
6368
  * @returns {number} 星期几(0-6,0表示星期日)
6345
- */
6346
- var getWeekday = function getWeekday(date) {
6347
- if (!date) {
6348
- return new Date().getDay();
6349
- }
6350
- if (typeof date === 'string') {
6351
- date = new Date(date);
6352
- }
6353
- return date.getDay();
6354
- };
6355
-
6369
+ */
6370
+ const getWeekday = function (date) {
6371
+ if (!date) {
6372
+ return new Date().getDay();
6373
+ }
6374
+ if (typeof date === 'string') {
6375
+ date = new Date(date);
6376
+ }
6377
+ return date.getDay();
6378
+ };
6379
+
6380
+
6356
6381
  /**
6357
6382
  * @desc 获取上午/下午/晚上
6358
6383
  * @author huangbo
6359
6384
  * @date 2022年5月7日
6360
6385
  * @param {String} [time] - 时间
6361
- **/
6362
- var timeCycle = function timeCycle(time) {
6363
- var hour = 0;
6364
- if (!time) {
6365
- hour = new Date().getHours();
6366
- } else if (typeof time === 'string') {
6367
- // 从时间字符串中提取小时
6368
- var match = time.match(/^(\d{1,2})/);
6369
- if (match) {
6370
- hour = parseInt(match[1], 10);
6371
- }
6372
- } else if (typeof time === 'number') {
6373
- hour = time;
6374
- }
6375
- // 判断时间段
6376
- if (hour >= 5 && hour < 12) {
6377
- return '上午';
6378
- } else if (hour >= 12 && hour < 18) {
6379
- return '下午';
6380
- } else {
6381
- return '晚上';
6382
- }
6386
+ **/
6387
+ const timeCycle = function (time) {
6388
+ let hour = 0;
6389
+ if (!time) {
6390
+ hour = new Date().getHours();
6391
+ } else if (typeof time === 'string') {
6392
+ // 从时间字符串中提取小时
6393
+ const match = time.match(/^(\d{1,2})/);
6394
+ if (match) {
6395
+ hour = parseInt(match[1], 10);
6396
+ }
6397
+ } else if (typeof time === 'number') {
6398
+ hour = time;
6399
+ }
6400
+ // 判断时间段
6401
+ if (hour >= 5 && hour < 12) {
6402
+ return '上午';
6403
+ } else if (hour >= 12 && hour < 18) {
6404
+ return '下午';
6405
+ } else {
6406
+ return '晚上';
6407
+ }
6383
6408
  };
6384
6409
 
6385
6410
  /***/ }),