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/flows.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 = 182);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 184);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -3528,7 +3528,7 @@ module.exports = require("lodash/set");
3528
3528
 
3529
3529
  /***/ }),
3530
3530
 
3531
- /***/ 182:
3531
+ /***/ 184:
3532
3532
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3533
3533
 
3534
3534
  "use strict";
@@ -7393,736 +7393,759 @@ module.exports = require("eoss/lib/tag");
7393
7393
  /* unused harmony export getSecond */
7394
7394
  /* unused harmony export getWeekday */
7395
7395
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
7396
-
7397
-
7396
+ /* Modified from https://github.com/taylorhakes/fecha
7397
+ *
7398
+ * The MIT License (MIT)
7399
+ *
7400
+ * Copyright (c) 2015 Taylor Hakes
7401
+ *
7402
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7403
+ * of this software and associated documentation files (the "Software"), to deal
7404
+ * in the Software without restriction, including without limitation the rights
7405
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7406
+ * copies of the Software, and to permit persons to whom the Software is
7407
+ * furnished to do so, subject to the following conditions:
7408
+ *
7409
+ * The above copyright notice and this permission notice shall be included in all
7410
+ * copies or substantial portions of the Software.
7411
+ *
7412
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
7413
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7414
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
7415
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
7416
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
7417
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
7418
+ * SOFTWARE.
7419
+ */
7420
+
7421
+ /*eslint-disable*/
7422
+ // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
7423
+
7424
+
7398
7425
  /**
7399
7426
  * Parse or format dates
7400
7427
  * @class fecha
7401
- */
7402
- var fecha = {};
7403
- var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
7404
- var twoDigits = '\\d\\d?';
7405
- var threeDigits = '\\d{3}';
7406
- var fourDigits = '\\d{4}';
7407
- var word = '[^\\s]+';
7408
- var literal = /\[([^]*?)\]/gm;
7409
- var noop = function noop() {};
7410
-
7411
- function regexEscape(str) {
7412
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
7413
- }
7414
-
7415
- function shorten(arr, sLen) {
7416
- var newArr = [];
7417
- for (var i = 0, len = arr.length; i < len; i++) {
7418
- newArr.push(arr[i].substr(0, sLen));
7419
- }
7420
- return newArr;
7421
- }
7422
-
7423
- function monthUpdate() {
7424
- return function (d, v) {
7425
- var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
7426
- if (~index) {
7427
- d.month = index;
7428
- }
7429
- };
7430
- }
7431
-
7432
- function pad(val, len) {
7433
- val = String(val);
7434
- len = len || 2;
7435
- while (val.length < len) {
7436
- val = '0' + val;
7437
- }
7438
- return val;
7439
- }
7440
-
7441
- // 直接使用中文日期名称常量
7442
- var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
7443
- var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
7444
- var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
7445
- var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
7446
- var amPm = ['上午', '下午'];
7447
- var DoFn = function DoFn(D) {
7448
- return D + '日';
7449
- };
7450
-
7451
- var formatFlags = {
7452
- D: function D(dateObj) {
7453
- return dateObj.getDay();
7454
- },
7455
- DD: function DD(dateObj) {
7456
- return pad(dateObj.getDay());
7457
- },
7458
- Do: function Do(dateObj) {
7459
- return DoFn(dateObj.getDate());
7460
- },
7461
- d: function d(dateObj) {
7462
- return dateObj.getDate();
7463
- },
7464
- dd: function dd(dateObj) {
7465
- return pad(dateObj.getDate());
7466
- },
7467
- ddd: function ddd(dateObj) {
7468
- return dayNamesShort[dateObj.getDay()];
7469
- },
7470
- dddd: function dddd(dateObj) {
7471
- return dayNames[dateObj.getDay()];
7472
- },
7473
- M: function M(dateObj) {
7474
- return dateObj.getMonth() + 1;
7475
- },
7476
- MM: function MM(dateObj) {
7477
- return pad(dateObj.getMonth() + 1);
7478
- },
7479
- MMM: function MMM(dateObj) {
7480
- return monthNamesShort[dateObj.getMonth()];
7481
- },
7482
- MMMM: function MMMM(dateObj) {
7483
- return monthNames[dateObj.getMonth()];
7484
- },
7485
- yy: function yy(dateObj) {
7486
- return pad(String(dateObj.getFullYear()), 4).substr(2);
7487
- },
7488
- yyyy: function yyyy(dateObj) {
7489
- return pad(dateObj.getFullYear(), 4);
7490
- },
7491
- h: function h(dateObj) {
7492
- return dateObj.getHours() % 12 || 12;
7493
- },
7494
- hh: function hh(dateObj) {
7495
- return pad(dateObj.getHours() % 12 || 12);
7496
- },
7497
- H: function H(dateObj) {
7498
- return dateObj.getHours();
7499
- },
7500
- HH: function HH(dateObj) {
7501
- return pad(dateObj.getHours());
7502
- },
7503
- m: function m(dateObj) {
7504
- return dateObj.getMinutes();
7505
- },
7506
- mm: function mm(dateObj) {
7507
- return pad(dateObj.getMinutes());
7508
- },
7509
- s: function s(dateObj) {
7510
- return dateObj.getSeconds();
7511
- },
7512
- ss: function ss(dateObj) {
7513
- return pad(dateObj.getSeconds());
7514
- },
7515
- S: function S(dateObj) {
7516
- return Math.round(dateObj.getMilliseconds() / 100);
7517
- },
7518
- SS: function SS(dateObj) {
7519
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
7520
- },
7521
- SSS: function SSS(dateObj) {
7522
- return pad(dateObj.getMilliseconds(), 3);
7523
- },
7524
- a: function a(dateObj) {
7525
- return dateObj.getHours() < 12 ? '上午' : '下午';
7526
- },
7527
- A: function A(dateObj) {
7528
- return dateObj.getHours() < 12 ? '上午' : '下午';
7529
- },
7530
- ZZ: function ZZ(dateObj) {
7531
- var o = dateObj.getTimezoneOffset();
7532
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
7533
- }
7534
- };
7535
-
7536
- var parseFlags = {
7537
- d: [twoDigits, function (d, v) {
7538
- d.day = v;
7539
- }],
7540
- Do: [twoDigits + word, function (d, v) {
7541
- d.day = parseInt(v, 10);
7542
- }],
7543
- M: [twoDigits, function (d, v) {
7544
- d.month = v - 1;
7545
- }],
7546
- yy: [twoDigits, function (d, v) {
7547
- var da = new Date(),
7548
- cent = +('' + da.getFullYear()).substr(0, 2);
7549
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
7550
- }],
7551
- h: [twoDigits, function (d, v) {
7552
- d.hour = v;
7553
- }],
7554
- m: [twoDigits, function (d, v) {
7555
- d.minute = v;
7556
- }],
7557
- s: [twoDigits, function (d, v) {
7558
- d.second = v;
7559
- }],
7560
- yyyy: [fourDigits, function (d, v) {
7561
- d.year = v;
7562
- }],
7563
- S: ['\\d', function (d, v) {
7564
- d.millisecond = v * 100;
7565
- }],
7566
- SS: ['\\d{2}', function (d, v) {
7567
- d.millisecond = v * 10;
7568
- }],
7569
- SSS: [threeDigits, function (d, v) {
7570
- d.millisecond = v;
7571
- }],
7572
- D: [twoDigits, noop],
7573
- ddd: [word, noop],
7574
- MMM: [word, monthUpdate('monthNamesShort')],
7575
- MMMM: [word, monthUpdate('monthNames')],
7576
- a: [word, function (d, v) {
7577
- var val = v.toLowerCase();
7578
- if (val === '上午') {
7579
- d.isPm = false;
7580
- } else if (val === '下午') {
7581
- d.isPm = true;
7582
- }
7583
- }],
7584
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
7585
- var parts = (v + '').match(/([+-]|\d\d)/gi),
7586
- minutes = void 0;
7587
-
7588
- if (parts) {
7589
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
7590
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
7591
- }
7592
- }]
7593
- };
7594
- parseFlags.dd = parseFlags.d;
7595
- parseFlags.dddd = parseFlags.ddd;
7596
- parseFlags.DD = parseFlags.D;
7597
- parseFlags.mm = parseFlags.m;
7598
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
7599
- parseFlags.MM = parseFlags.M;
7600
- parseFlags.ss = parseFlags.s;
7601
- parseFlags.A = parseFlags.a;
7602
-
7603
- // Some common format strings
7604
- fecha.masks = {
7605
- default: 'ddd MMM dd yyyy HH:mm:ss',
7606
- shortDate: 'M/D/yy',
7607
- mediumDate: 'MMM d, yyyy',
7608
- longDate: 'MMMM d, yyyy',
7609
- fullDate: 'dddd, MMMM d, yyyy',
7610
- shortTime: 'HH:mm',
7611
- mediumTime: 'HH:mm:ss',
7612
- longTime: 'HH:mm:ss.SSS'
7613
- };
7614
-
7428
+ */
7429
+ const fecha = {};
7430
+ const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
7431
+ const twoDigits = '\\d\\d?';
7432
+ const threeDigits = '\\d{3}';
7433
+ const fourDigits = '\\d{4}';
7434
+ const word = '[^\\s]+';
7435
+ const literal = /\[([^]*?)\]/gm;
7436
+ const noop = function () {};
7437
+
7438
+ function regexEscape(str) {
7439
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
7440
+ }
7441
+
7442
+ function shorten(arr, sLen) {
7443
+ const newArr = [];
7444
+ for (let i = 0, len = arr.length; i < len; i++) {
7445
+ newArr.push(arr[i].substr(0, sLen));
7446
+ }
7447
+ return newArr;
7448
+ }
7449
+
7450
+ function monthUpdate() {
7451
+ return function (d, v) {
7452
+ const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
7453
+ if (~index) {
7454
+ d.month = index;
7455
+ }
7456
+ };
7457
+ }
7458
+
7459
+ function pad(val, len) {
7460
+ val = String(val);
7461
+ len = len || 2;
7462
+ while (val.length < len) {
7463
+ val = '0' + val;
7464
+ }
7465
+ return val;
7466
+ }
7467
+
7468
+ // 直接使用中文日期名称常量
7469
+ const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
7470
+ const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
7471
+ const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
7472
+ const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
7473
+ const amPm = ['上午', '下午'];
7474
+ const DoFn = function DoFn(D) {
7475
+ return D + '日';
7476
+ };
7477
+
7478
+ const formatFlags = {
7479
+ D: function(dateObj) {
7480
+ return dateObj.getDay();
7481
+ },
7482
+ DD: function(dateObj) {
7483
+ return pad(dateObj.getDay());
7484
+ },
7485
+ Do: function(dateObj) {
7486
+ return DoFn(dateObj.getDate());
7487
+ },
7488
+ d: function(dateObj) {
7489
+ return dateObj.getDate();
7490
+ },
7491
+ dd: function(dateObj) {
7492
+ return pad(dateObj.getDate());
7493
+ },
7494
+ ddd: function(dateObj) {
7495
+ return dayNamesShort[dateObj.getDay()];
7496
+ },
7497
+ dddd: function(dateObj) {
7498
+ return dayNames[dateObj.getDay()];
7499
+ },
7500
+ M: function(dateObj) {
7501
+ return dateObj.getMonth() + 1;
7502
+ },
7503
+ MM: function(dateObj) {
7504
+ return pad(dateObj.getMonth() + 1);
7505
+ },
7506
+ MMM: function(dateObj) {
7507
+ return monthNamesShort[dateObj.getMonth()];
7508
+ },
7509
+ MMMM: function(dateObj) {
7510
+ return monthNames[dateObj.getMonth()];
7511
+ },
7512
+ yy: function(dateObj) {
7513
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
7514
+ },
7515
+ yyyy: function(dateObj) {
7516
+ return pad(dateObj.getFullYear(), 4);
7517
+ },
7518
+ h: function(dateObj) {
7519
+ return dateObj.getHours() % 12 || 12;
7520
+ },
7521
+ hh: function(dateObj) {
7522
+ return pad(dateObj.getHours() % 12 || 12);
7523
+ },
7524
+ H: function(dateObj) {
7525
+ return dateObj.getHours();
7526
+ },
7527
+ HH: function(dateObj) {
7528
+ return pad(dateObj.getHours());
7529
+ },
7530
+ m: function(dateObj) {
7531
+ return dateObj.getMinutes();
7532
+ },
7533
+ mm: function(dateObj) {
7534
+ return pad(dateObj.getMinutes());
7535
+ },
7536
+ s: function(dateObj) {
7537
+ return dateObj.getSeconds();
7538
+ },
7539
+ ss: function(dateObj) {
7540
+ return pad(dateObj.getSeconds());
7541
+ },
7542
+ S: function(dateObj) {
7543
+ return Math.round(dateObj.getMilliseconds() / 100);
7544
+ },
7545
+ SS: function(dateObj) {
7546
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
7547
+ },
7548
+ SSS: function(dateObj) {
7549
+ return pad(dateObj.getMilliseconds(), 3);
7550
+ },
7551
+ a: function(dateObj) {
7552
+ return dateObj.getHours() < 12 ? '上午' : '下午';
7553
+ },
7554
+ A: function(dateObj) {
7555
+ return dateObj.getHours() < 12 ? '上午' : '下午';
7556
+ },
7557
+ ZZ: function(dateObj) {
7558
+ const o = dateObj.getTimezoneOffset();
7559
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
7560
+ }
7561
+ };
7562
+
7563
+ const parseFlags = {
7564
+ d: [twoDigits, function (d, v) {
7565
+ d.day = v;
7566
+ }],
7567
+ Do: [twoDigits + word, function (d, v) {
7568
+ d.day = parseInt(v, 10);
7569
+ }],
7570
+ M: [twoDigits, function (d, v) {
7571
+ d.month = v - 1;
7572
+ }],
7573
+ yy: [twoDigits, function (d, v) {
7574
+ const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
7575
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
7576
+ }],
7577
+ h: [twoDigits, function (d, v) {
7578
+ d.hour = v;
7579
+ }],
7580
+ m: [twoDigits, function (d, v) {
7581
+ d.minute = v;
7582
+ }],
7583
+ s: [twoDigits, function (d, v) {
7584
+ d.second = v;
7585
+ }],
7586
+ yyyy: [fourDigits, function (d, v) {
7587
+ d.year = v;
7588
+ }],
7589
+ S: ['\\d', function (d, v) {
7590
+ d.millisecond = v * 100;
7591
+ }],
7592
+ SS: ['\\d{2}', function (d, v) {
7593
+ d.millisecond = v * 10;
7594
+ }],
7595
+ SSS: [threeDigits, function (d, v) {
7596
+ d.millisecond = v;
7597
+ }],
7598
+ D: [twoDigits, noop],
7599
+ ddd: [word, noop],
7600
+ MMM: [word, monthUpdate('monthNamesShort')],
7601
+ MMMM: [word, monthUpdate('monthNames')],
7602
+ a: [word, function (d, v) {
7603
+ const val = v.toLowerCase();
7604
+ if (val === '上午') {
7605
+ d.isPm = false;
7606
+ } else if (val === '下午') {
7607
+ d.isPm = true;
7608
+ }
7609
+ }],
7610
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
7611
+ let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
7612
+
7613
+ if (parts) {
7614
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
7615
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
7616
+ }
7617
+ }]
7618
+ };
7619
+ parseFlags.dd = parseFlags.d;
7620
+ parseFlags.dddd = parseFlags.ddd;
7621
+ parseFlags.DD = parseFlags.D;
7622
+ parseFlags.mm = parseFlags.m;
7623
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
7624
+ parseFlags.MM = parseFlags.M;
7625
+ parseFlags.ss = parseFlags.s;
7626
+ parseFlags.A = parseFlags.a;
7627
+
7628
+
7629
+ // Some common format strings
7630
+ fecha.masks = {
7631
+ default: 'ddd MMM dd yyyy HH:mm:ss',
7632
+ shortDate: 'M/D/yy',
7633
+ mediumDate: 'MMM d, yyyy',
7634
+ longDate: 'MMMM d, yyyy',
7635
+ fullDate: 'dddd, MMMM d, yyyy',
7636
+ shortTime: 'HH:mm',
7637
+ mediumTime: 'HH:mm:ss',
7638
+ longTime: 'HH:mm:ss.SSS'
7639
+ };
7640
+
7615
7641
  /***
7616
7642
  * Format a date
7617
7643
  * @method format
7618
7644
  * @param {Date|number} dateObj
7619
7645
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
7620
- */
7621
- fecha.format = function (dateObj, mask) {
7622
- if (typeof dateObj === 'number') {
7623
- dateObj = new Date(dateObj);
7624
- }
7625
-
7626
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
7627
- throw new Error('Invalid Date in fecha.format');
7628
- }
7629
-
7630
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
7631
-
7632
- var literals = [];
7633
-
7634
- // Make literals inactive by replacing them with ??
7635
- mask = mask.replace(literal, function ($0, $1) {
7636
- literals.push($1);
7637
- return '@@@';
7638
- });
7639
- // Apply formatting rules
7640
- mask = mask.replace(token, function ($0) {
7641
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
7642
- });
7643
- // Inline literal values back into the formatted value
7644
- return mask.replace(/@@@/g, function () {
7645
- return literals.shift();
7646
- });
7647
- };
7648
-
7646
+ */
7647
+ fecha.format = function (dateObj, mask) {
7648
+ if (typeof dateObj === 'number') {
7649
+ dateObj = new Date(dateObj);
7650
+ }
7651
+
7652
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
7653
+ throw new Error('Invalid Date in fecha.format');
7654
+ }
7655
+
7656
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
7657
+
7658
+ const literals = [];
7659
+
7660
+ // Make literals inactive by replacing them with ??
7661
+ mask = mask.replace(literal, function($0, $1) {
7662
+ literals.push($1);
7663
+ return '@@@';
7664
+ });
7665
+ // Apply formatting rules
7666
+ mask = mask.replace(token, function ($0) {
7667
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
7668
+ });
7669
+ // Inline literal values back into the formatted value
7670
+ return mask.replace(/@@@/g, function() {
7671
+ return literals.shift();
7672
+ });
7673
+ };
7674
+
7649
7675
  /**
7650
7676
  * Parse a date string into an object, changes - into /
7651
7677
  * @method parse
7652
7678
  * @param {string} dateStr Date string
7653
7679
  * @param {string} format Date parse format
7654
7680
  * @returns {Date|boolean}
7655
- */
7656
- fecha.parse = function (dateStr, format) {
7657
- if (typeof format !== 'string') {
7658
- throw new Error('Invalid format in fecha.parse');
7659
- }
7660
-
7661
- format = fecha.masks[format] || format;
7662
-
7663
- // Avoid regular expression denial of service, fail early for really long strings
7664
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
7665
- if (dateStr.length > 1000) {
7666
- return null;
7667
- }
7668
-
7669
- var dateInfo = {};
7670
- var parseInfo = [];
7671
- var literals = [];
7672
- format = format.replace(literal, function ($0, $1) {
7673
- literals.push($1);
7674
- return '@@@';
7675
- });
7676
- var newFormat = regexEscape(format).replace(token, function ($0) {
7677
- if (parseFlags[$0]) {
7678
- var info = parseFlags[$0];
7679
- parseInfo.push(info[1]);
7680
- return '(' + info[0] + ')';
7681
- }
7682
-
7683
- return $0;
7684
- });
7685
- newFormat = newFormat.replace(/@@@/g, function () {
7686
- return literals.shift();
7687
- });
7688
- var matches = dateStr.match(new RegExp(newFormat, 'i'));
7689
- if (!matches) {
7690
- return null;
7691
- }
7692
-
7693
- for (var i = 1; i < matches.length; i++) {
7694
- parseInfo[i - 1](dateInfo, matches[i]);
7695
- }
7696
-
7697
- var today = new Date();
7698
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
7699
- dateInfo.hour = +dateInfo.hour + 12;
7700
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
7701
- dateInfo.hour = 0;
7702
- }
7703
-
7704
- var date = void 0;
7705
- if (dateInfo.timezoneOffset != null) {
7706
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
7707
- 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));
7708
- } else {
7709
- 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);
7710
- }
7711
- return date;
7712
- };
7713
-
7714
- // 导出fecha对象
7715
-
7716
-
7717
- // 以下是从date-util.js合并的函数
7718
- var newArray = function newArray(start, end) {
7719
- var result = [];
7720
- for (var i = start; i <= end; i++) {
7721
- result.push(i);
7722
- }
7723
- return result;
7724
- };
7725
-
7726
- var getSettings = function getSettings() {
7727
- return {
7728
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
7729
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
7730
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
7731
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
7732
- amPm: ['上午', '下午']
7733
- };
7734
- };
7735
-
7736
- var toDate = function toDate(date) {
7737
- return isDate(date) ? new Date(date) : null;
7738
- };
7739
-
7740
- var isDate = function isDate(date) {
7741
- if (date === null || date === undefined) return false;
7742
- if (isNaN(new Date(date).getTime())) return false;
7743
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
7744
- return true;
7745
- };
7746
-
7747
- var isDateObject = function isDateObject(val) {
7748
- return val instanceof Date;
7749
- };
7750
-
7751
- var formatDate = function formatDate(date) {
7752
- var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
7753
-
7754
- // 处理多种输入类型
7755
- if (!date) return '';
7756
-
7757
- // 如果是时间戳,转成日期对象
7758
- if (typeof date === 'number') {
7759
- date = new Date(date);
7760
- }
7761
- // 如果是字符串,转成日期对象
7762
- if (typeof date === 'string') {
7763
- date = new Date(date);
7764
- }
7765
-
7766
- // 调用toDate进一步验证和转换
7767
- date = toDate(date);
7768
- if (!date) return '';
7769
-
7770
- // 兼容大写和小写的格式标记
7771
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
7772
- var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
7773
-
7774
- // 使用fecha库进行格式化,支持中文配置
7775
- var str = fecha.format(date, lowercaseFormat, getSettings());
7776
- return str;
7777
- };
7778
-
7779
- var parseDate = function parseDate(string, format) {
7780
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
7781
- };
7782
-
7783
- var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
7784
- if (month === 3 || month === 5 || month === 8 || month === 10) {
7785
- return 30;
7786
- }
7787
-
7788
- if (month === 1) {
7789
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
7790
- return 29;
7791
- } else {
7792
- return 28;
7793
- }
7794
- }
7795
-
7796
- return 31;
7797
- };
7798
-
7799
- var getDayCountOfYear = function getDayCountOfYear(year) {
7800
- var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
7801
- return isLeapYear ? 366 : 365;
7802
- };
7803
-
7804
- var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
7805
- var temp = new Date(date.getTime());
7806
- temp.setDate(1);
7807
- return temp.getDay();
7808
- };
7809
-
7810
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
7811
- // {prev, next} Date should work for Daylight Saving Time
7812
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
7813
- var prevDate = function prevDate(date) {
7814
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
7815
-
7816
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
7817
- };
7818
-
7819
- var nextDate = function nextDate(date) {
7820
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
7821
-
7822
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
7823
- };
7824
-
7825
- var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
7826
- var result = new Date(year, month, 1);
7827
- var day = result.getDay();
7828
-
7829
- if (day === 0) {
7830
- return prevDate(result, 7);
7831
- } else {
7832
- return prevDate(result, day);
7833
- }
7834
- };
7835
-
7836
- var getWeekNumber = function getWeekNumber(date) {
7837
- // 支持多种输入类型
7838
- if (!date || !isDate(date)) {
7839
- date = new Date();
7840
- }
7841
- if (typeof date === 'string') {
7842
- date = new Date(date);
7843
- }
7844
-
7845
- // 验证日期有效性
7846
- if (!isDate(date)) return null;
7847
-
7848
- var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
7849
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
7850
- // 将星期日的星期数设为7
7851
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
7852
- // 获取当年的第一天
7853
- var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
7854
- // 计算到最近的星期四的完整周数
7855
- var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
7856
- // 返回周数
7857
- return weekNo;
7858
- };
7859
-
7860
- var getRangeHours = function getRangeHours(ranges) {
7861
- var hours = [];
7862
- var disabledHours = [];
7863
-
7864
- (ranges || []).forEach(function (range) {
7865
- var value = range.map(function (date) {
7866
- return date.getHours();
7867
- });
7868
-
7869
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
7870
- });
7871
-
7872
- if (disabledHours.length) {
7873
- for (var i = 0; i < 24; i++) {
7874
- hours[i] = disabledHours.indexOf(i) === -1;
7875
- }
7876
- } else {
7877
- for (var _i = 0; _i < 24; _i++) {
7878
- hours[_i] = false;
7879
- }
7880
- }
7881
-
7882
- return hours;
7883
- };
7884
-
7885
- var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
7886
- if (amount <= 0) return [];
7887
- var temp = new Date(date.getTime());
7888
- temp.setDate(0);
7889
- var lastDay = temp.getDate();
7890
- return range(amount).map(function (_, index) {
7891
- return lastDay - (amount - index - 1);
7892
- });
7893
- };
7894
-
7895
- var getMonthDays = function getMonthDays(date) {
7896
- var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
7897
- var days = temp.getDate();
7898
- return range(days).map(function (_, index) {
7899
- return index + 1;
7900
- });
7901
- };
7902
-
7903
- function setRangeData(arr, start, end, value) {
7904
- for (var i = start; i < end; i++) {
7905
- arr[i] = value;
7906
- }
7907
- }
7908
-
7909
- var getRangeMinutes = function getRangeMinutes(ranges, hour) {
7910
- var minutes = new Array(60);
7911
-
7912
- if (ranges.length > 0) {
7913
- ranges.forEach(function (range) {
7914
- var start = range[0];
7915
- var end = range[1];
7916
- var startHour = start.getHours();
7917
- var startMinute = start.getMinutes();
7918
- var endHour = end.getHours();
7919
- var endMinute = end.getMinutes();
7920
- if (startHour === hour && endHour !== hour) {
7921
- setRangeData(minutes, startMinute, 60, true);
7922
- } else if (startHour === hour && endHour === hour) {
7923
- setRangeData(minutes, startMinute, endMinute + 1, true);
7924
- } else if (startHour !== hour && endHour === hour) {
7925
- setRangeData(minutes, 0, endMinute + 1, true);
7926
- } else if (startHour < hour && endHour > hour) {
7927
- setRangeData(minutes, 0, 60, true);
7928
- }
7929
- });
7930
- } else {
7931
- setRangeData(minutes, 0, 60, true);
7932
- }
7933
- return minutes;
7934
- };
7935
-
7936
- var range = function range(n) {
7937
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
7938
- return Array.apply(null, { length: n }).map(function (_, n) {
7939
- return n;
7940
- });
7941
- };
7942
-
7943
- var modifyDate = function modifyDate(date, y, m, d) {
7944
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
7945
- };
7946
-
7947
- var modifyTime = function modifyTime(date, h, m, s) {
7948
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
7949
- };
7950
-
7951
- var modifyWithTimeString = function modifyWithTimeString(date, time) {
7952
- if (date == null || !time) {
7953
- return date;
7954
- }
7955
- time = parseDate(time, 'HH:mm:ss');
7956
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
7957
- };
7958
-
7959
- var clearTime = function clearTime(date) {
7960
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
7961
- };
7962
-
7963
- var clearMilliseconds = function clearMilliseconds(date) {
7964
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
7965
- };
7966
-
7967
- var limitTimeRange = function limitTimeRange(date, ranges) {
7968
- var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
7969
-
7970
- // TODO: refactory a more elegant solution
7971
- if (ranges.length === 0) return date;
7972
- var normalizeDate = function normalizeDate(date) {
7973
- return fecha.parse(fecha.format(date, format), format);
7974
- };
7975
- var ndate = normalizeDate(date);
7976
- var nranges = ranges.map(function (range) {
7977
- return range.map(normalizeDate);
7978
- });
7979
- if (nranges.some(function (nrange) {
7980
- return ndate >= nrange[0] && ndate <= nrange[1];
7981
- })) return date;
7982
-
7983
- var minDate = nranges[0][0];
7984
- var maxDate = nranges[0][0];
7985
-
7986
- nranges.forEach(function (nrange) {
7987
- minDate = new Date(Math.min(nrange[0], minDate));
7988
- maxDate = new Date(Math.max(nrange[1], minDate));
7989
- });
7990
-
7991
- var ret = ndate < minDate ? minDate : maxDate;
7992
- // preserve Year/Month/Date
7993
- return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
7994
- };
7995
-
7996
- var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
7997
- var limitedDate = limitTimeRange(date, selectableRange, format);
7998
- return limitedDate.getTime() === date.getTime();
7999
- };
8000
-
8001
- var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
8002
- // clamp date to the number of days in `year`, `month`
8003
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
8004
- var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
8005
- return modifyDate(date, year, month, monthDate);
8006
- };
8007
-
8008
- var prevMonth = function prevMonth(date) {
8009
- var year = date.getFullYear();
8010
- var month = date.getMonth();
8011
- return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
8012
- };
8013
-
8014
- var nextMonth = function nextMonth(date) {
8015
- var year = date.getFullYear();
8016
- var month = date.getMonth();
8017
- return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
8018
- };
8019
-
8020
- var prevYear = function prevYear(date) {
8021
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
8022
-
8023
- var year = date.getFullYear();
8024
- var month = date.getMonth();
8025
- return changeYearMonthAndClampDate(date, year - amount, month);
8026
- };
8027
-
8028
- var nextYear = function nextYear(date) {
8029
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
8030
-
8031
- var year = date.getFullYear();
8032
- var month = date.getMonth();
8033
- return changeYearMonthAndClampDate(date, year + amount, month);
8034
- };
8035
-
8036
- var extractDateFormat = function extractDateFormat(format) {
8037
- return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
8038
- };
8039
-
8040
- var extractTimeFormat = function extractTimeFormat(format) {
8041
- return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
8042
- };
8043
-
8044
- var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
8045
- return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
8046
- };
8047
-
7681
+ */
7682
+ fecha.parse = function (dateStr, format) {
7683
+ if (typeof format !== 'string') {
7684
+ throw new Error('Invalid format in fecha.parse');
7685
+ }
7686
+
7687
+ format = fecha.masks[format] || format;
7688
+
7689
+ // Avoid regular expression denial of service, fail early for really long strings
7690
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
7691
+ if (dateStr.length > 1000) {
7692
+ return null;
7693
+ }
7694
+
7695
+ const dateInfo = {};
7696
+ const parseInfo = [];
7697
+ const literals = [];
7698
+ format = format.replace(literal, function($0, $1) {
7699
+ literals.push($1);
7700
+ return '@@@';
7701
+ });
7702
+ let newFormat = regexEscape(format).replace(token, function ($0) {
7703
+ if (parseFlags[$0]) {
7704
+ const info = parseFlags[$0];
7705
+ parseInfo.push(info[1]);
7706
+ return '(' + info[0] + ')';
7707
+ }
7708
+
7709
+ return $0;
7710
+ });
7711
+ newFormat = newFormat.replace(/@@@/g, function() {
7712
+ return literals.shift();
7713
+ });
7714
+ const matches = dateStr.match(new RegExp(newFormat, 'i'));
7715
+ if (!matches) {
7716
+ return null;
7717
+ }
7718
+
7719
+ for (let i = 1; i < matches.length; i++) {
7720
+ parseInfo[i - 1](dateInfo, matches[i]);
7721
+ }
7722
+
7723
+ const today = new Date();
7724
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
7725
+ dateInfo.hour = +dateInfo.hour + 12;
7726
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
7727
+ dateInfo.hour = 0;
7728
+ }
7729
+
7730
+ let date;
7731
+ if (dateInfo.timezoneOffset != null) {
7732
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
7733
+ date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
7734
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
7735
+ } else {
7736
+ date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
7737
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
7738
+ }
7739
+ return date;
7740
+ };
7741
+
7742
+ // 导出fecha对象
7743
+
7744
+
7745
+ // 以下是从date-util.js合并的函数
7746
+ const newArray = function(start, end) {
7747
+ let result = [];
7748
+ for (let i = start; i <= end; i++) {
7749
+ result.push(i);
7750
+ }
7751
+ return result;
7752
+ };
7753
+
7754
+ const getSettings = () => {
7755
+ return {
7756
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
7757
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
7758
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
7759
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
7760
+ amPm: ['上午', '下午']
7761
+ };
7762
+ };
7763
+
7764
+ const toDate = function(date) {
7765
+ return isDate(date) ? new Date(date) : null;
7766
+ };
7767
+
7768
+ const isDate = function(date) {
7769
+ if (date === null || date === undefined) return false;
7770
+ if (isNaN(new Date(date).getTime())) return false;
7771
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
7772
+ return true;
7773
+ };
7774
+
7775
+ const isDateObject = function(val) {
7776
+ return val instanceof Date;
7777
+ };
7778
+
7779
+ const formatDate = function (date, format = 'yyyy-MM-dd') {
7780
+ // 处理多种输入类型
7781
+ if (!date) return '';
7782
+
7783
+ // 如果是时间戳,转成日期对象
7784
+ if (typeof date === 'number') {
7785
+ date = new Date(date);
7786
+ }
7787
+ // 如果是字符串,转成日期对象
7788
+ if (typeof date === 'string') {
7789
+ date = new Date(date);
7790
+ }
7791
+
7792
+ // 调用toDate进一步验证和转换
7793
+ date = toDate(date);
7794
+ if (!date) return '';
7795
+
7796
+ // 兼容大写和小写的格式标记
7797
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
7798
+ const lowercaseFormat = format
7799
+ .replace(/YYYY/g, 'yyyy')
7800
+ .replace(/D/g, 'd')
7801
+
7802
+ // 使用fecha库进行格式化,支持中文配置
7803
+ const str = fecha.format(date, lowercaseFormat, getSettings());
7804
+ return str;
7805
+ };
7806
+
7807
+ const parseDate = function(string, format) {
7808
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
7809
+ };
7810
+
7811
+ const getDayCountOfMonth = function(year, month) {
7812
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
7813
+ return 30;
7814
+ }
7815
+
7816
+ if (month === 1) {
7817
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
7818
+ return 29;
7819
+ } else {
7820
+ return 28;
7821
+ }
7822
+ }
7823
+
7824
+ return 31;
7825
+ };
7826
+
7827
+ const getDayCountOfYear = function(year) {
7828
+ const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
7829
+ return isLeapYear ? 366 : 365;
7830
+ };
7831
+
7832
+ const getFirstDayOfMonth = function(date) {
7833
+ const temp = new Date(date.getTime());
7834
+ temp.setDate(1);
7835
+ return temp.getDay();
7836
+ };
7837
+
7838
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
7839
+ // {prev, next} Date should work for Daylight Saving Time
7840
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
7841
+ const prevDate = function(date, amount = 1) {
7842
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
7843
+ };
7844
+
7845
+ const nextDate = function(date, amount = 1) {
7846
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
7847
+ };
7848
+
7849
+ const getStartDateOfMonth = function(year, month) {
7850
+ const result = new Date(year, month, 1);
7851
+ const day = result.getDay();
7852
+
7853
+ if (day === 0) {
7854
+ return prevDate(result, 7);
7855
+ } else {
7856
+ return prevDate(result, day);
7857
+ }
7858
+ };
7859
+
7860
+ const getWeekNumber = function(date) {
7861
+ // 支持多种输入类型
7862
+ if (!date||!isDate(date)) {
7863
+ date = new Date();
7864
+ }
7865
+ if (typeof date === 'string') {
7866
+ date = new Date(date);
7867
+ }
7868
+
7869
+ // 验证日期有效性
7870
+ if (!isDate(date)) return null;
7871
+
7872
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
7873
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
7874
+ // 将星期日的星期数设为7
7875
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
7876
+ // 获取当年的第一天
7877
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
7878
+ // 计算到最近的星期四的完整周数
7879
+ const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
7880
+ // 返回周数
7881
+ return weekNo;
7882
+ };
7883
+
7884
+ const getRangeHours = function(ranges) {
7885
+ const hours = [];
7886
+ let disabledHours = [];
7887
+
7888
+ (ranges || []).forEach(range => {
7889
+ const value = range.map(date => date.getHours());
7890
+
7891
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
7892
+ });
7893
+
7894
+ if (disabledHours.length) {
7895
+ for (let i = 0; i < 24; i++) {
7896
+ hours[i] = disabledHours.indexOf(i) === -1;
7897
+ }
7898
+ } else {
7899
+ for (let i = 0; i < 24; i++) {
7900
+ hours[i] = false;
7901
+ }
7902
+ }
7903
+
7904
+ return hours;
7905
+ };
7906
+
7907
+ const getPrevMonthLastDays = (date, amount) => {
7908
+ if (amount <= 0) return [];
7909
+ const temp = new Date(date.getTime());
7910
+ temp.setDate(0);
7911
+ const lastDay = temp.getDate();
7912
+ return range(amount).map((_, index) => lastDay - (amount - index - 1));
7913
+ };
7914
+
7915
+ const getMonthDays = (date) => {
7916
+ const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
7917
+ const days = temp.getDate();
7918
+ return range(days).map((_, index) => index + 1);
7919
+ };
7920
+
7921
+ function setRangeData(arr, start, end, value) {
7922
+ for (let i = start; i < end; i++) {
7923
+ arr[i] = value;
7924
+ }
7925
+ }
7926
+
7927
+ const getRangeMinutes = function(ranges, hour) {
7928
+ const minutes = new Array(60);
7929
+
7930
+ if (ranges.length > 0) {
7931
+ ranges.forEach(range => {
7932
+ const start = range[0];
7933
+ const end = range[1];
7934
+ const startHour = start.getHours();
7935
+ const startMinute = start.getMinutes();
7936
+ const endHour = end.getHours();
7937
+ const endMinute = end.getMinutes();
7938
+ if (startHour === hour && endHour !== hour) {
7939
+ setRangeData(minutes, startMinute, 60, true);
7940
+ } else if (startHour === hour && endHour === hour) {
7941
+ setRangeData(minutes, startMinute, endMinute + 1, true);
7942
+ } else if (startHour !== hour && endHour === hour) {
7943
+ setRangeData(minutes, 0, endMinute + 1, true);
7944
+ } else if (startHour < hour && endHour > hour) {
7945
+ setRangeData(minutes, 0, 60, true);
7946
+ }
7947
+ });
7948
+ } else {
7949
+ setRangeData(minutes, 0, 60, true);
7950
+ }
7951
+ return minutes;
7952
+ };
7953
+
7954
+ const range = function(n) {
7955
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
7956
+ return Array.apply(null, {length: n}).map((_, n) => n);
7957
+ };
7958
+
7959
+ const modifyDate = function(date, y, m, d) {
7960
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
7961
+ };
7962
+
7963
+ const modifyTime = function(date, h, m, s) {
7964
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
7965
+ };
7966
+
7967
+ const modifyWithTimeString = (date, time) => {
7968
+ if (date == null || !time) {
7969
+ return date;
7970
+ }
7971
+ time = parseDate(time, 'HH:mm:ss');
7972
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
7973
+ };
7974
+
7975
+ const clearTime = function(date) {
7976
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
7977
+ };
7978
+
7979
+ const clearMilliseconds = function(date) {
7980
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
7981
+ };
7982
+
7983
+ const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
7984
+ // TODO: refactory a more elegant solution
7985
+ if (ranges.length === 0) return date;
7986
+ const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
7987
+ const ndate = normalizeDate(date);
7988
+ const nranges = ranges.map(range => range.map(normalizeDate));
7989
+ if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
7990
+
7991
+ let minDate = nranges[0][0];
7992
+ let maxDate = nranges[0][0];
7993
+
7994
+ nranges.forEach(nrange => {
7995
+ minDate = new Date(Math.min(nrange[0], minDate));
7996
+ maxDate = new Date(Math.max(nrange[1], minDate));
7997
+ });
7998
+
7999
+ const ret = ndate < minDate ? minDate : maxDate;
8000
+ // preserve Year/Month/Date
8001
+ return modifyDate(
8002
+ ret,
8003
+ date.getFullYear(),
8004
+ date.getMonth(),
8005
+ date.getDate()
8006
+ );
8007
+ };
8008
+
8009
+ const timeWithinRange = function(date, selectableRange, format) {
8010
+ const limitedDate = limitTimeRange(date, selectableRange, format);
8011
+ return limitedDate.getTime() === date.getTime();
8012
+ };
8013
+
8014
+ const changeYearMonthAndClampDate = function(date, year, month) {
8015
+ // clamp date to the number of days in `year`, `month`
8016
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
8017
+ const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
8018
+ return modifyDate(date, year, month, monthDate);
8019
+ };
8020
+
8021
+ const prevMonth = function(date) {
8022
+ const year = date.getFullYear();
8023
+ const month = date.getMonth();
8024
+ return month === 0
8025
+ ? changeYearMonthAndClampDate(date, year - 1, 11)
8026
+ : changeYearMonthAndClampDate(date, year, month - 1);
8027
+ };
8028
+
8029
+ const nextMonth = function(date) {
8030
+ const year = date.getFullYear();
8031
+ const month = date.getMonth();
8032
+ return month === 11
8033
+ ? changeYearMonthAndClampDate(date, year + 1, 0)
8034
+ : changeYearMonthAndClampDate(date, year, month + 1);
8035
+ };
8036
+
8037
+ const prevYear = function(date, amount = 1) {
8038
+ const year = date.getFullYear();
8039
+ const month = date.getMonth();
8040
+ return changeYearMonthAndClampDate(date, year - amount, month);
8041
+ };
8042
+
8043
+ const nextYear = function(date, amount = 1) {
8044
+ const year = date.getFullYear();
8045
+ const month = date.getMonth();
8046
+ return changeYearMonthAndClampDate(date, year + amount, month);
8047
+ };
8048
+
8049
+ const extractDateFormat = function(format) {
8050
+ return format
8051
+ .replace(/\W?m{1,2}|\W?ZZ/g, '')
8052
+ .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
8053
+ .trim();
8054
+ };
8055
+
8056
+ const extractTimeFormat = function(format) {
8057
+ return format
8058
+ .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
8059
+ .trim();
8060
+ };
8061
+
8062
+ const validateRangeInOneMonth = function(start, end) {
8063
+ return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
8064
+ };
8065
+
8048
8066
  /**
8049
8067
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
8050
8068
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
8051
8069
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
8052
8070
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
8053
8071
  * @returns {number} 工作日数量
8054
- */
8055
- var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
8056
- var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
8057
-
8058
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
8059
- throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
8060
- }
8061
-
8062
- var startDateObj = new Date(start_date);
8063
- var endDateObj = new Date(end_date);
8064
-
8065
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
8066
- throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
8067
- }
8068
-
8069
- if (startDateObj > endDateObj) {
8070
- throw new Error('Start date should be earlier than or equal to end date.');
8071
- }
8072
-
8073
- var workdays = 0;
8074
-
8075
- // Iterate through each day in the date range
8076
-
8077
- var _loop = function _loop(currentDate) {
8078
- // Check if the current day is a weekend (Saturday or Sunday)
8079
- var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
8080
-
8081
- // Check if the current day is a holiday
8082
- var isHoliday = holidays.some(function (holiday) {
8083
- var holidayDate = new Date(holiday);
8084
- return currentDate.toDateString() === holidayDate.toDateString();
8085
- });
8086
-
8087
- // If it's a workday (not a weekend or holiday), increment the workdays count
8088
- if (!isWeekend && !isHoliday) {
8089
- workdays++;
8090
- }
8091
- };
8092
-
8093
- for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
8094
- _loop(currentDate);
8095
- }
8096
-
8097
- return workdays;
8098
- };
8099
-
8072
+ */
8073
+ const calculateNetworkDays = function (start_date, end_date, holidays = []) {
8074
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
8075
+ throw new Error(
8076
+ "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
8077
+ );
8078
+ }
8079
+
8080
+ const startDateObj = new Date(start_date);
8081
+ const endDateObj = new Date(end_date);
8082
+
8083
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
8084
+ throw new Error(
8085
+ "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
8086
+ );
8087
+ }
8088
+
8089
+ if (startDateObj > endDateObj) {
8090
+ throw new Error('Start date should be earlier than or equal to end date.');
8091
+ }
8092
+
8093
+ let workdays = 0;
8094
+
8095
+ // Iterate through each day in the date range
8096
+ for (
8097
+ let currentDate = new Date(startDateObj);
8098
+ currentDate <= endDateObj;
8099
+ currentDate.setDate(currentDate.getDate() + 1)
8100
+ ) {
8101
+ // Check if the current day is a weekend (Saturday or Sunday)
8102
+ const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
8103
+
8104
+ // Check if the current day is a holiday
8105
+ const isHoliday = holidays.some((holiday) => {
8106
+ const holidayDate = new Date(holiday);
8107
+ return currentDate.toDateString() === holidayDate.toDateString();
8108
+ });
8109
+
8110
+ // If it's a workday (not a weekend or holiday), increment the workdays count
8111
+ if (!isWeekend && !isHoliday) {
8112
+ workdays++;
8113
+ }
8114
+ }
8115
+
8116
+ return workdays;
8117
+ };
8118
+
8100
8119
  /**
8101
8120
  * 日期加减天数
8102
8121
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
8103
8122
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
8104
8123
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
8105
- */
8106
- var dateAddDays = function dateAddDays(start_date, days) {
8107
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
8108
- 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.");
8109
- }
8110
-
8111
- var startDateObj = new Date(start_date);
8112
- if (isNaN(startDateObj.getTime())) {
8113
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
8114
- }
8115
-
8116
- var resultDateObj = new Date(startDateObj);
8117
- resultDateObj.setDate(resultDateObj.getDate() + days);
8118
-
8119
- var resultYear = resultDateObj.getFullYear();
8120
- var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
8121
- var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
8122
-
8123
- return resultYear + '-' + resultMonth + '-' + resultDay;
8124
- };
8125
-
8124
+ */
8125
+ const dateAddDays = function (start_date, days) {
8126
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
8127
+ throw new Error(
8128
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
8129
+ );
8130
+ }
8131
+
8132
+ const startDateObj = new Date(start_date);
8133
+ if (isNaN(startDateObj.getTime())) {
8134
+ throw new Error(
8135
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
8136
+ );
8137
+ }
8138
+
8139
+ const resultDateObj = new Date(startDateObj);
8140
+ resultDateObj.setDate(resultDateObj.getDate() + days);
8141
+
8142
+ const resultYear = resultDateObj.getFullYear();
8143
+ const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
8144
+ const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
8145
+
8146
+ return `${resultYear}-${resultMonth}-${resultDay}`;
8147
+ };
8148
+
8126
8149
  /**
8127
8150
  * 计算两个日期之间的差值
8128
8151
  * @date 2023年12月14日
@@ -8130,180 +8153,182 @@ var dateAddDays = function dateAddDays(start_date, days) {
8130
8153
  * @param {String} end_date - 结束日期字符串
8131
8154
  * @param {String} unit - 单位:year/month/day
8132
8155
  * @returns {Number} 差值
8133
- */
8134
- var dateDiff = function dateDiff(start_date, end_date) {
8135
- var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
8136
-
8137
- // Assuming date strings are in "YYYY-MM-DD" format
8138
- var startDate = new Date(start_date);
8139
- var endDate = new Date(end_date);
8140
-
8141
- // If the date is invalid, return 0
8142
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
8143
- return 0;
8144
- }
8145
-
8146
- if (unit === 'year') {
8147
- return endDate.getFullYear() - startDate.getFullYear();
8148
- } else if (unit === 'month') {
8149
- return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
8150
- } else {
8151
- // Default to day
8152
- var timeDifference = endDate - startDate;
8153
- // Calculate days (86400000 milliseconds per day)
8154
- return Math.floor(timeDifference / 86400000);
8155
- }
8156
- };
8157
-
8156
+ */
8157
+ const dateDiff = function (start_date, end_date, unit = 'day') {
8158
+ // Assuming date strings are in "YYYY-MM-DD" format
8159
+ var startDate = new Date(start_date);
8160
+ var endDate = new Date(end_date);
8161
+
8162
+ // If the date is invalid, return 0
8163
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
8164
+ return 0;
8165
+ }
8166
+
8167
+ if (unit === 'year') {
8168
+ return endDate.getFullYear() - startDate.getFullYear();
8169
+ } else if (unit === 'month') {
8170
+ return (
8171
+ (endDate.getFullYear() - startDate.getFullYear()) * 12 +
8172
+ (endDate.getMonth() - startDate.getMonth())
8173
+ );
8174
+ } else {
8175
+ // Default to day
8176
+ var timeDifference = endDate - startDate;
8177
+ // Calculate days (86400000 milliseconds per day)
8178
+ return Math.floor(timeDifference / 86400000);
8179
+ }
8180
+ };
8181
+
8158
8182
  /**
8159
8183
  * 获取月份中的日期
8160
8184
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
8161
8185
  * @returns {number} 月份中的日期(1-31)
8162
- */
8163
- var dayOfMonth = function dayOfMonth(date) {
8164
- if (typeof date !== 'string') {
8165
- throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
8166
- }
8167
-
8168
- var dateObj = new Date(date);
8169
- if (isNaN(dateObj.getTime())) {
8170
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
8171
- }
8172
-
8173
- return dateObj.getDate();
8174
- };
8175
-
8186
+ */
8187
+ const dayOfMonth = function (date) {
8188
+ if (typeof date !== 'string') {
8189
+ throw new Error(
8190
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
8191
+ );
8192
+ }
8193
+
8194
+ const dateObj = new Date(date);
8195
+ if (isNaN(dateObj.getTime())) {
8196
+ throw new Error(
8197
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
8198
+ );
8199
+ }
8200
+
8201
+ return dateObj.getDate();
8202
+ };
8203
+
8176
8204
  /**
8177
8205
  * 获取当前日期
8178
8206
  * @date 2022年5月7日
8179
8207
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
8180
8208
  * @returns {string} 当前日期的格式化字符串
8181
- */
8182
- var getCurrentDate = function getCurrentDate() {
8183
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
8184
-
8185
- return formatDate(new Date(), format);
8186
- };
8187
-
8209
+ */
8210
+ const getCurrentDate = function (format = 'YYYY-MM-DD') {
8211
+ return formatDate(new Date(), format);
8212
+ };
8213
+
8188
8214
  /**
8189
8215
  * 获取当前日期时间
8190
8216
  * @date 2022年5月7日
8191
8217
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
8192
8218
  * @returns {string} 当前日期时间的格式化字符串
8193
- */
8194
- var getCurrentDateTime = function getCurrentDateTime() {
8195
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
8196
-
8197
- return formatDate(new Date(), format);
8198
- };
8199
-
8219
+ */
8220
+ const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
8221
+ return formatDate(new Date(), format);
8222
+ };
8223
+
8200
8224
  /**
8201
8225
  * 获取小时
8202
8226
  * @date 2022年5月7日
8203
8227
  * @param {Date|string} [date] - 日期对象或日期字符串
8204
8228
  * @returns {number} 小时数(0-23)
8205
- */
8206
- var getHour = function getHour(date) {
8207
- if (!date) {
8208
- return new Date().getHours();
8209
- }
8210
- if (typeof date === 'string') {
8211
- date = new Date(date);
8212
- }
8213
- return date.getHours();
8214
- };
8215
-
8229
+ */
8230
+ const getHour = function (date) {
8231
+ if (!date) {
8232
+ return new Date().getHours();
8233
+ }
8234
+ if (typeof date === 'string') {
8235
+ date = new Date(date);
8236
+ }
8237
+ return date.getHours();
8238
+ };
8239
+
8216
8240
  /**
8217
8241
  * 获取分钟
8218
8242
  * @date 2022年5月7日
8219
8243
  * @param {Date|string} [date] - 日期对象或日期字符串
8220
8244
  * @returns {number} 分钟数(0-59)
8221
- */
8222
- var getMinute = function getMinute(date) {
8223
- if (!date) {
8224
- return new Date().getMinutes();
8225
- }
8226
- if (typeof date === 'string') {
8227
- date = new Date(date);
8228
- }
8229
- return date.getMinutes();
8230
- };
8231
-
8245
+ */
8246
+ const getMinute = function (date) {
8247
+ if (!date) {
8248
+ return new Date().getMinutes();
8249
+ }
8250
+ if (typeof date === 'string') {
8251
+ date = new Date(date);
8252
+ }
8253
+ return date.getMinutes();
8254
+ };
8255
+
8232
8256
  /**
8233
8257
  * 获取月份
8234
8258
  * @date 2022年5月7日
8235
8259
  * @param {Date|string} [date] - 日期对象或日期字符串
8236
8260
  * @returns {number} 月份数(1-12)
8237
- */
8238
- var getMonth = function getMonth(date) {
8239
- if (!date) {
8240
- return new Date().getMonth() + 1;
8241
- }
8242
- if (typeof date === 'string') {
8243
- date = new Date(date);
8244
- }
8245
- return date.getMonth() + 1;
8246
- };
8247
-
8261
+ */
8262
+ const getMonth = function (date) {
8263
+ if (!date) {
8264
+ return new Date().getMonth() + 1;
8265
+ }
8266
+ if (typeof date === 'string') {
8267
+ date = new Date(date);
8268
+ }
8269
+ return date.getMonth() + 1;
8270
+ };
8271
+
8248
8272
  /**
8249
8273
  * 获取秒
8250
8274
  * @date 2022年5月7日
8251
8275
  * @param {Date|string} [date] - 日期对象或日期字符串
8252
8276
  * @returns {number} 秒数(0-59)
8253
- */
8254
- var getSecond = function getSecond(date) {
8255
- if (!date) {
8256
- return new Date().getSeconds();
8257
- }
8258
- if (typeof date === 'string') {
8259
- date = new Date(date);
8260
- }
8261
- return date.getSeconds();
8262
- };
8263
-
8277
+ */
8278
+ const getSecond = function (date) {
8279
+ if (!date) {
8280
+ return new Date().getSeconds();
8281
+ }
8282
+ if (typeof date === 'string') {
8283
+ date = new Date(date);
8284
+ }
8285
+ return date.getSeconds();
8286
+ };
8287
+
8264
8288
  /**
8265
8289
  * 获取星期几
8266
8290
  * @date 2022年5月7日
8267
8291
  * @param {Date|string} [date] - 日期对象或日期字符串
8268
8292
  * @returns {number} 星期几(0-6,0表示星期日)
8269
- */
8270
- var getWeekday = function getWeekday(date) {
8271
- if (!date) {
8272
- return new Date().getDay();
8273
- }
8274
- if (typeof date === 'string') {
8275
- date = new Date(date);
8276
- }
8277
- return date.getDay();
8278
- };
8279
-
8293
+ */
8294
+ const getWeekday = function (date) {
8295
+ if (!date) {
8296
+ return new Date().getDay();
8297
+ }
8298
+ if (typeof date === 'string') {
8299
+ date = new Date(date);
8300
+ }
8301
+ return date.getDay();
8302
+ };
8303
+
8304
+
8280
8305
  /**
8281
8306
  * @desc 获取上午/下午/晚上
8282
8307
  * @author huangbo
8283
8308
  * @date 2022年5月7日
8284
8309
  * @param {String} [time] - 时间
8285
- **/
8286
- var timeCycle = function timeCycle(time) {
8287
- var hour = 0;
8288
- if (!time) {
8289
- hour = new Date().getHours();
8290
- } else if (typeof time === 'string') {
8291
- // 从时间字符串中提取小时
8292
- var match = time.match(/^(\d{1,2})/);
8293
- if (match) {
8294
- hour = parseInt(match[1], 10);
8295
- }
8296
- } else if (typeof time === 'number') {
8297
- hour = time;
8298
- }
8299
- // 判断时间段
8300
- if (hour >= 5 && hour < 12) {
8301
- return '上午';
8302
- } else if (hour >= 12 && hour < 18) {
8303
- return '下午';
8304
- } else {
8305
- return '晚上';
8306
- }
8310
+ **/
8311
+ const timeCycle = function (time) {
8312
+ let hour = 0;
8313
+ if (!time) {
8314
+ hour = new Date().getHours();
8315
+ } else if (typeof time === 'string') {
8316
+ // 从时间字符串中提取小时
8317
+ const match = time.match(/^(\d{1,2})/);
8318
+ if (match) {
8319
+ hour = parseInt(match[1], 10);
8320
+ }
8321
+ } else if (typeof time === 'number') {
8322
+ hour = time;
8323
+ }
8324
+ // 判断时间段
8325
+ if (hour >= 5 && hour < 12) {
8326
+ return '上午';
8327
+ } else if (hour >= 12 && hour < 18) {
8328
+ return '下午';
8329
+ } else {
8330
+ return '晚上';
8331
+ }
8307
8332
  };
8308
8333
 
8309
8334
  /***/ }),