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/ca-login.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 = 206);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 208);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -3528,7 +3528,7 @@ module.exports = require("vue");
3528
3528
 
3529
3529
  /***/ }),
3530
3530
 
3531
- /***/ 206:
3531
+ /***/ 208:
3532
3532
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3533
3533
 
3534
3534
  "use strict";
@@ -5351,736 +5351,759 @@ function normalizeComponent(
5351
5351
  /* unused harmony export getSecond */
5352
5352
  /* unused harmony export getWeekday */
5353
5353
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
5354
-
5355
-
5354
+ /* Modified from https://github.com/taylorhakes/fecha
5355
+ *
5356
+ * The MIT License (MIT)
5357
+ *
5358
+ * Copyright (c) 2015 Taylor Hakes
5359
+ *
5360
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5361
+ * of this software and associated documentation files (the "Software"), to deal
5362
+ * in the Software without restriction, including without limitation the rights
5363
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5364
+ * copies of the Software, and to permit persons to whom the Software is
5365
+ * furnished to do so, subject to the following conditions:
5366
+ *
5367
+ * The above copyright notice and this permission notice shall be included in all
5368
+ * copies or substantial portions of the Software.
5369
+ *
5370
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5371
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5372
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5373
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5374
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5375
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
5376
+ * SOFTWARE.
5377
+ */
5378
+
5379
+ /*eslint-disable*/
5380
+ // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
5381
+
5382
+
5356
5383
  /**
5357
5384
  * Parse or format dates
5358
5385
  * @class fecha
5359
- */
5360
- var fecha = {};
5361
- var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
5362
- var twoDigits = '\\d\\d?';
5363
- var threeDigits = '\\d{3}';
5364
- var fourDigits = '\\d{4}';
5365
- var word = '[^\\s]+';
5366
- var literal = /\[([^]*?)\]/gm;
5367
- var noop = function noop() {};
5368
-
5369
- function regexEscape(str) {
5370
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
5371
- }
5372
-
5373
- function shorten(arr, sLen) {
5374
- var newArr = [];
5375
- for (var i = 0, len = arr.length; i < len; i++) {
5376
- newArr.push(arr[i].substr(0, sLen));
5377
- }
5378
- return newArr;
5379
- }
5380
-
5381
- function monthUpdate() {
5382
- return function (d, v) {
5383
- var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
5384
- if (~index) {
5385
- d.month = index;
5386
- }
5387
- };
5388
- }
5389
-
5390
- function pad(val, len) {
5391
- val = String(val);
5392
- len = len || 2;
5393
- while (val.length < len) {
5394
- val = '0' + val;
5395
- }
5396
- return val;
5397
- }
5398
-
5399
- // 直接使用中文日期名称常量
5400
- var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
5401
- var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
5402
- var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
5403
- var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
5404
- var amPm = ['上午', '下午'];
5405
- var DoFn = function DoFn(D) {
5406
- return D + '日';
5407
- };
5408
-
5409
- var formatFlags = {
5410
- D: function D(dateObj) {
5411
- return dateObj.getDay();
5412
- },
5413
- DD: function DD(dateObj) {
5414
- return pad(dateObj.getDay());
5415
- },
5416
- Do: function Do(dateObj) {
5417
- return DoFn(dateObj.getDate());
5418
- },
5419
- d: function d(dateObj) {
5420
- return dateObj.getDate();
5421
- },
5422
- dd: function dd(dateObj) {
5423
- return pad(dateObj.getDate());
5424
- },
5425
- ddd: function ddd(dateObj) {
5426
- return dayNamesShort[dateObj.getDay()];
5427
- },
5428
- dddd: function dddd(dateObj) {
5429
- return dayNames[dateObj.getDay()];
5430
- },
5431
- M: function M(dateObj) {
5432
- return dateObj.getMonth() + 1;
5433
- },
5434
- MM: function MM(dateObj) {
5435
- return pad(dateObj.getMonth() + 1);
5436
- },
5437
- MMM: function MMM(dateObj) {
5438
- return monthNamesShort[dateObj.getMonth()];
5439
- },
5440
- MMMM: function MMMM(dateObj) {
5441
- return monthNames[dateObj.getMonth()];
5442
- },
5443
- yy: function yy(dateObj) {
5444
- return pad(String(dateObj.getFullYear()), 4).substr(2);
5445
- },
5446
- yyyy: function yyyy(dateObj) {
5447
- return pad(dateObj.getFullYear(), 4);
5448
- },
5449
- h: function h(dateObj) {
5450
- return dateObj.getHours() % 12 || 12;
5451
- },
5452
- hh: function hh(dateObj) {
5453
- return pad(dateObj.getHours() % 12 || 12);
5454
- },
5455
- H: function H(dateObj) {
5456
- return dateObj.getHours();
5457
- },
5458
- HH: function HH(dateObj) {
5459
- return pad(dateObj.getHours());
5460
- },
5461
- m: function m(dateObj) {
5462
- return dateObj.getMinutes();
5463
- },
5464
- mm: function mm(dateObj) {
5465
- return pad(dateObj.getMinutes());
5466
- },
5467
- s: function s(dateObj) {
5468
- return dateObj.getSeconds();
5469
- },
5470
- ss: function ss(dateObj) {
5471
- return pad(dateObj.getSeconds());
5472
- },
5473
- S: function S(dateObj) {
5474
- return Math.round(dateObj.getMilliseconds() / 100);
5475
- },
5476
- SS: function SS(dateObj) {
5477
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
5478
- },
5479
- SSS: function SSS(dateObj) {
5480
- return pad(dateObj.getMilliseconds(), 3);
5481
- },
5482
- a: function a(dateObj) {
5483
- return dateObj.getHours() < 12 ? '上午' : '下午';
5484
- },
5485
- A: function A(dateObj) {
5486
- return dateObj.getHours() < 12 ? '上午' : '下午';
5487
- },
5488
- ZZ: function ZZ(dateObj) {
5489
- var o = dateObj.getTimezoneOffset();
5490
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
5491
- }
5492
- };
5493
-
5494
- var parseFlags = {
5495
- d: [twoDigits, function (d, v) {
5496
- d.day = v;
5497
- }],
5498
- Do: [twoDigits + word, function (d, v) {
5499
- d.day = parseInt(v, 10);
5500
- }],
5501
- M: [twoDigits, function (d, v) {
5502
- d.month = v - 1;
5503
- }],
5504
- yy: [twoDigits, function (d, v) {
5505
- var da = new Date(),
5506
- cent = +('' + da.getFullYear()).substr(0, 2);
5507
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
5508
- }],
5509
- h: [twoDigits, function (d, v) {
5510
- d.hour = v;
5511
- }],
5512
- m: [twoDigits, function (d, v) {
5513
- d.minute = v;
5514
- }],
5515
- s: [twoDigits, function (d, v) {
5516
- d.second = v;
5517
- }],
5518
- yyyy: [fourDigits, function (d, v) {
5519
- d.year = v;
5520
- }],
5521
- S: ['\\d', function (d, v) {
5522
- d.millisecond = v * 100;
5523
- }],
5524
- SS: ['\\d{2}', function (d, v) {
5525
- d.millisecond = v * 10;
5526
- }],
5527
- SSS: [threeDigits, function (d, v) {
5528
- d.millisecond = v;
5529
- }],
5530
- D: [twoDigits, noop],
5531
- ddd: [word, noop],
5532
- MMM: [word, monthUpdate('monthNamesShort')],
5533
- MMMM: [word, monthUpdate('monthNames')],
5534
- a: [word, function (d, v) {
5535
- var val = v.toLowerCase();
5536
- if (val === '上午') {
5537
- d.isPm = false;
5538
- } else if (val === '下午') {
5539
- d.isPm = true;
5540
- }
5541
- }],
5542
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
5543
- var parts = (v + '').match(/([+-]|\d\d)/gi),
5544
- minutes = void 0;
5545
-
5546
- if (parts) {
5547
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
5548
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
5549
- }
5550
- }]
5551
- };
5552
- parseFlags.dd = parseFlags.d;
5553
- parseFlags.dddd = parseFlags.ddd;
5554
- parseFlags.DD = parseFlags.D;
5555
- parseFlags.mm = parseFlags.m;
5556
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
5557
- parseFlags.MM = parseFlags.M;
5558
- parseFlags.ss = parseFlags.s;
5559
- parseFlags.A = parseFlags.a;
5560
-
5561
- // Some common format strings
5562
- fecha.masks = {
5563
- default: 'ddd MMM dd yyyy HH:mm:ss',
5564
- shortDate: 'M/D/yy',
5565
- mediumDate: 'MMM d, yyyy',
5566
- longDate: 'MMMM d, yyyy',
5567
- fullDate: 'dddd, MMMM d, yyyy',
5568
- shortTime: 'HH:mm',
5569
- mediumTime: 'HH:mm:ss',
5570
- longTime: 'HH:mm:ss.SSS'
5571
- };
5572
-
5386
+ */
5387
+ const fecha = {};
5388
+ const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
5389
+ const twoDigits = '\\d\\d?';
5390
+ const threeDigits = '\\d{3}';
5391
+ const fourDigits = '\\d{4}';
5392
+ const word = '[^\\s]+';
5393
+ const literal = /\[([^]*?)\]/gm;
5394
+ const noop = function () {};
5395
+
5396
+ function regexEscape(str) {
5397
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
5398
+ }
5399
+
5400
+ function shorten(arr, sLen) {
5401
+ const newArr = [];
5402
+ for (let i = 0, len = arr.length; i < len; i++) {
5403
+ newArr.push(arr[i].substr(0, sLen));
5404
+ }
5405
+ return newArr;
5406
+ }
5407
+
5408
+ function monthUpdate() {
5409
+ return function (d, v) {
5410
+ const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
5411
+ if (~index) {
5412
+ d.month = index;
5413
+ }
5414
+ };
5415
+ }
5416
+
5417
+ function pad(val, len) {
5418
+ val = String(val);
5419
+ len = len || 2;
5420
+ while (val.length < len) {
5421
+ val = '0' + val;
5422
+ }
5423
+ return val;
5424
+ }
5425
+
5426
+ // 直接使用中文日期名称常量
5427
+ const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
5428
+ const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
5429
+ const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
5430
+ const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
5431
+ const amPm = ['上午', '下午'];
5432
+ const DoFn = function DoFn(D) {
5433
+ return D + '日';
5434
+ };
5435
+
5436
+ const formatFlags = {
5437
+ D: function(dateObj) {
5438
+ return dateObj.getDay();
5439
+ },
5440
+ DD: function(dateObj) {
5441
+ return pad(dateObj.getDay());
5442
+ },
5443
+ Do: function(dateObj) {
5444
+ return DoFn(dateObj.getDate());
5445
+ },
5446
+ d: function(dateObj) {
5447
+ return dateObj.getDate();
5448
+ },
5449
+ dd: function(dateObj) {
5450
+ return pad(dateObj.getDate());
5451
+ },
5452
+ ddd: function(dateObj) {
5453
+ return dayNamesShort[dateObj.getDay()];
5454
+ },
5455
+ dddd: function(dateObj) {
5456
+ return dayNames[dateObj.getDay()];
5457
+ },
5458
+ M: function(dateObj) {
5459
+ return dateObj.getMonth() + 1;
5460
+ },
5461
+ MM: function(dateObj) {
5462
+ return pad(dateObj.getMonth() + 1);
5463
+ },
5464
+ MMM: function(dateObj) {
5465
+ return monthNamesShort[dateObj.getMonth()];
5466
+ },
5467
+ MMMM: function(dateObj) {
5468
+ return monthNames[dateObj.getMonth()];
5469
+ },
5470
+ yy: function(dateObj) {
5471
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
5472
+ },
5473
+ yyyy: function(dateObj) {
5474
+ return pad(dateObj.getFullYear(), 4);
5475
+ },
5476
+ h: function(dateObj) {
5477
+ return dateObj.getHours() % 12 || 12;
5478
+ },
5479
+ hh: function(dateObj) {
5480
+ return pad(dateObj.getHours() % 12 || 12);
5481
+ },
5482
+ H: function(dateObj) {
5483
+ return dateObj.getHours();
5484
+ },
5485
+ HH: function(dateObj) {
5486
+ return pad(dateObj.getHours());
5487
+ },
5488
+ m: function(dateObj) {
5489
+ return dateObj.getMinutes();
5490
+ },
5491
+ mm: function(dateObj) {
5492
+ return pad(dateObj.getMinutes());
5493
+ },
5494
+ s: function(dateObj) {
5495
+ return dateObj.getSeconds();
5496
+ },
5497
+ ss: function(dateObj) {
5498
+ return pad(dateObj.getSeconds());
5499
+ },
5500
+ S: function(dateObj) {
5501
+ return Math.round(dateObj.getMilliseconds() / 100);
5502
+ },
5503
+ SS: function(dateObj) {
5504
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
5505
+ },
5506
+ SSS: function(dateObj) {
5507
+ return pad(dateObj.getMilliseconds(), 3);
5508
+ },
5509
+ a: function(dateObj) {
5510
+ return dateObj.getHours() < 12 ? '上午' : '下午';
5511
+ },
5512
+ A: function(dateObj) {
5513
+ return dateObj.getHours() < 12 ? '上午' : '下午';
5514
+ },
5515
+ ZZ: function(dateObj) {
5516
+ const o = dateObj.getTimezoneOffset();
5517
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
5518
+ }
5519
+ };
5520
+
5521
+ const parseFlags = {
5522
+ d: [twoDigits, function (d, v) {
5523
+ d.day = v;
5524
+ }],
5525
+ Do: [twoDigits + word, function (d, v) {
5526
+ d.day = parseInt(v, 10);
5527
+ }],
5528
+ M: [twoDigits, function (d, v) {
5529
+ d.month = v - 1;
5530
+ }],
5531
+ yy: [twoDigits, function (d, v) {
5532
+ const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
5533
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
5534
+ }],
5535
+ h: [twoDigits, function (d, v) {
5536
+ d.hour = v;
5537
+ }],
5538
+ m: [twoDigits, function (d, v) {
5539
+ d.minute = v;
5540
+ }],
5541
+ s: [twoDigits, function (d, v) {
5542
+ d.second = v;
5543
+ }],
5544
+ yyyy: [fourDigits, function (d, v) {
5545
+ d.year = v;
5546
+ }],
5547
+ S: ['\\d', function (d, v) {
5548
+ d.millisecond = v * 100;
5549
+ }],
5550
+ SS: ['\\d{2}', function (d, v) {
5551
+ d.millisecond = v * 10;
5552
+ }],
5553
+ SSS: [threeDigits, function (d, v) {
5554
+ d.millisecond = v;
5555
+ }],
5556
+ D: [twoDigits, noop],
5557
+ ddd: [word, noop],
5558
+ MMM: [word, monthUpdate('monthNamesShort')],
5559
+ MMMM: [word, monthUpdate('monthNames')],
5560
+ a: [word, function (d, v) {
5561
+ const val = v.toLowerCase();
5562
+ if (val === '上午') {
5563
+ d.isPm = false;
5564
+ } else if (val === '下午') {
5565
+ d.isPm = true;
5566
+ }
5567
+ }],
5568
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
5569
+ let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
5570
+
5571
+ if (parts) {
5572
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
5573
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
5574
+ }
5575
+ }]
5576
+ };
5577
+ parseFlags.dd = parseFlags.d;
5578
+ parseFlags.dddd = parseFlags.ddd;
5579
+ parseFlags.DD = parseFlags.D;
5580
+ parseFlags.mm = parseFlags.m;
5581
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
5582
+ parseFlags.MM = parseFlags.M;
5583
+ parseFlags.ss = parseFlags.s;
5584
+ parseFlags.A = parseFlags.a;
5585
+
5586
+
5587
+ // Some common format strings
5588
+ fecha.masks = {
5589
+ default: 'ddd MMM dd yyyy HH:mm:ss',
5590
+ shortDate: 'M/D/yy',
5591
+ mediumDate: 'MMM d, yyyy',
5592
+ longDate: 'MMMM d, yyyy',
5593
+ fullDate: 'dddd, MMMM d, yyyy',
5594
+ shortTime: 'HH:mm',
5595
+ mediumTime: 'HH:mm:ss',
5596
+ longTime: 'HH:mm:ss.SSS'
5597
+ };
5598
+
5573
5599
  /***
5574
5600
  * Format a date
5575
5601
  * @method format
5576
5602
  * @param {Date|number} dateObj
5577
5603
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
5578
- */
5579
- fecha.format = function (dateObj, mask) {
5580
- if (typeof dateObj === 'number') {
5581
- dateObj = new Date(dateObj);
5582
- }
5583
-
5584
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
5585
- throw new Error('Invalid Date in fecha.format');
5586
- }
5587
-
5588
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
5589
-
5590
- var literals = [];
5591
-
5592
- // Make literals inactive by replacing them with ??
5593
- mask = mask.replace(literal, function ($0, $1) {
5594
- literals.push($1);
5595
- return '@@@';
5596
- });
5597
- // Apply formatting rules
5598
- mask = mask.replace(token, function ($0) {
5599
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
5600
- });
5601
- // Inline literal values back into the formatted value
5602
- return mask.replace(/@@@/g, function () {
5603
- return literals.shift();
5604
- });
5605
- };
5606
-
5604
+ */
5605
+ fecha.format = function (dateObj, mask) {
5606
+ if (typeof dateObj === 'number') {
5607
+ dateObj = new Date(dateObj);
5608
+ }
5609
+
5610
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
5611
+ throw new Error('Invalid Date in fecha.format');
5612
+ }
5613
+
5614
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
5615
+
5616
+ const literals = [];
5617
+
5618
+ // Make literals inactive by replacing them with ??
5619
+ mask = mask.replace(literal, function($0, $1) {
5620
+ literals.push($1);
5621
+ return '@@@';
5622
+ });
5623
+ // Apply formatting rules
5624
+ mask = mask.replace(token, function ($0) {
5625
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
5626
+ });
5627
+ // Inline literal values back into the formatted value
5628
+ return mask.replace(/@@@/g, function() {
5629
+ return literals.shift();
5630
+ });
5631
+ };
5632
+
5607
5633
  /**
5608
5634
  * Parse a date string into an object, changes - into /
5609
5635
  * @method parse
5610
5636
  * @param {string} dateStr Date string
5611
5637
  * @param {string} format Date parse format
5612
5638
  * @returns {Date|boolean}
5613
- */
5614
- fecha.parse = function (dateStr, format) {
5615
- if (typeof format !== 'string') {
5616
- throw new Error('Invalid format in fecha.parse');
5617
- }
5618
-
5619
- format = fecha.masks[format] || format;
5620
-
5621
- // Avoid regular expression denial of service, fail early for really long strings
5622
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
5623
- if (dateStr.length > 1000) {
5624
- return null;
5625
- }
5626
-
5627
- var dateInfo = {};
5628
- var parseInfo = [];
5629
- var literals = [];
5630
- format = format.replace(literal, function ($0, $1) {
5631
- literals.push($1);
5632
- return '@@@';
5633
- });
5634
- var newFormat = regexEscape(format).replace(token, function ($0) {
5635
- if (parseFlags[$0]) {
5636
- var info = parseFlags[$0];
5637
- parseInfo.push(info[1]);
5638
- return '(' + info[0] + ')';
5639
- }
5640
-
5641
- return $0;
5642
- });
5643
- newFormat = newFormat.replace(/@@@/g, function () {
5644
- return literals.shift();
5645
- });
5646
- var matches = dateStr.match(new RegExp(newFormat, 'i'));
5647
- if (!matches) {
5648
- return null;
5649
- }
5650
-
5651
- for (var i = 1; i < matches.length; i++) {
5652
- parseInfo[i - 1](dateInfo, matches[i]);
5653
- }
5654
-
5655
- var today = new Date();
5656
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
5657
- dateInfo.hour = +dateInfo.hour + 12;
5658
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
5659
- dateInfo.hour = 0;
5660
- }
5661
-
5662
- var date = void 0;
5663
- if (dateInfo.timezoneOffset != null) {
5664
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
5665
- 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));
5666
- } else {
5667
- 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);
5668
- }
5669
- return date;
5670
- };
5671
-
5672
- // 导出fecha对象
5673
-
5674
-
5675
- // 以下是从date-util.js合并的函数
5676
- var newArray = function newArray(start, end) {
5677
- var result = [];
5678
- for (var i = start; i <= end; i++) {
5679
- result.push(i);
5680
- }
5681
- return result;
5682
- };
5683
-
5684
- var getSettings = function getSettings() {
5685
- return {
5686
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
5687
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
5688
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
5689
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
5690
- amPm: ['上午', '下午']
5691
- };
5692
- };
5693
-
5694
- var toDate = function toDate(date) {
5695
- return isDate(date) ? new Date(date) : null;
5696
- };
5697
-
5698
- var isDate = function isDate(date) {
5699
- if (date === null || date === undefined) return false;
5700
- if (isNaN(new Date(date).getTime())) return false;
5701
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
5702
- return true;
5703
- };
5704
-
5705
- var isDateObject = function isDateObject(val) {
5706
- return val instanceof Date;
5707
- };
5708
-
5709
- var formatDate = function formatDate(date) {
5710
- var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
5711
-
5712
- // 处理多种输入类型
5713
- if (!date) return '';
5714
-
5715
- // 如果是时间戳,转成日期对象
5716
- if (typeof date === 'number') {
5717
- date = new Date(date);
5718
- }
5719
- // 如果是字符串,转成日期对象
5720
- if (typeof date === 'string') {
5721
- date = new Date(date);
5722
- }
5723
-
5724
- // 调用toDate进一步验证和转换
5725
- date = toDate(date);
5726
- if (!date) return '';
5727
-
5728
- // 兼容大写和小写的格式标记
5729
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
5730
- var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
5731
-
5732
- // 使用fecha库进行格式化,支持中文配置
5733
- var str = fecha.format(date, lowercaseFormat, getSettings());
5734
- return str;
5735
- };
5736
-
5737
- var parseDate = function parseDate(string, format) {
5738
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
5739
- };
5740
-
5741
- var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
5742
- if (month === 3 || month === 5 || month === 8 || month === 10) {
5743
- return 30;
5744
- }
5745
-
5746
- if (month === 1) {
5747
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
5748
- return 29;
5749
- } else {
5750
- return 28;
5751
- }
5752
- }
5753
-
5754
- return 31;
5755
- };
5756
-
5757
- var getDayCountOfYear = function getDayCountOfYear(year) {
5758
- var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
5759
- return isLeapYear ? 366 : 365;
5760
- };
5761
-
5762
- var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
5763
- var temp = new Date(date.getTime());
5764
- temp.setDate(1);
5765
- return temp.getDay();
5766
- };
5767
-
5768
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
5769
- // {prev, next} Date should work for Daylight Saving Time
5770
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
5771
- var prevDate = function prevDate(date) {
5772
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5773
-
5774
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
5775
- };
5776
-
5777
- var nextDate = function nextDate(date) {
5778
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5779
-
5780
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
5781
- };
5782
-
5783
- var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
5784
- var result = new Date(year, month, 1);
5785
- var day = result.getDay();
5786
-
5787
- if (day === 0) {
5788
- return prevDate(result, 7);
5789
- } else {
5790
- return prevDate(result, day);
5791
- }
5792
- };
5793
-
5794
- var getWeekNumber = function getWeekNumber(date) {
5795
- // 支持多种输入类型
5796
- if (!date || !isDate(date)) {
5797
- date = new Date();
5798
- }
5799
- if (typeof date === 'string') {
5800
- date = new Date(date);
5801
- }
5802
-
5803
- // 验证日期有效性
5804
- if (!isDate(date)) return null;
5805
-
5806
- var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
5807
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
5808
- // 将星期日的星期数设为7
5809
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
5810
- // 获取当年的第一天
5811
- var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
5812
- // 计算到最近的星期四的完整周数
5813
- var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
5814
- // 返回周数
5815
- return weekNo;
5816
- };
5817
-
5818
- var getRangeHours = function getRangeHours(ranges) {
5819
- var hours = [];
5820
- var disabledHours = [];
5821
-
5822
- (ranges || []).forEach(function (range) {
5823
- var value = range.map(function (date) {
5824
- return date.getHours();
5825
- });
5826
-
5827
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
5828
- });
5829
-
5830
- if (disabledHours.length) {
5831
- for (var i = 0; i < 24; i++) {
5832
- hours[i] = disabledHours.indexOf(i) === -1;
5833
- }
5834
- } else {
5835
- for (var _i = 0; _i < 24; _i++) {
5836
- hours[_i] = false;
5837
- }
5838
- }
5839
-
5840
- return hours;
5841
- };
5842
-
5843
- var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
5844
- if (amount <= 0) return [];
5845
- var temp = new Date(date.getTime());
5846
- temp.setDate(0);
5847
- var lastDay = temp.getDate();
5848
- return range(amount).map(function (_, index) {
5849
- return lastDay - (amount - index - 1);
5850
- });
5851
- };
5852
-
5853
- var getMonthDays = function getMonthDays(date) {
5854
- var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
5855
- var days = temp.getDate();
5856
- return range(days).map(function (_, index) {
5857
- return index + 1;
5858
- });
5859
- };
5860
-
5861
- function setRangeData(arr, start, end, value) {
5862
- for (var i = start; i < end; i++) {
5863
- arr[i] = value;
5864
- }
5865
- }
5866
-
5867
- var getRangeMinutes = function getRangeMinutes(ranges, hour) {
5868
- var minutes = new Array(60);
5869
-
5870
- if (ranges.length > 0) {
5871
- ranges.forEach(function (range) {
5872
- var start = range[0];
5873
- var end = range[1];
5874
- var startHour = start.getHours();
5875
- var startMinute = start.getMinutes();
5876
- var endHour = end.getHours();
5877
- var endMinute = end.getMinutes();
5878
- if (startHour === hour && endHour !== hour) {
5879
- setRangeData(minutes, startMinute, 60, true);
5880
- } else if (startHour === hour && endHour === hour) {
5881
- setRangeData(minutes, startMinute, endMinute + 1, true);
5882
- } else if (startHour !== hour && endHour === hour) {
5883
- setRangeData(minutes, 0, endMinute + 1, true);
5884
- } else if (startHour < hour && endHour > hour) {
5885
- setRangeData(minutes, 0, 60, true);
5886
- }
5887
- });
5888
- } else {
5889
- setRangeData(minutes, 0, 60, true);
5890
- }
5891
- return minutes;
5892
- };
5893
-
5894
- var range = function range(n) {
5895
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
5896
- return Array.apply(null, { length: n }).map(function (_, n) {
5897
- return n;
5898
- });
5899
- };
5900
-
5901
- var modifyDate = function modifyDate(date, y, m, d) {
5902
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
5903
- };
5904
-
5905
- var modifyTime = function modifyTime(date, h, m, s) {
5906
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
5907
- };
5908
-
5909
- var modifyWithTimeString = function modifyWithTimeString(date, time) {
5910
- if (date == null || !time) {
5911
- return date;
5912
- }
5913
- time = parseDate(time, 'HH:mm:ss');
5914
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
5915
- };
5916
-
5917
- var clearTime = function clearTime(date) {
5918
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
5919
- };
5920
-
5921
- var clearMilliseconds = function clearMilliseconds(date) {
5922
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
5923
- };
5924
-
5925
- var limitTimeRange = function limitTimeRange(date, ranges) {
5926
- var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
5927
-
5928
- // TODO: refactory a more elegant solution
5929
- if (ranges.length === 0) return date;
5930
- var normalizeDate = function normalizeDate(date) {
5931
- return fecha.parse(fecha.format(date, format), format);
5932
- };
5933
- var ndate = normalizeDate(date);
5934
- var nranges = ranges.map(function (range) {
5935
- return range.map(normalizeDate);
5936
- });
5937
- if (nranges.some(function (nrange) {
5938
- return ndate >= nrange[0] && ndate <= nrange[1];
5939
- })) return date;
5940
-
5941
- var minDate = nranges[0][0];
5942
- var maxDate = nranges[0][0];
5943
-
5944
- nranges.forEach(function (nrange) {
5945
- minDate = new Date(Math.min(nrange[0], minDate));
5946
- maxDate = new Date(Math.max(nrange[1], minDate));
5947
- });
5948
-
5949
- var ret = ndate < minDate ? minDate : maxDate;
5950
- // preserve Year/Month/Date
5951
- return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
5952
- };
5953
-
5954
- var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
5955
- var limitedDate = limitTimeRange(date, selectableRange, format);
5956
- return limitedDate.getTime() === date.getTime();
5957
- };
5958
-
5959
- var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
5960
- // clamp date to the number of days in `year`, `month`
5961
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
5962
- var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
5963
- return modifyDate(date, year, month, monthDate);
5964
- };
5965
-
5966
- var prevMonth = function prevMonth(date) {
5967
- var year = date.getFullYear();
5968
- var month = date.getMonth();
5969
- return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
5970
- };
5971
-
5972
- var nextMonth = function nextMonth(date) {
5973
- var year = date.getFullYear();
5974
- var month = date.getMonth();
5975
- return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
5976
- };
5977
-
5978
- var prevYear = function prevYear(date) {
5979
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5980
-
5981
- var year = date.getFullYear();
5982
- var month = date.getMonth();
5983
- return changeYearMonthAndClampDate(date, year - amount, month);
5984
- };
5985
-
5986
- var nextYear = function nextYear(date) {
5987
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5988
-
5989
- var year = date.getFullYear();
5990
- var month = date.getMonth();
5991
- return changeYearMonthAndClampDate(date, year + amount, month);
5992
- };
5993
-
5994
- var extractDateFormat = function extractDateFormat(format) {
5995
- return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
5996
- };
5997
-
5998
- var extractTimeFormat = function extractTimeFormat(format) {
5999
- return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
6000
- };
6001
-
6002
- var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
6003
- return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
6004
- };
6005
-
5639
+ */
5640
+ fecha.parse = function (dateStr, format) {
5641
+ if (typeof format !== 'string') {
5642
+ throw new Error('Invalid format in fecha.parse');
5643
+ }
5644
+
5645
+ format = fecha.masks[format] || format;
5646
+
5647
+ // Avoid regular expression denial of service, fail early for really long strings
5648
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
5649
+ if (dateStr.length > 1000) {
5650
+ return null;
5651
+ }
5652
+
5653
+ const dateInfo = {};
5654
+ const parseInfo = [];
5655
+ const literals = [];
5656
+ format = format.replace(literal, function($0, $1) {
5657
+ literals.push($1);
5658
+ return '@@@';
5659
+ });
5660
+ let newFormat = regexEscape(format).replace(token, function ($0) {
5661
+ if (parseFlags[$0]) {
5662
+ const info = parseFlags[$0];
5663
+ parseInfo.push(info[1]);
5664
+ return '(' + info[0] + ')';
5665
+ }
5666
+
5667
+ return $0;
5668
+ });
5669
+ newFormat = newFormat.replace(/@@@/g, function() {
5670
+ return literals.shift();
5671
+ });
5672
+ const matches = dateStr.match(new RegExp(newFormat, 'i'));
5673
+ if (!matches) {
5674
+ return null;
5675
+ }
5676
+
5677
+ for (let i = 1; i < matches.length; i++) {
5678
+ parseInfo[i - 1](dateInfo, matches[i]);
5679
+ }
5680
+
5681
+ const today = new Date();
5682
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
5683
+ dateInfo.hour = +dateInfo.hour + 12;
5684
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
5685
+ dateInfo.hour = 0;
5686
+ }
5687
+
5688
+ let date;
5689
+ if (dateInfo.timezoneOffset != null) {
5690
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
5691
+ date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
5692
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
5693
+ } else {
5694
+ date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
5695
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
5696
+ }
5697
+ return date;
5698
+ };
5699
+
5700
+ // 导出fecha对象
5701
+
5702
+
5703
+ // 以下是从date-util.js合并的函数
5704
+ const newArray = function(start, end) {
5705
+ let result = [];
5706
+ for (let i = start; i <= end; i++) {
5707
+ result.push(i);
5708
+ }
5709
+ return result;
5710
+ };
5711
+
5712
+ const getSettings = () => {
5713
+ return {
5714
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
5715
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
5716
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
5717
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
5718
+ amPm: ['上午', '下午']
5719
+ };
5720
+ };
5721
+
5722
+ const toDate = function(date) {
5723
+ return isDate(date) ? new Date(date) : null;
5724
+ };
5725
+
5726
+ const isDate = function(date) {
5727
+ if (date === null || date === undefined) return false;
5728
+ if (isNaN(new Date(date).getTime())) return false;
5729
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
5730
+ return true;
5731
+ };
5732
+
5733
+ const isDateObject = function(val) {
5734
+ return val instanceof Date;
5735
+ };
5736
+
5737
+ const formatDate = function (date, format = 'yyyy-MM-dd') {
5738
+ // 处理多种输入类型
5739
+ if (!date) return '';
5740
+
5741
+ // 如果是时间戳,转成日期对象
5742
+ if (typeof date === 'number') {
5743
+ date = new Date(date);
5744
+ }
5745
+ // 如果是字符串,转成日期对象
5746
+ if (typeof date === 'string') {
5747
+ date = new Date(date);
5748
+ }
5749
+
5750
+ // 调用toDate进一步验证和转换
5751
+ date = toDate(date);
5752
+ if (!date) return '';
5753
+
5754
+ // 兼容大写和小写的格式标记
5755
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
5756
+ const lowercaseFormat = format
5757
+ .replace(/YYYY/g, 'yyyy')
5758
+ .replace(/D/g, 'd')
5759
+
5760
+ // 使用fecha库进行格式化,支持中文配置
5761
+ const str = fecha.format(date, lowercaseFormat, getSettings());
5762
+ return str;
5763
+ };
5764
+
5765
+ const parseDate = function(string, format) {
5766
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
5767
+ };
5768
+
5769
+ const getDayCountOfMonth = function(year, month) {
5770
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
5771
+ return 30;
5772
+ }
5773
+
5774
+ if (month === 1) {
5775
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
5776
+ return 29;
5777
+ } else {
5778
+ return 28;
5779
+ }
5780
+ }
5781
+
5782
+ return 31;
5783
+ };
5784
+
5785
+ const getDayCountOfYear = function(year) {
5786
+ const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
5787
+ return isLeapYear ? 366 : 365;
5788
+ };
5789
+
5790
+ const getFirstDayOfMonth = function(date) {
5791
+ const temp = new Date(date.getTime());
5792
+ temp.setDate(1);
5793
+ return temp.getDay();
5794
+ };
5795
+
5796
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
5797
+ // {prev, next} Date should work for Daylight Saving Time
5798
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
5799
+ const prevDate = function(date, amount = 1) {
5800
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
5801
+ };
5802
+
5803
+ const nextDate = function(date, amount = 1) {
5804
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
5805
+ };
5806
+
5807
+ const getStartDateOfMonth = function(year, month) {
5808
+ const result = new Date(year, month, 1);
5809
+ const day = result.getDay();
5810
+
5811
+ if (day === 0) {
5812
+ return prevDate(result, 7);
5813
+ } else {
5814
+ return prevDate(result, day);
5815
+ }
5816
+ };
5817
+
5818
+ const getWeekNumber = function(date) {
5819
+ // 支持多种输入类型
5820
+ if (!date||!isDate(date)) {
5821
+ date = new Date();
5822
+ }
5823
+ if (typeof date === 'string') {
5824
+ date = new Date(date);
5825
+ }
5826
+
5827
+ // 验证日期有效性
5828
+ if (!isDate(date)) return null;
5829
+
5830
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
5831
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
5832
+ // 将星期日的星期数设为7
5833
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
5834
+ // 获取当年的第一天
5835
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
5836
+ // 计算到最近的星期四的完整周数
5837
+ const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
5838
+ // 返回周数
5839
+ return weekNo;
5840
+ };
5841
+
5842
+ const getRangeHours = function(ranges) {
5843
+ const hours = [];
5844
+ let disabledHours = [];
5845
+
5846
+ (ranges || []).forEach(range => {
5847
+ const value = range.map(date => date.getHours());
5848
+
5849
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
5850
+ });
5851
+
5852
+ if (disabledHours.length) {
5853
+ for (let i = 0; i < 24; i++) {
5854
+ hours[i] = disabledHours.indexOf(i) === -1;
5855
+ }
5856
+ } else {
5857
+ for (let i = 0; i < 24; i++) {
5858
+ hours[i] = false;
5859
+ }
5860
+ }
5861
+
5862
+ return hours;
5863
+ };
5864
+
5865
+ const getPrevMonthLastDays = (date, amount) => {
5866
+ if (amount <= 0) return [];
5867
+ const temp = new Date(date.getTime());
5868
+ temp.setDate(0);
5869
+ const lastDay = temp.getDate();
5870
+ return range(amount).map((_, index) => lastDay - (amount - index - 1));
5871
+ };
5872
+
5873
+ const getMonthDays = (date) => {
5874
+ const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
5875
+ const days = temp.getDate();
5876
+ return range(days).map((_, index) => index + 1);
5877
+ };
5878
+
5879
+ function setRangeData(arr, start, end, value) {
5880
+ for (let i = start; i < end; i++) {
5881
+ arr[i] = value;
5882
+ }
5883
+ }
5884
+
5885
+ const getRangeMinutes = function(ranges, hour) {
5886
+ const minutes = new Array(60);
5887
+
5888
+ if (ranges.length > 0) {
5889
+ ranges.forEach(range => {
5890
+ const start = range[0];
5891
+ const end = range[1];
5892
+ const startHour = start.getHours();
5893
+ const startMinute = start.getMinutes();
5894
+ const endHour = end.getHours();
5895
+ const endMinute = end.getMinutes();
5896
+ if (startHour === hour && endHour !== hour) {
5897
+ setRangeData(minutes, startMinute, 60, true);
5898
+ } else if (startHour === hour && endHour === hour) {
5899
+ setRangeData(minutes, startMinute, endMinute + 1, true);
5900
+ } else if (startHour !== hour && endHour === hour) {
5901
+ setRangeData(minutes, 0, endMinute + 1, true);
5902
+ } else if (startHour < hour && endHour > hour) {
5903
+ setRangeData(minutes, 0, 60, true);
5904
+ }
5905
+ });
5906
+ } else {
5907
+ setRangeData(minutes, 0, 60, true);
5908
+ }
5909
+ return minutes;
5910
+ };
5911
+
5912
+ const range = function(n) {
5913
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
5914
+ return Array.apply(null, {length: n}).map((_, n) => n);
5915
+ };
5916
+
5917
+ const modifyDate = function(date, y, m, d) {
5918
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
5919
+ };
5920
+
5921
+ const modifyTime = function(date, h, m, s) {
5922
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
5923
+ };
5924
+
5925
+ const modifyWithTimeString = (date, time) => {
5926
+ if (date == null || !time) {
5927
+ return date;
5928
+ }
5929
+ time = parseDate(time, 'HH:mm:ss');
5930
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
5931
+ };
5932
+
5933
+ const clearTime = function(date) {
5934
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
5935
+ };
5936
+
5937
+ const clearMilliseconds = function(date) {
5938
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
5939
+ };
5940
+
5941
+ const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
5942
+ // TODO: refactory a more elegant solution
5943
+ if (ranges.length === 0) return date;
5944
+ const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
5945
+ const ndate = normalizeDate(date);
5946
+ const nranges = ranges.map(range => range.map(normalizeDate));
5947
+ if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
5948
+
5949
+ let minDate = nranges[0][0];
5950
+ let maxDate = nranges[0][0];
5951
+
5952
+ nranges.forEach(nrange => {
5953
+ minDate = new Date(Math.min(nrange[0], minDate));
5954
+ maxDate = new Date(Math.max(nrange[1], minDate));
5955
+ });
5956
+
5957
+ const ret = ndate < minDate ? minDate : maxDate;
5958
+ // preserve Year/Month/Date
5959
+ return modifyDate(
5960
+ ret,
5961
+ date.getFullYear(),
5962
+ date.getMonth(),
5963
+ date.getDate()
5964
+ );
5965
+ };
5966
+
5967
+ const timeWithinRange = function(date, selectableRange, format) {
5968
+ const limitedDate = limitTimeRange(date, selectableRange, format);
5969
+ return limitedDate.getTime() === date.getTime();
5970
+ };
5971
+
5972
+ const changeYearMonthAndClampDate = function(date, year, month) {
5973
+ // clamp date to the number of days in `year`, `month`
5974
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
5975
+ const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
5976
+ return modifyDate(date, year, month, monthDate);
5977
+ };
5978
+
5979
+ const prevMonth = function(date) {
5980
+ const year = date.getFullYear();
5981
+ const month = date.getMonth();
5982
+ return month === 0
5983
+ ? changeYearMonthAndClampDate(date, year - 1, 11)
5984
+ : changeYearMonthAndClampDate(date, year, month - 1);
5985
+ };
5986
+
5987
+ const nextMonth = function(date) {
5988
+ const year = date.getFullYear();
5989
+ const month = date.getMonth();
5990
+ return month === 11
5991
+ ? changeYearMonthAndClampDate(date, year + 1, 0)
5992
+ : changeYearMonthAndClampDate(date, year, month + 1);
5993
+ };
5994
+
5995
+ const prevYear = function(date, amount = 1) {
5996
+ const year = date.getFullYear();
5997
+ const month = date.getMonth();
5998
+ return changeYearMonthAndClampDate(date, year - amount, month);
5999
+ };
6000
+
6001
+ const nextYear = function(date, amount = 1) {
6002
+ const year = date.getFullYear();
6003
+ const month = date.getMonth();
6004
+ return changeYearMonthAndClampDate(date, year + amount, month);
6005
+ };
6006
+
6007
+ const extractDateFormat = function(format) {
6008
+ return format
6009
+ .replace(/\W?m{1,2}|\W?ZZ/g, '')
6010
+ .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
6011
+ .trim();
6012
+ };
6013
+
6014
+ const extractTimeFormat = function(format) {
6015
+ return format
6016
+ .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
6017
+ .trim();
6018
+ };
6019
+
6020
+ const validateRangeInOneMonth = function(start, end) {
6021
+ return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
6022
+ };
6023
+
6006
6024
  /**
6007
6025
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
6008
6026
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
6009
6027
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
6010
6028
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
6011
6029
  * @returns {number} 工作日数量
6012
- */
6013
- var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
6014
- var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
6015
-
6016
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
6017
- throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
6018
- }
6019
-
6020
- var startDateObj = new Date(start_date);
6021
- var endDateObj = new Date(end_date);
6022
-
6023
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
6024
- throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
6025
- }
6026
-
6027
- if (startDateObj > endDateObj) {
6028
- throw new Error('Start date should be earlier than or equal to end date.');
6029
- }
6030
-
6031
- var workdays = 0;
6032
-
6033
- // Iterate through each day in the date range
6034
-
6035
- var _loop = function _loop(currentDate) {
6036
- // Check if the current day is a weekend (Saturday or Sunday)
6037
- var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
6038
-
6039
- // Check if the current day is a holiday
6040
- var isHoliday = holidays.some(function (holiday) {
6041
- var holidayDate = new Date(holiday);
6042
- return currentDate.toDateString() === holidayDate.toDateString();
6043
- });
6044
-
6045
- // If it's a workday (not a weekend or holiday), increment the workdays count
6046
- if (!isWeekend && !isHoliday) {
6047
- workdays++;
6048
- }
6049
- };
6050
-
6051
- for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
6052
- _loop(currentDate);
6053
- }
6054
-
6055
- return workdays;
6056
- };
6057
-
6030
+ */
6031
+ const calculateNetworkDays = function (start_date, end_date, holidays = []) {
6032
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
6033
+ throw new Error(
6034
+ "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
6035
+ );
6036
+ }
6037
+
6038
+ const startDateObj = new Date(start_date);
6039
+ const endDateObj = new Date(end_date);
6040
+
6041
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
6042
+ throw new Error(
6043
+ "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
6044
+ );
6045
+ }
6046
+
6047
+ if (startDateObj > endDateObj) {
6048
+ throw new Error('Start date should be earlier than or equal to end date.');
6049
+ }
6050
+
6051
+ let workdays = 0;
6052
+
6053
+ // Iterate through each day in the date range
6054
+ for (
6055
+ let currentDate = new Date(startDateObj);
6056
+ currentDate <= endDateObj;
6057
+ currentDate.setDate(currentDate.getDate() + 1)
6058
+ ) {
6059
+ // Check if the current day is a weekend (Saturday or Sunday)
6060
+ const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
6061
+
6062
+ // Check if the current day is a holiday
6063
+ const isHoliday = holidays.some((holiday) => {
6064
+ const holidayDate = new Date(holiday);
6065
+ return currentDate.toDateString() === holidayDate.toDateString();
6066
+ });
6067
+
6068
+ // If it's a workday (not a weekend or holiday), increment the workdays count
6069
+ if (!isWeekend && !isHoliday) {
6070
+ workdays++;
6071
+ }
6072
+ }
6073
+
6074
+ return workdays;
6075
+ };
6076
+
6058
6077
  /**
6059
6078
  * 日期加减天数
6060
6079
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
6061
6080
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
6062
6081
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
6063
- */
6064
- var dateAddDays = function dateAddDays(start_date, days) {
6065
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
6066
- 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.");
6067
- }
6068
-
6069
- var startDateObj = new Date(start_date);
6070
- if (isNaN(startDateObj.getTime())) {
6071
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6072
- }
6073
-
6074
- var resultDateObj = new Date(startDateObj);
6075
- resultDateObj.setDate(resultDateObj.getDate() + days);
6076
-
6077
- var resultYear = resultDateObj.getFullYear();
6078
- var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
6079
- var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
6080
-
6081
- return resultYear + '-' + resultMonth + '-' + resultDay;
6082
- };
6083
-
6082
+ */
6083
+ const dateAddDays = function (start_date, days) {
6084
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
6085
+ throw new Error(
6086
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
6087
+ );
6088
+ }
6089
+
6090
+ const startDateObj = new Date(start_date);
6091
+ if (isNaN(startDateObj.getTime())) {
6092
+ throw new Error(
6093
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
6094
+ );
6095
+ }
6096
+
6097
+ const resultDateObj = new Date(startDateObj);
6098
+ resultDateObj.setDate(resultDateObj.getDate() + days);
6099
+
6100
+ const resultYear = resultDateObj.getFullYear();
6101
+ const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
6102
+ const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
6103
+
6104
+ return `${resultYear}-${resultMonth}-${resultDay}`;
6105
+ };
6106
+
6084
6107
  /**
6085
6108
  * 计算两个日期之间的差值
6086
6109
  * @date 2023年12月14日
@@ -6088,180 +6111,182 @@ var dateAddDays = function dateAddDays(start_date, days) {
6088
6111
  * @param {String} end_date - 结束日期字符串
6089
6112
  * @param {String} unit - 单位:year/month/day
6090
6113
  * @returns {Number} 差值
6091
- */
6092
- var dateDiff = function dateDiff(start_date, end_date) {
6093
- var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
6094
-
6095
- // Assuming date strings are in "YYYY-MM-DD" format
6096
- var startDate = new Date(start_date);
6097
- var endDate = new Date(end_date);
6098
-
6099
- // If the date is invalid, return 0
6100
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
6101
- return 0;
6102
- }
6103
-
6104
- if (unit === 'year') {
6105
- return endDate.getFullYear() - startDate.getFullYear();
6106
- } else if (unit === 'month') {
6107
- return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
6108
- } else {
6109
- // Default to day
6110
- var timeDifference = endDate - startDate;
6111
- // Calculate days (86400000 milliseconds per day)
6112
- return Math.floor(timeDifference / 86400000);
6113
- }
6114
- };
6115
-
6114
+ */
6115
+ const dateDiff = function (start_date, end_date, unit = 'day') {
6116
+ // Assuming date strings are in "YYYY-MM-DD" format
6117
+ var startDate = new Date(start_date);
6118
+ var endDate = new Date(end_date);
6119
+
6120
+ // If the date is invalid, return 0
6121
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
6122
+ return 0;
6123
+ }
6124
+
6125
+ if (unit === 'year') {
6126
+ return endDate.getFullYear() - startDate.getFullYear();
6127
+ } else if (unit === 'month') {
6128
+ return (
6129
+ (endDate.getFullYear() - startDate.getFullYear()) * 12 +
6130
+ (endDate.getMonth() - startDate.getMonth())
6131
+ );
6132
+ } else {
6133
+ // Default to day
6134
+ var timeDifference = endDate - startDate;
6135
+ // Calculate days (86400000 milliseconds per day)
6136
+ return Math.floor(timeDifference / 86400000);
6137
+ }
6138
+ };
6139
+
6116
6140
  /**
6117
6141
  * 获取月份中的日期
6118
6142
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
6119
6143
  * @returns {number} 月份中的日期(1-31)
6120
- */
6121
- var dayOfMonth = function dayOfMonth(date) {
6122
- if (typeof date !== 'string') {
6123
- throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6124
- }
6125
-
6126
- var dateObj = new Date(date);
6127
- if (isNaN(dateObj.getTime())) {
6128
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
6129
- }
6130
-
6131
- return dateObj.getDate();
6132
- };
6133
-
6144
+ */
6145
+ const dayOfMonth = function (date) {
6146
+ if (typeof date !== 'string') {
6147
+ throw new Error(
6148
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
6149
+ );
6150
+ }
6151
+
6152
+ const dateObj = new Date(date);
6153
+ if (isNaN(dateObj.getTime())) {
6154
+ throw new Error(
6155
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
6156
+ );
6157
+ }
6158
+
6159
+ return dateObj.getDate();
6160
+ };
6161
+
6134
6162
  /**
6135
6163
  * 获取当前日期
6136
6164
  * @date 2022年5月7日
6137
6165
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
6138
6166
  * @returns {string} 当前日期的格式化字符串
6139
- */
6140
- var getCurrentDate = function getCurrentDate() {
6141
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
6142
-
6143
- return formatDate(new Date(), format);
6144
- };
6145
-
6167
+ */
6168
+ const getCurrentDate = function (format = 'YYYY-MM-DD') {
6169
+ return formatDate(new Date(), format);
6170
+ };
6171
+
6146
6172
  /**
6147
6173
  * 获取当前日期时间
6148
6174
  * @date 2022年5月7日
6149
6175
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
6150
6176
  * @returns {string} 当前日期时间的格式化字符串
6151
- */
6152
- var getCurrentDateTime = function getCurrentDateTime() {
6153
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
6154
-
6155
- return formatDate(new Date(), format);
6156
- };
6157
-
6177
+ */
6178
+ const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
6179
+ return formatDate(new Date(), format);
6180
+ };
6181
+
6158
6182
  /**
6159
6183
  * 获取小时
6160
6184
  * @date 2022年5月7日
6161
6185
  * @param {Date|string} [date] - 日期对象或日期字符串
6162
6186
  * @returns {number} 小时数(0-23)
6163
- */
6164
- var getHour = function getHour(date) {
6165
- if (!date) {
6166
- return new Date().getHours();
6167
- }
6168
- if (typeof date === 'string') {
6169
- date = new Date(date);
6170
- }
6171
- return date.getHours();
6172
- };
6173
-
6187
+ */
6188
+ const getHour = function (date) {
6189
+ if (!date) {
6190
+ return new Date().getHours();
6191
+ }
6192
+ if (typeof date === 'string') {
6193
+ date = new Date(date);
6194
+ }
6195
+ return date.getHours();
6196
+ };
6197
+
6174
6198
  /**
6175
6199
  * 获取分钟
6176
6200
  * @date 2022年5月7日
6177
6201
  * @param {Date|string} [date] - 日期对象或日期字符串
6178
6202
  * @returns {number} 分钟数(0-59)
6179
- */
6180
- var getMinute = function getMinute(date) {
6181
- if (!date) {
6182
- return new Date().getMinutes();
6183
- }
6184
- if (typeof date === 'string') {
6185
- date = new Date(date);
6186
- }
6187
- return date.getMinutes();
6188
- };
6189
-
6203
+ */
6204
+ const getMinute = function (date) {
6205
+ if (!date) {
6206
+ return new Date().getMinutes();
6207
+ }
6208
+ if (typeof date === 'string') {
6209
+ date = new Date(date);
6210
+ }
6211
+ return date.getMinutes();
6212
+ };
6213
+
6190
6214
  /**
6191
6215
  * 获取月份
6192
6216
  * @date 2022年5月7日
6193
6217
  * @param {Date|string} [date] - 日期对象或日期字符串
6194
6218
  * @returns {number} 月份数(1-12)
6195
- */
6196
- var getMonth = function getMonth(date) {
6197
- if (!date) {
6198
- return new Date().getMonth() + 1;
6199
- }
6200
- if (typeof date === 'string') {
6201
- date = new Date(date);
6202
- }
6203
- return date.getMonth() + 1;
6204
- };
6205
-
6219
+ */
6220
+ const getMonth = function (date) {
6221
+ if (!date) {
6222
+ return new Date().getMonth() + 1;
6223
+ }
6224
+ if (typeof date === 'string') {
6225
+ date = new Date(date);
6226
+ }
6227
+ return date.getMonth() + 1;
6228
+ };
6229
+
6206
6230
  /**
6207
6231
  * 获取秒
6208
6232
  * @date 2022年5月7日
6209
6233
  * @param {Date|string} [date] - 日期对象或日期字符串
6210
6234
  * @returns {number} 秒数(0-59)
6211
- */
6212
- var getSecond = function getSecond(date) {
6213
- if (!date) {
6214
- return new Date().getSeconds();
6215
- }
6216
- if (typeof date === 'string') {
6217
- date = new Date(date);
6218
- }
6219
- return date.getSeconds();
6220
- };
6221
-
6235
+ */
6236
+ const getSecond = function (date) {
6237
+ if (!date) {
6238
+ return new Date().getSeconds();
6239
+ }
6240
+ if (typeof date === 'string') {
6241
+ date = new Date(date);
6242
+ }
6243
+ return date.getSeconds();
6244
+ };
6245
+
6222
6246
  /**
6223
6247
  * 获取星期几
6224
6248
  * @date 2022年5月7日
6225
6249
  * @param {Date|string} [date] - 日期对象或日期字符串
6226
6250
  * @returns {number} 星期几(0-6,0表示星期日)
6227
- */
6228
- var getWeekday = function getWeekday(date) {
6229
- if (!date) {
6230
- return new Date().getDay();
6231
- }
6232
- if (typeof date === 'string') {
6233
- date = new Date(date);
6234
- }
6235
- return date.getDay();
6236
- };
6237
-
6251
+ */
6252
+ const getWeekday = function (date) {
6253
+ if (!date) {
6254
+ return new Date().getDay();
6255
+ }
6256
+ if (typeof date === 'string') {
6257
+ date = new Date(date);
6258
+ }
6259
+ return date.getDay();
6260
+ };
6261
+
6262
+
6238
6263
  /**
6239
6264
  * @desc 获取上午/下午/晚上
6240
6265
  * @author huangbo
6241
6266
  * @date 2022年5月7日
6242
6267
  * @param {String} [time] - 时间
6243
- **/
6244
- var timeCycle = function timeCycle(time) {
6245
- var hour = 0;
6246
- if (!time) {
6247
- hour = new Date().getHours();
6248
- } else if (typeof time === 'string') {
6249
- // 从时间字符串中提取小时
6250
- var match = time.match(/^(\d{1,2})/);
6251
- if (match) {
6252
- hour = parseInt(match[1], 10);
6253
- }
6254
- } else if (typeof time === 'number') {
6255
- hour = time;
6256
- }
6257
- // 判断时间段
6258
- if (hour >= 5 && hour < 12) {
6259
- return '上午';
6260
- } else if (hour >= 12 && hour < 18) {
6261
- return '下午';
6262
- } else {
6263
- return '晚上';
6264
- }
6268
+ **/
6269
+ const timeCycle = function (time) {
6270
+ let hour = 0;
6271
+ if (!time) {
6272
+ hour = new Date().getHours();
6273
+ } else if (typeof time === 'string') {
6274
+ // 从时间字符串中提取小时
6275
+ const match = time.match(/^(\d{1,2})/);
6276
+ if (match) {
6277
+ hour = parseInt(match[1], 10);
6278
+ }
6279
+ } else if (typeof time === 'number') {
6280
+ hour = time;
6281
+ }
6282
+ // 判断时间段
6283
+ if (hour >= 5 && hour < 12) {
6284
+ return '上午';
6285
+ } else if (hour >= 12 && hour < 18) {
6286
+ return '下午';
6287
+ } else {
6288
+ return '晚上';
6289
+ }
6265
6290
  };
6266
6291
 
6267
6292
  /***/ }),