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