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
@@ -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 = 242);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 244);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -3521,7 +3521,7 @@ module.exports = require("vue");
3521
3521
 
3522
3522
  /***/ }),
3523
3523
 
3524
- /***/ 242:
3524
+ /***/ 244:
3525
3525
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3526
3526
 
3527
3527
  "use strict";
@@ -4509,736 +4509,759 @@ function insertAfter(newEl, targetEl) {
4509
4509
  /* unused harmony export getSecond */
4510
4510
  /* unused harmony export getWeekday */
4511
4511
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
4512
-
4513
-
4512
+ /* Modified from https://github.com/taylorhakes/fecha
4513
+ *
4514
+ * The MIT License (MIT)
4515
+ *
4516
+ * Copyright (c) 2015 Taylor Hakes
4517
+ *
4518
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
4519
+ * of this software and associated documentation files (the "Software"), to deal
4520
+ * in the Software without restriction, including without limitation the rights
4521
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4522
+ * copies of the Software, and to permit persons to whom the Software is
4523
+ * furnished to do so, subject to the following conditions:
4524
+ *
4525
+ * The above copyright notice and this permission notice shall be included in all
4526
+ * copies or substantial portions of the Software.
4527
+ *
4528
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4529
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4530
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4531
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4532
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4533
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4534
+ * SOFTWARE.
4535
+ */
4536
+
4537
+ /*eslint-disable*/
4538
+ // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
4539
+
4540
+
4514
4541
  /**
4515
4542
  * Parse or format dates
4516
4543
  * @class fecha
4517
- */
4518
- var fecha = {};
4519
- var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
4520
- var twoDigits = '\\d\\d?';
4521
- var threeDigits = '\\d{3}';
4522
- var fourDigits = '\\d{4}';
4523
- var word = '[^\\s]+';
4524
- var literal = /\[([^]*?)\]/gm;
4525
- var noop = function noop() {};
4526
-
4527
- function regexEscape(str) {
4528
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
4529
- }
4530
-
4531
- function shorten(arr, sLen) {
4532
- var newArr = [];
4533
- for (var i = 0, len = arr.length; i < len; i++) {
4534
- newArr.push(arr[i].substr(0, sLen));
4535
- }
4536
- return newArr;
4537
- }
4538
-
4539
- function monthUpdate() {
4540
- return function (d, v) {
4541
- var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
4542
- if (~index) {
4543
- d.month = index;
4544
- }
4545
- };
4546
- }
4547
-
4548
- function pad(val, len) {
4549
- val = String(val);
4550
- len = len || 2;
4551
- while (val.length < len) {
4552
- val = '0' + val;
4553
- }
4554
- return val;
4555
- }
4556
-
4557
- // 直接使用中文日期名称常量
4558
- var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
4559
- var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
4560
- var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
4561
- var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
4562
- var amPm = ['上午', '下午'];
4563
- var DoFn = function DoFn(D) {
4564
- return D + '日';
4565
- };
4566
-
4567
- var formatFlags = {
4568
- D: function D(dateObj) {
4569
- return dateObj.getDay();
4570
- },
4571
- DD: function DD(dateObj) {
4572
- return pad(dateObj.getDay());
4573
- },
4574
- Do: function Do(dateObj) {
4575
- return DoFn(dateObj.getDate());
4576
- },
4577
- d: function d(dateObj) {
4578
- return dateObj.getDate();
4579
- },
4580
- dd: function dd(dateObj) {
4581
- return pad(dateObj.getDate());
4582
- },
4583
- ddd: function ddd(dateObj) {
4584
- return dayNamesShort[dateObj.getDay()];
4585
- },
4586
- dddd: function dddd(dateObj) {
4587
- return dayNames[dateObj.getDay()];
4588
- },
4589
- M: function M(dateObj) {
4590
- return dateObj.getMonth() + 1;
4591
- },
4592
- MM: function MM(dateObj) {
4593
- return pad(dateObj.getMonth() + 1);
4594
- },
4595
- MMM: function MMM(dateObj) {
4596
- return monthNamesShort[dateObj.getMonth()];
4597
- },
4598
- MMMM: function MMMM(dateObj) {
4599
- return monthNames[dateObj.getMonth()];
4600
- },
4601
- yy: function yy(dateObj) {
4602
- return pad(String(dateObj.getFullYear()), 4).substr(2);
4603
- },
4604
- yyyy: function yyyy(dateObj) {
4605
- return pad(dateObj.getFullYear(), 4);
4606
- },
4607
- h: function h(dateObj) {
4608
- return dateObj.getHours() % 12 || 12;
4609
- },
4610
- hh: function hh(dateObj) {
4611
- return pad(dateObj.getHours() % 12 || 12);
4612
- },
4613
- H: function H(dateObj) {
4614
- return dateObj.getHours();
4615
- },
4616
- HH: function HH(dateObj) {
4617
- return pad(dateObj.getHours());
4618
- },
4619
- m: function m(dateObj) {
4620
- return dateObj.getMinutes();
4621
- },
4622
- mm: function mm(dateObj) {
4623
- return pad(dateObj.getMinutes());
4624
- },
4625
- s: function s(dateObj) {
4626
- return dateObj.getSeconds();
4627
- },
4628
- ss: function ss(dateObj) {
4629
- return pad(dateObj.getSeconds());
4630
- },
4631
- S: function S(dateObj) {
4632
- return Math.round(dateObj.getMilliseconds() / 100);
4633
- },
4634
- SS: function SS(dateObj) {
4635
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
4636
- },
4637
- SSS: function SSS(dateObj) {
4638
- return pad(dateObj.getMilliseconds(), 3);
4639
- },
4640
- a: function a(dateObj) {
4641
- return dateObj.getHours() < 12 ? '上午' : '下午';
4642
- },
4643
- A: function A(dateObj) {
4644
- return dateObj.getHours() < 12 ? '上午' : '下午';
4645
- },
4646
- ZZ: function ZZ(dateObj) {
4647
- var o = dateObj.getTimezoneOffset();
4648
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
4649
- }
4650
- };
4651
-
4652
- var parseFlags = {
4653
- d: [twoDigits, function (d, v) {
4654
- d.day = v;
4655
- }],
4656
- Do: [twoDigits + word, function (d, v) {
4657
- d.day = parseInt(v, 10);
4658
- }],
4659
- M: [twoDigits, function (d, v) {
4660
- d.month = v - 1;
4661
- }],
4662
- yy: [twoDigits, function (d, v) {
4663
- var da = new Date(),
4664
- cent = +('' + da.getFullYear()).substr(0, 2);
4665
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
4666
- }],
4667
- h: [twoDigits, function (d, v) {
4668
- d.hour = v;
4669
- }],
4670
- m: [twoDigits, function (d, v) {
4671
- d.minute = v;
4672
- }],
4673
- s: [twoDigits, function (d, v) {
4674
- d.second = v;
4675
- }],
4676
- yyyy: [fourDigits, function (d, v) {
4677
- d.year = v;
4678
- }],
4679
- S: ['\\d', function (d, v) {
4680
- d.millisecond = v * 100;
4681
- }],
4682
- SS: ['\\d{2}', function (d, v) {
4683
- d.millisecond = v * 10;
4684
- }],
4685
- SSS: [threeDigits, function (d, v) {
4686
- d.millisecond = v;
4687
- }],
4688
- D: [twoDigits, noop],
4689
- ddd: [word, noop],
4690
- MMM: [word, monthUpdate('monthNamesShort')],
4691
- MMMM: [word, monthUpdate('monthNames')],
4692
- a: [word, function (d, v) {
4693
- var val = v.toLowerCase();
4694
- if (val === '上午') {
4695
- d.isPm = false;
4696
- } else if (val === '下午') {
4697
- d.isPm = true;
4698
- }
4699
- }],
4700
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
4701
- var parts = (v + '').match(/([+-]|\d\d)/gi),
4702
- minutes = void 0;
4703
-
4704
- if (parts) {
4705
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
4706
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
4707
- }
4708
- }]
4709
- };
4710
- parseFlags.dd = parseFlags.d;
4711
- parseFlags.dddd = parseFlags.ddd;
4712
- parseFlags.DD = parseFlags.D;
4713
- parseFlags.mm = parseFlags.m;
4714
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
4715
- parseFlags.MM = parseFlags.M;
4716
- parseFlags.ss = parseFlags.s;
4717
- parseFlags.A = parseFlags.a;
4718
-
4719
- // Some common format strings
4720
- fecha.masks = {
4721
- default: 'ddd MMM dd yyyy HH:mm:ss',
4722
- shortDate: 'M/D/yy',
4723
- mediumDate: 'MMM d, yyyy',
4724
- longDate: 'MMMM d, yyyy',
4725
- fullDate: 'dddd, MMMM d, yyyy',
4726
- shortTime: 'HH:mm',
4727
- mediumTime: 'HH:mm:ss',
4728
- longTime: 'HH:mm:ss.SSS'
4729
- };
4730
-
4544
+ */
4545
+ const fecha = {};
4546
+ const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
4547
+ const twoDigits = '\\d\\d?';
4548
+ const threeDigits = '\\d{3}';
4549
+ const fourDigits = '\\d{4}';
4550
+ const word = '[^\\s]+';
4551
+ const literal = /\[([^]*?)\]/gm;
4552
+ const noop = function () {};
4553
+
4554
+ function regexEscape(str) {
4555
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
4556
+ }
4557
+
4558
+ function shorten(arr, sLen) {
4559
+ const newArr = [];
4560
+ for (let i = 0, len = arr.length; i < len; i++) {
4561
+ newArr.push(arr[i].substr(0, sLen));
4562
+ }
4563
+ return newArr;
4564
+ }
4565
+
4566
+ function monthUpdate() {
4567
+ return function (d, v) {
4568
+ const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
4569
+ if (~index) {
4570
+ d.month = index;
4571
+ }
4572
+ };
4573
+ }
4574
+
4575
+ function pad(val, len) {
4576
+ val = String(val);
4577
+ len = len || 2;
4578
+ while (val.length < len) {
4579
+ val = '0' + val;
4580
+ }
4581
+ return val;
4582
+ }
4583
+
4584
+ // 直接使用中文日期名称常量
4585
+ const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
4586
+ const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
4587
+ const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
4588
+ const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
4589
+ const amPm = ['上午', '下午'];
4590
+ const DoFn = function DoFn(D) {
4591
+ return D + '日';
4592
+ };
4593
+
4594
+ const formatFlags = {
4595
+ D: function(dateObj) {
4596
+ return dateObj.getDay();
4597
+ },
4598
+ DD: function(dateObj) {
4599
+ return pad(dateObj.getDay());
4600
+ },
4601
+ Do: function(dateObj) {
4602
+ return DoFn(dateObj.getDate());
4603
+ },
4604
+ d: function(dateObj) {
4605
+ return dateObj.getDate();
4606
+ },
4607
+ dd: function(dateObj) {
4608
+ return pad(dateObj.getDate());
4609
+ },
4610
+ ddd: function(dateObj) {
4611
+ return dayNamesShort[dateObj.getDay()];
4612
+ },
4613
+ dddd: function(dateObj) {
4614
+ return dayNames[dateObj.getDay()];
4615
+ },
4616
+ M: function(dateObj) {
4617
+ return dateObj.getMonth() + 1;
4618
+ },
4619
+ MM: function(dateObj) {
4620
+ return pad(dateObj.getMonth() + 1);
4621
+ },
4622
+ MMM: function(dateObj) {
4623
+ return monthNamesShort[dateObj.getMonth()];
4624
+ },
4625
+ MMMM: function(dateObj) {
4626
+ return monthNames[dateObj.getMonth()];
4627
+ },
4628
+ yy: function(dateObj) {
4629
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
4630
+ },
4631
+ yyyy: function(dateObj) {
4632
+ return pad(dateObj.getFullYear(), 4);
4633
+ },
4634
+ h: function(dateObj) {
4635
+ return dateObj.getHours() % 12 || 12;
4636
+ },
4637
+ hh: function(dateObj) {
4638
+ return pad(dateObj.getHours() % 12 || 12);
4639
+ },
4640
+ H: function(dateObj) {
4641
+ return dateObj.getHours();
4642
+ },
4643
+ HH: function(dateObj) {
4644
+ return pad(dateObj.getHours());
4645
+ },
4646
+ m: function(dateObj) {
4647
+ return dateObj.getMinutes();
4648
+ },
4649
+ mm: function(dateObj) {
4650
+ return pad(dateObj.getMinutes());
4651
+ },
4652
+ s: function(dateObj) {
4653
+ return dateObj.getSeconds();
4654
+ },
4655
+ ss: function(dateObj) {
4656
+ return pad(dateObj.getSeconds());
4657
+ },
4658
+ S: function(dateObj) {
4659
+ return Math.round(dateObj.getMilliseconds() / 100);
4660
+ },
4661
+ SS: function(dateObj) {
4662
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
4663
+ },
4664
+ SSS: function(dateObj) {
4665
+ return pad(dateObj.getMilliseconds(), 3);
4666
+ },
4667
+ a: function(dateObj) {
4668
+ return dateObj.getHours() < 12 ? '上午' : '下午';
4669
+ },
4670
+ A: function(dateObj) {
4671
+ return dateObj.getHours() < 12 ? '上午' : '下午';
4672
+ },
4673
+ ZZ: function(dateObj) {
4674
+ const o = dateObj.getTimezoneOffset();
4675
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
4676
+ }
4677
+ };
4678
+
4679
+ const parseFlags = {
4680
+ d: [twoDigits, function (d, v) {
4681
+ d.day = v;
4682
+ }],
4683
+ Do: [twoDigits + word, function (d, v) {
4684
+ d.day = parseInt(v, 10);
4685
+ }],
4686
+ M: [twoDigits, function (d, v) {
4687
+ d.month = v - 1;
4688
+ }],
4689
+ yy: [twoDigits, function (d, v) {
4690
+ const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
4691
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
4692
+ }],
4693
+ h: [twoDigits, function (d, v) {
4694
+ d.hour = v;
4695
+ }],
4696
+ m: [twoDigits, function (d, v) {
4697
+ d.minute = v;
4698
+ }],
4699
+ s: [twoDigits, function (d, v) {
4700
+ d.second = v;
4701
+ }],
4702
+ yyyy: [fourDigits, function (d, v) {
4703
+ d.year = v;
4704
+ }],
4705
+ S: ['\\d', function (d, v) {
4706
+ d.millisecond = v * 100;
4707
+ }],
4708
+ SS: ['\\d{2}', function (d, v) {
4709
+ d.millisecond = v * 10;
4710
+ }],
4711
+ SSS: [threeDigits, function (d, v) {
4712
+ d.millisecond = v;
4713
+ }],
4714
+ D: [twoDigits, noop],
4715
+ ddd: [word, noop],
4716
+ MMM: [word, monthUpdate('monthNamesShort')],
4717
+ MMMM: [word, monthUpdate('monthNames')],
4718
+ a: [word, function (d, v) {
4719
+ const val = v.toLowerCase();
4720
+ if (val === '上午') {
4721
+ d.isPm = false;
4722
+ } else if (val === '下午') {
4723
+ d.isPm = true;
4724
+ }
4725
+ }],
4726
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
4727
+ let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
4728
+
4729
+ if (parts) {
4730
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
4731
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
4732
+ }
4733
+ }]
4734
+ };
4735
+ parseFlags.dd = parseFlags.d;
4736
+ parseFlags.dddd = parseFlags.ddd;
4737
+ parseFlags.DD = parseFlags.D;
4738
+ parseFlags.mm = parseFlags.m;
4739
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
4740
+ parseFlags.MM = parseFlags.M;
4741
+ parseFlags.ss = parseFlags.s;
4742
+ parseFlags.A = parseFlags.a;
4743
+
4744
+
4745
+ // Some common format strings
4746
+ fecha.masks = {
4747
+ default: 'ddd MMM dd yyyy HH:mm:ss',
4748
+ shortDate: 'M/D/yy',
4749
+ mediumDate: 'MMM d, yyyy',
4750
+ longDate: 'MMMM d, yyyy',
4751
+ fullDate: 'dddd, MMMM d, yyyy',
4752
+ shortTime: 'HH:mm',
4753
+ mediumTime: 'HH:mm:ss',
4754
+ longTime: 'HH:mm:ss.SSS'
4755
+ };
4756
+
4731
4757
  /***
4732
4758
  * Format a date
4733
4759
  * @method format
4734
4760
  * @param {Date|number} dateObj
4735
4761
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
4736
- */
4737
- fecha.format = function (dateObj, mask) {
4738
- if (typeof dateObj === 'number') {
4739
- dateObj = new Date(dateObj);
4740
- }
4741
-
4742
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
4743
- throw new Error('Invalid Date in fecha.format');
4744
- }
4745
-
4746
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
4747
-
4748
- var literals = [];
4749
-
4750
- // Make literals inactive by replacing them with ??
4751
- mask = mask.replace(literal, function ($0, $1) {
4752
- literals.push($1);
4753
- return '@@@';
4754
- });
4755
- // Apply formatting rules
4756
- mask = mask.replace(token, function ($0) {
4757
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
4758
- });
4759
- // Inline literal values back into the formatted value
4760
- return mask.replace(/@@@/g, function () {
4761
- return literals.shift();
4762
- });
4763
- };
4764
-
4762
+ */
4763
+ fecha.format = function (dateObj, mask) {
4764
+ if (typeof dateObj === 'number') {
4765
+ dateObj = new Date(dateObj);
4766
+ }
4767
+
4768
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
4769
+ throw new Error('Invalid Date in fecha.format');
4770
+ }
4771
+
4772
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
4773
+
4774
+ const literals = [];
4775
+
4776
+ // Make literals inactive by replacing them with ??
4777
+ mask = mask.replace(literal, function($0, $1) {
4778
+ literals.push($1);
4779
+ return '@@@';
4780
+ });
4781
+ // Apply formatting rules
4782
+ mask = mask.replace(token, function ($0) {
4783
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
4784
+ });
4785
+ // Inline literal values back into the formatted value
4786
+ return mask.replace(/@@@/g, function() {
4787
+ return literals.shift();
4788
+ });
4789
+ };
4790
+
4765
4791
  /**
4766
4792
  * Parse a date string into an object, changes - into /
4767
4793
  * @method parse
4768
4794
  * @param {string} dateStr Date string
4769
4795
  * @param {string} format Date parse format
4770
4796
  * @returns {Date|boolean}
4771
- */
4772
- fecha.parse = function (dateStr, format) {
4773
- if (typeof format !== 'string') {
4774
- throw new Error('Invalid format in fecha.parse');
4775
- }
4776
-
4777
- format = fecha.masks[format] || format;
4778
-
4779
- // Avoid regular expression denial of service, fail early for really long strings
4780
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
4781
- if (dateStr.length > 1000) {
4782
- return null;
4783
- }
4784
-
4785
- var dateInfo = {};
4786
- var parseInfo = [];
4787
- var literals = [];
4788
- format = format.replace(literal, function ($0, $1) {
4789
- literals.push($1);
4790
- return '@@@';
4791
- });
4792
- var newFormat = regexEscape(format).replace(token, function ($0) {
4793
- if (parseFlags[$0]) {
4794
- var info = parseFlags[$0];
4795
- parseInfo.push(info[1]);
4796
- return '(' + info[0] + ')';
4797
- }
4798
-
4799
- return $0;
4800
- });
4801
- newFormat = newFormat.replace(/@@@/g, function () {
4802
- return literals.shift();
4803
- });
4804
- var matches = dateStr.match(new RegExp(newFormat, 'i'));
4805
- if (!matches) {
4806
- return null;
4807
- }
4808
-
4809
- for (var i = 1; i < matches.length; i++) {
4810
- parseInfo[i - 1](dateInfo, matches[i]);
4811
- }
4812
-
4813
- var today = new Date();
4814
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
4815
- dateInfo.hour = +dateInfo.hour + 12;
4816
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
4817
- dateInfo.hour = 0;
4818
- }
4819
-
4820
- var date = void 0;
4821
- if (dateInfo.timezoneOffset != null) {
4822
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
4823
- 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));
4824
- } else {
4825
- 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);
4826
- }
4827
- return date;
4828
- };
4829
-
4830
- // 导出fecha对象
4831
-
4832
-
4833
- // 以下是从date-util.js合并的函数
4834
- var newArray = function newArray(start, end) {
4835
- var result = [];
4836
- for (var i = start; i <= end; i++) {
4837
- result.push(i);
4838
- }
4839
- return result;
4840
- };
4841
-
4842
- var getSettings = function getSettings() {
4843
- return {
4844
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
4845
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
4846
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
4847
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
4848
- amPm: ['上午', '下午']
4849
- };
4850
- };
4851
-
4852
- var toDate = function toDate(date) {
4853
- return isDate(date) ? new Date(date) : null;
4854
- };
4855
-
4856
- var isDate = function isDate(date) {
4857
- if (date === null || date === undefined) return false;
4858
- if (isNaN(new Date(date).getTime())) return false;
4859
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
4860
- return true;
4861
- };
4862
-
4863
- var isDateObject = function isDateObject(val) {
4864
- return val instanceof Date;
4865
- };
4866
-
4867
- var formatDate = function formatDate(date) {
4868
- var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
4869
-
4870
- // 处理多种输入类型
4871
- if (!date) return '';
4872
-
4873
- // 如果是时间戳,转成日期对象
4874
- if (typeof date === 'number') {
4875
- date = new Date(date);
4876
- }
4877
- // 如果是字符串,转成日期对象
4878
- if (typeof date === 'string') {
4879
- date = new Date(date);
4880
- }
4881
-
4882
- // 调用toDate进一步验证和转换
4883
- date = toDate(date);
4884
- if (!date) return '';
4885
-
4886
- // 兼容大写和小写的格式标记
4887
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
4888
- var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
4889
-
4890
- // 使用fecha库进行格式化,支持中文配置
4891
- var str = fecha.format(date, lowercaseFormat, getSettings());
4892
- return str;
4893
- };
4894
-
4895
- var parseDate = function parseDate(string, format) {
4896
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
4897
- };
4898
-
4899
- var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
4900
- if (month === 3 || month === 5 || month === 8 || month === 10) {
4901
- return 30;
4902
- }
4903
-
4904
- if (month === 1) {
4905
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
4906
- return 29;
4907
- } else {
4908
- return 28;
4909
- }
4910
- }
4911
-
4912
- return 31;
4913
- };
4914
-
4915
- var getDayCountOfYear = function getDayCountOfYear(year) {
4916
- var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
4917
- return isLeapYear ? 366 : 365;
4918
- };
4919
-
4920
- var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
4921
- var temp = new Date(date.getTime());
4922
- temp.setDate(1);
4923
- return temp.getDay();
4924
- };
4925
-
4926
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
4927
- // {prev, next} Date should work for Daylight Saving Time
4928
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
4929
- var prevDate = function prevDate(date) {
4930
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4931
-
4932
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
4933
- };
4934
-
4935
- var nextDate = function nextDate(date) {
4936
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4937
-
4938
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
4939
- };
4940
-
4941
- var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
4942
- var result = new Date(year, month, 1);
4943
- var day = result.getDay();
4944
-
4945
- if (day === 0) {
4946
- return prevDate(result, 7);
4947
- } else {
4948
- return prevDate(result, day);
4949
- }
4950
- };
4951
-
4952
- var getWeekNumber = function getWeekNumber(date) {
4953
- // 支持多种输入类型
4954
- if (!date || !isDate(date)) {
4955
- date = new Date();
4956
- }
4957
- if (typeof date === 'string') {
4958
- date = new Date(date);
4959
- }
4960
-
4961
- // 验证日期有效性
4962
- if (!isDate(date)) return null;
4963
-
4964
- var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
4965
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
4966
- // 将星期日的星期数设为7
4967
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
4968
- // 获取当年的第一天
4969
- var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
4970
- // 计算到最近的星期四的完整周数
4971
- var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
4972
- // 返回周数
4973
- return weekNo;
4974
- };
4975
-
4976
- var getRangeHours = function getRangeHours(ranges) {
4977
- var hours = [];
4978
- var disabledHours = [];
4979
-
4980
- (ranges || []).forEach(function (range) {
4981
- var value = range.map(function (date) {
4982
- return date.getHours();
4983
- });
4984
-
4985
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
4986
- });
4987
-
4988
- if (disabledHours.length) {
4989
- for (var i = 0; i < 24; i++) {
4990
- hours[i] = disabledHours.indexOf(i) === -1;
4991
- }
4992
- } else {
4993
- for (var _i = 0; _i < 24; _i++) {
4994
- hours[_i] = false;
4995
- }
4996
- }
4997
-
4998
- return hours;
4999
- };
5000
-
5001
- var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
5002
- if (amount <= 0) return [];
5003
- var temp = new Date(date.getTime());
5004
- temp.setDate(0);
5005
- var lastDay = temp.getDate();
5006
- return range(amount).map(function (_, index) {
5007
- return lastDay - (amount - index - 1);
5008
- });
5009
- };
5010
-
5011
- var getMonthDays = function getMonthDays(date) {
5012
- var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
5013
- var days = temp.getDate();
5014
- return range(days).map(function (_, index) {
5015
- return index + 1;
5016
- });
5017
- };
5018
-
5019
- function setRangeData(arr, start, end, value) {
5020
- for (var i = start; i < end; i++) {
5021
- arr[i] = value;
5022
- }
5023
- }
5024
-
5025
- var getRangeMinutes = function getRangeMinutes(ranges, hour) {
5026
- var minutes = new Array(60);
5027
-
5028
- if (ranges.length > 0) {
5029
- ranges.forEach(function (range) {
5030
- var start = range[0];
5031
- var end = range[1];
5032
- var startHour = start.getHours();
5033
- var startMinute = start.getMinutes();
5034
- var endHour = end.getHours();
5035
- var endMinute = end.getMinutes();
5036
- if (startHour === hour && endHour !== hour) {
5037
- setRangeData(minutes, startMinute, 60, true);
5038
- } else if (startHour === hour && endHour === hour) {
5039
- setRangeData(minutes, startMinute, endMinute + 1, true);
5040
- } else if (startHour !== hour && endHour === hour) {
5041
- setRangeData(minutes, 0, endMinute + 1, true);
5042
- } else if (startHour < hour && endHour > hour) {
5043
- setRangeData(minutes, 0, 60, true);
5044
- }
5045
- });
5046
- } else {
5047
- setRangeData(minutes, 0, 60, true);
5048
- }
5049
- return minutes;
5050
- };
5051
-
5052
- var range = function range(n) {
5053
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
5054
- return Array.apply(null, { length: n }).map(function (_, n) {
5055
- return n;
5056
- });
5057
- };
5058
-
5059
- var modifyDate = function modifyDate(date, y, m, d) {
5060
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
5061
- };
5062
-
5063
- var modifyTime = function modifyTime(date, h, m, s) {
5064
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
5065
- };
5066
-
5067
- var modifyWithTimeString = function modifyWithTimeString(date, time) {
5068
- if (date == null || !time) {
5069
- return date;
5070
- }
5071
- time = parseDate(time, 'HH:mm:ss');
5072
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
5073
- };
5074
-
5075
- var clearTime = function clearTime(date) {
5076
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
5077
- };
5078
-
5079
- var clearMilliseconds = function clearMilliseconds(date) {
5080
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
5081
- };
5082
-
5083
- var limitTimeRange = function limitTimeRange(date, ranges) {
5084
- var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
5085
-
5086
- // TODO: refactory a more elegant solution
5087
- if (ranges.length === 0) return date;
5088
- var normalizeDate = function normalizeDate(date) {
5089
- return fecha.parse(fecha.format(date, format), format);
5090
- };
5091
- var ndate = normalizeDate(date);
5092
- var nranges = ranges.map(function (range) {
5093
- return range.map(normalizeDate);
5094
- });
5095
- if (nranges.some(function (nrange) {
5096
- return ndate >= nrange[0] && ndate <= nrange[1];
5097
- })) return date;
5098
-
5099
- var minDate = nranges[0][0];
5100
- var maxDate = nranges[0][0];
5101
-
5102
- nranges.forEach(function (nrange) {
5103
- minDate = new Date(Math.min(nrange[0], minDate));
5104
- maxDate = new Date(Math.max(nrange[1], minDate));
5105
- });
5106
-
5107
- var ret = ndate < minDate ? minDate : maxDate;
5108
- // preserve Year/Month/Date
5109
- return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
5110
- };
5111
-
5112
- var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
5113
- var limitedDate = limitTimeRange(date, selectableRange, format);
5114
- return limitedDate.getTime() === date.getTime();
5115
- };
5116
-
5117
- var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
5118
- // clamp date to the number of days in `year`, `month`
5119
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
5120
- var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
5121
- return modifyDate(date, year, month, monthDate);
5122
- };
5123
-
5124
- var prevMonth = function prevMonth(date) {
5125
- var year = date.getFullYear();
5126
- var month = date.getMonth();
5127
- return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
5128
- };
5129
-
5130
- var nextMonth = function nextMonth(date) {
5131
- var year = date.getFullYear();
5132
- var month = date.getMonth();
5133
- return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
5134
- };
5135
-
5136
- var prevYear = function prevYear(date) {
5137
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5138
-
5139
- var year = date.getFullYear();
5140
- var month = date.getMonth();
5141
- return changeYearMonthAndClampDate(date, year - amount, month);
5142
- };
5143
-
5144
- var nextYear = function nextYear(date) {
5145
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5146
-
5147
- var year = date.getFullYear();
5148
- var month = date.getMonth();
5149
- return changeYearMonthAndClampDate(date, year + amount, month);
5150
- };
5151
-
5152
- var extractDateFormat = function extractDateFormat(format) {
5153
- return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
5154
- };
5155
-
5156
- var extractTimeFormat = function extractTimeFormat(format) {
5157
- return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
5158
- };
5159
-
5160
- var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
5161
- return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
5162
- };
5163
-
4797
+ */
4798
+ fecha.parse = function (dateStr, format) {
4799
+ if (typeof format !== 'string') {
4800
+ throw new Error('Invalid format in fecha.parse');
4801
+ }
4802
+
4803
+ format = fecha.masks[format] || format;
4804
+
4805
+ // Avoid regular expression denial of service, fail early for really long strings
4806
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
4807
+ if (dateStr.length > 1000) {
4808
+ return null;
4809
+ }
4810
+
4811
+ const dateInfo = {};
4812
+ const parseInfo = [];
4813
+ const literals = [];
4814
+ format = format.replace(literal, function($0, $1) {
4815
+ literals.push($1);
4816
+ return '@@@';
4817
+ });
4818
+ let newFormat = regexEscape(format).replace(token, function ($0) {
4819
+ if (parseFlags[$0]) {
4820
+ const info = parseFlags[$0];
4821
+ parseInfo.push(info[1]);
4822
+ return '(' + info[0] + ')';
4823
+ }
4824
+
4825
+ return $0;
4826
+ });
4827
+ newFormat = newFormat.replace(/@@@/g, function() {
4828
+ return literals.shift();
4829
+ });
4830
+ const matches = dateStr.match(new RegExp(newFormat, 'i'));
4831
+ if (!matches) {
4832
+ return null;
4833
+ }
4834
+
4835
+ for (let i = 1; i < matches.length; i++) {
4836
+ parseInfo[i - 1](dateInfo, matches[i]);
4837
+ }
4838
+
4839
+ const today = new Date();
4840
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
4841
+ dateInfo.hour = +dateInfo.hour + 12;
4842
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
4843
+ dateInfo.hour = 0;
4844
+ }
4845
+
4846
+ let date;
4847
+ if (dateInfo.timezoneOffset != null) {
4848
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
4849
+ date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
4850
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
4851
+ } else {
4852
+ date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
4853
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
4854
+ }
4855
+ return date;
4856
+ };
4857
+
4858
+ // 导出fecha对象
4859
+
4860
+
4861
+ // 以下是从date-util.js合并的函数
4862
+ const newArray = function(start, end) {
4863
+ let result = [];
4864
+ for (let i = start; i <= end; i++) {
4865
+ result.push(i);
4866
+ }
4867
+ return result;
4868
+ };
4869
+
4870
+ const getSettings = () => {
4871
+ return {
4872
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
4873
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
4874
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
4875
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
4876
+ amPm: ['上午', '下午']
4877
+ };
4878
+ };
4879
+
4880
+ const toDate = function(date) {
4881
+ return isDate(date) ? new Date(date) : null;
4882
+ };
4883
+
4884
+ const isDate = function(date) {
4885
+ if (date === null || date === undefined) return false;
4886
+ if (isNaN(new Date(date).getTime())) return false;
4887
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
4888
+ return true;
4889
+ };
4890
+
4891
+ const isDateObject = function(val) {
4892
+ return val instanceof Date;
4893
+ };
4894
+
4895
+ const formatDate = function (date, format = 'yyyy-MM-dd') {
4896
+ // 处理多种输入类型
4897
+ if (!date) return '';
4898
+
4899
+ // 如果是时间戳,转成日期对象
4900
+ if (typeof date === 'number') {
4901
+ date = new Date(date);
4902
+ }
4903
+ // 如果是字符串,转成日期对象
4904
+ if (typeof date === 'string') {
4905
+ date = new Date(date);
4906
+ }
4907
+
4908
+ // 调用toDate进一步验证和转换
4909
+ date = toDate(date);
4910
+ if (!date) return '';
4911
+
4912
+ // 兼容大写和小写的格式标记
4913
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
4914
+ const lowercaseFormat = format
4915
+ .replace(/YYYY/g, 'yyyy')
4916
+ .replace(/D/g, 'd')
4917
+
4918
+ // 使用fecha库进行格式化,支持中文配置
4919
+ const str = fecha.format(date, lowercaseFormat, getSettings());
4920
+ return str;
4921
+ };
4922
+
4923
+ const parseDate = function(string, format) {
4924
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
4925
+ };
4926
+
4927
+ const getDayCountOfMonth = function(year, month) {
4928
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
4929
+ return 30;
4930
+ }
4931
+
4932
+ if (month === 1) {
4933
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
4934
+ return 29;
4935
+ } else {
4936
+ return 28;
4937
+ }
4938
+ }
4939
+
4940
+ return 31;
4941
+ };
4942
+
4943
+ const getDayCountOfYear = function(year) {
4944
+ const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
4945
+ return isLeapYear ? 366 : 365;
4946
+ };
4947
+
4948
+ const getFirstDayOfMonth = function(date) {
4949
+ const temp = new Date(date.getTime());
4950
+ temp.setDate(1);
4951
+ return temp.getDay();
4952
+ };
4953
+
4954
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
4955
+ // {prev, next} Date should work for Daylight Saving Time
4956
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
4957
+ const prevDate = function(date, amount = 1) {
4958
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
4959
+ };
4960
+
4961
+ const nextDate = function(date, amount = 1) {
4962
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
4963
+ };
4964
+
4965
+ const getStartDateOfMonth = function(year, month) {
4966
+ const result = new Date(year, month, 1);
4967
+ const day = result.getDay();
4968
+
4969
+ if (day === 0) {
4970
+ return prevDate(result, 7);
4971
+ } else {
4972
+ return prevDate(result, day);
4973
+ }
4974
+ };
4975
+
4976
+ const getWeekNumber = function(date) {
4977
+ // 支持多种输入类型
4978
+ if (!date||!isDate(date)) {
4979
+ date = new Date();
4980
+ }
4981
+ if (typeof date === 'string') {
4982
+ date = new Date(date);
4983
+ }
4984
+
4985
+ // 验证日期有效性
4986
+ if (!isDate(date)) return null;
4987
+
4988
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
4989
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
4990
+ // 将星期日的星期数设为7
4991
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
4992
+ // 获取当年的第一天
4993
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
4994
+ // 计算到最近的星期四的完整周数
4995
+ const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
4996
+ // 返回周数
4997
+ return weekNo;
4998
+ };
4999
+
5000
+ const getRangeHours = function(ranges) {
5001
+ const hours = [];
5002
+ let disabledHours = [];
5003
+
5004
+ (ranges || []).forEach(range => {
5005
+ const value = range.map(date => date.getHours());
5006
+
5007
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
5008
+ });
5009
+
5010
+ if (disabledHours.length) {
5011
+ for (let i = 0; i < 24; i++) {
5012
+ hours[i] = disabledHours.indexOf(i) === -1;
5013
+ }
5014
+ } else {
5015
+ for (let i = 0; i < 24; i++) {
5016
+ hours[i] = false;
5017
+ }
5018
+ }
5019
+
5020
+ return hours;
5021
+ };
5022
+
5023
+ const getPrevMonthLastDays = (date, amount) => {
5024
+ if (amount <= 0) return [];
5025
+ const temp = new Date(date.getTime());
5026
+ temp.setDate(0);
5027
+ const lastDay = temp.getDate();
5028
+ return range(amount).map((_, index) => lastDay - (amount - index - 1));
5029
+ };
5030
+
5031
+ const getMonthDays = (date) => {
5032
+ const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
5033
+ const days = temp.getDate();
5034
+ return range(days).map((_, index) => index + 1);
5035
+ };
5036
+
5037
+ function setRangeData(arr, start, end, value) {
5038
+ for (let i = start; i < end; i++) {
5039
+ arr[i] = value;
5040
+ }
5041
+ }
5042
+
5043
+ const getRangeMinutes = function(ranges, hour) {
5044
+ const minutes = new Array(60);
5045
+
5046
+ if (ranges.length > 0) {
5047
+ ranges.forEach(range => {
5048
+ const start = range[0];
5049
+ const end = range[1];
5050
+ const startHour = start.getHours();
5051
+ const startMinute = start.getMinutes();
5052
+ const endHour = end.getHours();
5053
+ const endMinute = end.getMinutes();
5054
+ if (startHour === hour && endHour !== hour) {
5055
+ setRangeData(minutes, startMinute, 60, true);
5056
+ } else if (startHour === hour && endHour === hour) {
5057
+ setRangeData(minutes, startMinute, endMinute + 1, true);
5058
+ } else if (startHour !== hour && endHour === hour) {
5059
+ setRangeData(minutes, 0, endMinute + 1, true);
5060
+ } else if (startHour < hour && endHour > hour) {
5061
+ setRangeData(minutes, 0, 60, true);
5062
+ }
5063
+ });
5064
+ } else {
5065
+ setRangeData(minutes, 0, 60, true);
5066
+ }
5067
+ return minutes;
5068
+ };
5069
+
5070
+ const range = function(n) {
5071
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
5072
+ return Array.apply(null, {length: n}).map((_, n) => n);
5073
+ };
5074
+
5075
+ const modifyDate = function(date, y, m, d) {
5076
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
5077
+ };
5078
+
5079
+ const modifyTime = function(date, h, m, s) {
5080
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
5081
+ };
5082
+
5083
+ const modifyWithTimeString = (date, time) => {
5084
+ if (date == null || !time) {
5085
+ return date;
5086
+ }
5087
+ time = parseDate(time, 'HH:mm:ss');
5088
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
5089
+ };
5090
+
5091
+ const clearTime = function(date) {
5092
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
5093
+ };
5094
+
5095
+ const clearMilliseconds = function(date) {
5096
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
5097
+ };
5098
+
5099
+ const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
5100
+ // TODO: refactory a more elegant solution
5101
+ if (ranges.length === 0) return date;
5102
+ const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
5103
+ const ndate = normalizeDate(date);
5104
+ const nranges = ranges.map(range => range.map(normalizeDate));
5105
+ if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
5106
+
5107
+ let minDate = nranges[0][0];
5108
+ let maxDate = nranges[0][0];
5109
+
5110
+ nranges.forEach(nrange => {
5111
+ minDate = new Date(Math.min(nrange[0], minDate));
5112
+ maxDate = new Date(Math.max(nrange[1], minDate));
5113
+ });
5114
+
5115
+ const ret = ndate < minDate ? minDate : maxDate;
5116
+ // preserve Year/Month/Date
5117
+ return modifyDate(
5118
+ ret,
5119
+ date.getFullYear(),
5120
+ date.getMonth(),
5121
+ date.getDate()
5122
+ );
5123
+ };
5124
+
5125
+ const timeWithinRange = function(date, selectableRange, format) {
5126
+ const limitedDate = limitTimeRange(date, selectableRange, format);
5127
+ return limitedDate.getTime() === date.getTime();
5128
+ };
5129
+
5130
+ const changeYearMonthAndClampDate = function(date, year, month) {
5131
+ // clamp date to the number of days in `year`, `month`
5132
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
5133
+ const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
5134
+ return modifyDate(date, year, month, monthDate);
5135
+ };
5136
+
5137
+ const prevMonth = function(date) {
5138
+ const year = date.getFullYear();
5139
+ const month = date.getMonth();
5140
+ return month === 0
5141
+ ? changeYearMonthAndClampDate(date, year - 1, 11)
5142
+ : changeYearMonthAndClampDate(date, year, month - 1);
5143
+ };
5144
+
5145
+ const nextMonth = function(date) {
5146
+ const year = date.getFullYear();
5147
+ const month = date.getMonth();
5148
+ return month === 11
5149
+ ? changeYearMonthAndClampDate(date, year + 1, 0)
5150
+ : changeYearMonthAndClampDate(date, year, month + 1);
5151
+ };
5152
+
5153
+ const prevYear = function(date, amount = 1) {
5154
+ const year = date.getFullYear();
5155
+ const month = date.getMonth();
5156
+ return changeYearMonthAndClampDate(date, year - amount, month);
5157
+ };
5158
+
5159
+ const nextYear = function(date, amount = 1) {
5160
+ const year = date.getFullYear();
5161
+ const month = date.getMonth();
5162
+ return changeYearMonthAndClampDate(date, year + amount, month);
5163
+ };
5164
+
5165
+ const extractDateFormat = function(format) {
5166
+ return format
5167
+ .replace(/\W?m{1,2}|\W?ZZ/g, '')
5168
+ .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
5169
+ .trim();
5170
+ };
5171
+
5172
+ const extractTimeFormat = function(format) {
5173
+ return format
5174
+ .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
5175
+ .trim();
5176
+ };
5177
+
5178
+ const validateRangeInOneMonth = function(start, end) {
5179
+ return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
5180
+ };
5181
+
5164
5182
  /**
5165
5183
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
5166
5184
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
5167
5185
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
5168
5186
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
5169
5187
  * @returns {number} 工作日数量
5170
- */
5171
- var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
5172
- var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
5173
-
5174
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
5175
- throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
5176
- }
5177
-
5178
- var startDateObj = new Date(start_date);
5179
- var endDateObj = new Date(end_date);
5180
-
5181
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
5182
- throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
5183
- }
5184
-
5185
- if (startDateObj > endDateObj) {
5186
- throw new Error('Start date should be earlier than or equal to end date.');
5187
- }
5188
-
5189
- var workdays = 0;
5190
-
5191
- // Iterate through each day in the date range
5192
-
5193
- var _loop = function _loop(currentDate) {
5194
- // Check if the current day is a weekend (Saturday or Sunday)
5195
- var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
5196
-
5197
- // Check if the current day is a holiday
5198
- var isHoliday = holidays.some(function (holiday) {
5199
- var holidayDate = new Date(holiday);
5200
- return currentDate.toDateString() === holidayDate.toDateString();
5201
- });
5202
-
5203
- // If it's a workday (not a weekend or holiday), increment the workdays count
5204
- if (!isWeekend && !isHoliday) {
5205
- workdays++;
5206
- }
5207
- };
5208
-
5209
- for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
5210
- _loop(currentDate);
5211
- }
5212
-
5213
- return workdays;
5214
- };
5215
-
5188
+ */
5189
+ const calculateNetworkDays = function (start_date, end_date, holidays = []) {
5190
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
5191
+ throw new Error(
5192
+ "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
5193
+ );
5194
+ }
5195
+
5196
+ const startDateObj = new Date(start_date);
5197
+ const endDateObj = new Date(end_date);
5198
+
5199
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
5200
+ throw new Error(
5201
+ "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
5202
+ );
5203
+ }
5204
+
5205
+ if (startDateObj > endDateObj) {
5206
+ throw new Error('Start date should be earlier than or equal to end date.');
5207
+ }
5208
+
5209
+ let workdays = 0;
5210
+
5211
+ // Iterate through each day in the date range
5212
+ for (
5213
+ let currentDate = new Date(startDateObj);
5214
+ currentDate <= endDateObj;
5215
+ currentDate.setDate(currentDate.getDate() + 1)
5216
+ ) {
5217
+ // Check if the current day is a weekend (Saturday or Sunday)
5218
+ const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
5219
+
5220
+ // Check if the current day is a holiday
5221
+ const isHoliday = holidays.some((holiday) => {
5222
+ const holidayDate = new Date(holiday);
5223
+ return currentDate.toDateString() === holidayDate.toDateString();
5224
+ });
5225
+
5226
+ // If it's a workday (not a weekend or holiday), increment the workdays count
5227
+ if (!isWeekend && !isHoliday) {
5228
+ workdays++;
5229
+ }
5230
+ }
5231
+
5232
+ return workdays;
5233
+ };
5234
+
5216
5235
  /**
5217
5236
  * 日期加减天数
5218
5237
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
5219
5238
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
5220
5239
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
5221
- */
5222
- var dateAddDays = function dateAddDays(start_date, days) {
5223
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
5224
- 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.");
5225
- }
5226
-
5227
- var startDateObj = new Date(start_date);
5228
- if (isNaN(startDateObj.getTime())) {
5229
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5230
- }
5231
-
5232
- var resultDateObj = new Date(startDateObj);
5233
- resultDateObj.setDate(resultDateObj.getDate() + days);
5234
-
5235
- var resultYear = resultDateObj.getFullYear();
5236
- var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
5237
- var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
5238
-
5239
- return resultYear + '-' + resultMonth + '-' + resultDay;
5240
- };
5241
-
5240
+ */
5241
+ const dateAddDays = function (start_date, days) {
5242
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
5243
+ throw new Error(
5244
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
5245
+ );
5246
+ }
5247
+
5248
+ const startDateObj = new Date(start_date);
5249
+ if (isNaN(startDateObj.getTime())) {
5250
+ throw new Error(
5251
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
5252
+ );
5253
+ }
5254
+
5255
+ const resultDateObj = new Date(startDateObj);
5256
+ resultDateObj.setDate(resultDateObj.getDate() + days);
5257
+
5258
+ const resultYear = resultDateObj.getFullYear();
5259
+ const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
5260
+ const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
5261
+
5262
+ return `${resultYear}-${resultMonth}-${resultDay}`;
5263
+ };
5264
+
5242
5265
  /**
5243
5266
  * 计算两个日期之间的差值
5244
5267
  * @date 2023年12月14日
@@ -5246,180 +5269,182 @@ var dateAddDays = function dateAddDays(start_date, days) {
5246
5269
  * @param {String} end_date - 结束日期字符串
5247
5270
  * @param {String} unit - 单位:year/month/day
5248
5271
  * @returns {Number} 差值
5249
- */
5250
- var dateDiff = function dateDiff(start_date, end_date) {
5251
- var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
5252
-
5253
- // Assuming date strings are in "YYYY-MM-DD" format
5254
- var startDate = new Date(start_date);
5255
- var endDate = new Date(end_date);
5256
-
5257
- // If the date is invalid, return 0
5258
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
5259
- return 0;
5260
- }
5261
-
5262
- if (unit === 'year') {
5263
- return endDate.getFullYear() - startDate.getFullYear();
5264
- } else if (unit === 'month') {
5265
- return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
5266
- } else {
5267
- // Default to day
5268
- var timeDifference = endDate - startDate;
5269
- // Calculate days (86400000 milliseconds per day)
5270
- return Math.floor(timeDifference / 86400000);
5271
- }
5272
- };
5273
-
5272
+ */
5273
+ const dateDiff = function (start_date, end_date, unit = 'day') {
5274
+ // Assuming date strings are in "YYYY-MM-DD" format
5275
+ var startDate = new Date(start_date);
5276
+ var endDate = new Date(end_date);
5277
+
5278
+ // If the date is invalid, return 0
5279
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
5280
+ return 0;
5281
+ }
5282
+
5283
+ if (unit === 'year') {
5284
+ return endDate.getFullYear() - startDate.getFullYear();
5285
+ } else if (unit === 'month') {
5286
+ return (
5287
+ (endDate.getFullYear() - startDate.getFullYear()) * 12 +
5288
+ (endDate.getMonth() - startDate.getMonth())
5289
+ );
5290
+ } else {
5291
+ // Default to day
5292
+ var timeDifference = endDate - startDate;
5293
+ // Calculate days (86400000 milliseconds per day)
5294
+ return Math.floor(timeDifference / 86400000);
5295
+ }
5296
+ };
5297
+
5274
5298
  /**
5275
5299
  * 获取月份中的日期
5276
5300
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
5277
5301
  * @returns {number} 月份中的日期(1-31)
5278
- */
5279
- var dayOfMonth = function dayOfMonth(date) {
5280
- if (typeof date !== 'string') {
5281
- throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5282
- }
5283
-
5284
- var dateObj = new Date(date);
5285
- if (isNaN(dateObj.getTime())) {
5286
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5287
- }
5288
-
5289
- return dateObj.getDate();
5290
- };
5291
-
5302
+ */
5303
+ const dayOfMonth = function (date) {
5304
+ if (typeof date !== 'string') {
5305
+ throw new Error(
5306
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
5307
+ );
5308
+ }
5309
+
5310
+ const dateObj = new Date(date);
5311
+ if (isNaN(dateObj.getTime())) {
5312
+ throw new Error(
5313
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
5314
+ );
5315
+ }
5316
+
5317
+ return dateObj.getDate();
5318
+ };
5319
+
5292
5320
  /**
5293
5321
  * 获取当前日期
5294
5322
  * @date 2022年5月7日
5295
5323
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
5296
5324
  * @returns {string} 当前日期的格式化字符串
5297
- */
5298
- var getCurrentDate = function getCurrentDate() {
5299
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
5300
-
5301
- return formatDate(new Date(), format);
5302
- };
5303
-
5325
+ */
5326
+ const getCurrentDate = function (format = 'YYYY-MM-DD') {
5327
+ return formatDate(new Date(), format);
5328
+ };
5329
+
5304
5330
  /**
5305
5331
  * 获取当前日期时间
5306
5332
  * @date 2022年5月7日
5307
5333
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
5308
5334
  * @returns {string} 当前日期时间的格式化字符串
5309
- */
5310
- var getCurrentDateTime = function getCurrentDateTime() {
5311
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
5312
-
5313
- return formatDate(new Date(), format);
5314
- };
5315
-
5335
+ */
5336
+ const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
5337
+ return formatDate(new Date(), format);
5338
+ };
5339
+
5316
5340
  /**
5317
5341
  * 获取小时
5318
5342
  * @date 2022年5月7日
5319
5343
  * @param {Date|string} [date] - 日期对象或日期字符串
5320
5344
  * @returns {number} 小时数(0-23)
5321
- */
5322
- var getHour = function getHour(date) {
5323
- if (!date) {
5324
- return new Date().getHours();
5325
- }
5326
- if (typeof date === 'string') {
5327
- date = new Date(date);
5328
- }
5329
- return date.getHours();
5330
- };
5331
-
5345
+ */
5346
+ const getHour = function (date) {
5347
+ if (!date) {
5348
+ return new Date().getHours();
5349
+ }
5350
+ if (typeof date === 'string') {
5351
+ date = new Date(date);
5352
+ }
5353
+ return date.getHours();
5354
+ };
5355
+
5332
5356
  /**
5333
5357
  * 获取分钟
5334
5358
  * @date 2022年5月7日
5335
5359
  * @param {Date|string} [date] - 日期对象或日期字符串
5336
5360
  * @returns {number} 分钟数(0-59)
5337
- */
5338
- var getMinute = function getMinute(date) {
5339
- if (!date) {
5340
- return new Date().getMinutes();
5341
- }
5342
- if (typeof date === 'string') {
5343
- date = new Date(date);
5344
- }
5345
- return date.getMinutes();
5346
- };
5347
-
5361
+ */
5362
+ const getMinute = function (date) {
5363
+ if (!date) {
5364
+ return new Date().getMinutes();
5365
+ }
5366
+ if (typeof date === 'string') {
5367
+ date = new Date(date);
5368
+ }
5369
+ return date.getMinutes();
5370
+ };
5371
+
5348
5372
  /**
5349
5373
  * 获取月份
5350
5374
  * @date 2022年5月7日
5351
5375
  * @param {Date|string} [date] - 日期对象或日期字符串
5352
5376
  * @returns {number} 月份数(1-12)
5353
- */
5354
- var getMonth = function getMonth(date) {
5355
- if (!date) {
5356
- return new Date().getMonth() + 1;
5357
- }
5358
- if (typeof date === 'string') {
5359
- date = new Date(date);
5360
- }
5361
- return date.getMonth() + 1;
5362
- };
5363
-
5377
+ */
5378
+ const getMonth = function (date) {
5379
+ if (!date) {
5380
+ return new Date().getMonth() + 1;
5381
+ }
5382
+ if (typeof date === 'string') {
5383
+ date = new Date(date);
5384
+ }
5385
+ return date.getMonth() + 1;
5386
+ };
5387
+
5364
5388
  /**
5365
5389
  * 获取秒
5366
5390
  * @date 2022年5月7日
5367
5391
  * @param {Date|string} [date] - 日期对象或日期字符串
5368
5392
  * @returns {number} 秒数(0-59)
5369
- */
5370
- var getSecond = function getSecond(date) {
5371
- if (!date) {
5372
- return new Date().getSeconds();
5373
- }
5374
- if (typeof date === 'string') {
5375
- date = new Date(date);
5376
- }
5377
- return date.getSeconds();
5378
- };
5379
-
5393
+ */
5394
+ const getSecond = function (date) {
5395
+ if (!date) {
5396
+ return new Date().getSeconds();
5397
+ }
5398
+ if (typeof date === 'string') {
5399
+ date = new Date(date);
5400
+ }
5401
+ return date.getSeconds();
5402
+ };
5403
+
5380
5404
  /**
5381
5405
  * 获取星期几
5382
5406
  * @date 2022年5月7日
5383
5407
  * @param {Date|string} [date] - 日期对象或日期字符串
5384
5408
  * @returns {number} 星期几(0-6,0表示星期日)
5385
- */
5386
- var getWeekday = function getWeekday(date) {
5387
- if (!date) {
5388
- return new Date().getDay();
5389
- }
5390
- if (typeof date === 'string') {
5391
- date = new Date(date);
5392
- }
5393
- return date.getDay();
5394
- };
5395
-
5409
+ */
5410
+ const getWeekday = function (date) {
5411
+ if (!date) {
5412
+ return new Date().getDay();
5413
+ }
5414
+ if (typeof date === 'string') {
5415
+ date = new Date(date);
5416
+ }
5417
+ return date.getDay();
5418
+ };
5419
+
5420
+
5396
5421
  /**
5397
5422
  * @desc 获取上午/下午/晚上
5398
5423
  * @author huangbo
5399
5424
  * @date 2022年5月7日
5400
5425
  * @param {String} [time] - 时间
5401
- **/
5402
- var timeCycle = function timeCycle(time) {
5403
- var hour = 0;
5404
- if (!time) {
5405
- hour = new Date().getHours();
5406
- } else if (typeof time === 'string') {
5407
- // 从时间字符串中提取小时
5408
- var match = time.match(/^(\d{1,2})/);
5409
- if (match) {
5410
- hour = parseInt(match[1], 10);
5411
- }
5412
- } else if (typeof time === 'number') {
5413
- hour = time;
5414
- }
5415
- // 判断时间段
5416
- if (hour >= 5 && hour < 12) {
5417
- return '上午';
5418
- } else if (hour >= 12 && hour < 18) {
5419
- return '下午';
5420
- } else {
5421
- return '晚上';
5422
- }
5426
+ **/
5427
+ const timeCycle = function (time) {
5428
+ let hour = 0;
5429
+ if (!time) {
5430
+ hour = new Date().getHours();
5431
+ } else if (typeof time === 'string') {
5432
+ // 从时间字符串中提取小时
5433
+ const match = time.match(/^(\d{1,2})/);
5434
+ if (match) {
5435
+ hour = parseInt(match[1], 10);
5436
+ }
5437
+ } else if (typeof time === 'number') {
5438
+ hour = time;
5439
+ }
5440
+ // 判断时间段
5441
+ if (hour >= 5 && hour < 12) {
5442
+ return '上午';
5443
+ } else if (hour >= 12 && hour < 18) {
5444
+ return '下午';
5445
+ } else {
5446
+ return '晚上';
5447
+ }
5423
5448
  };
5424
5449
 
5425
5450
  /***/ }),