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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/lib/account-login.js +912 -856
  2. package/lib/alert.js +2 -2
  3. package/lib/aside.js +2 -2
  4. package/lib/audit-trajectory.js +2 -2
  5. package/lib/autocomplete.js +2001 -1777
  6. package/lib/avatar.js +2 -2
  7. package/lib/backtop.js +2 -2
  8. package/lib/badge.js +2 -2
  9. package/lib/breadcrumb-item.js +4 -4
  10. package/lib/breadcrumb.js +4 -4
  11. package/lib/button-group.js +2 -2
  12. package/lib/button.js +2 -2
  13. package/lib/ca-login.js +862 -837
  14. package/lib/calendar.js +862 -837
  15. package/lib/card.js +2 -2
  16. package/lib/carousel-item.js +864 -839
  17. package/lib/carousel.js +864 -839
  18. package/lib/cascader-panel.js +864 -839
  19. package/lib/cascader.js +2003 -1779
  20. package/lib/checkbox-button.js +2 -2
  21. package/lib/checkbox-group.js +864 -839
  22. package/lib/checkbox.js +2 -2
  23. package/lib/col.js +2 -2
  24. package/lib/collapse-item.js +864 -839
  25. package/lib/collapse.js +864 -839
  26. package/lib/color-picker.js +1141 -942
  27. package/lib/container.js +2 -2
  28. package/lib/cron.js +2 -2
  29. package/lib/data-table.js +871 -846
  30. package/lib/date-picker.js +2003 -1779
  31. package/lib/descriptions-item.js +144 -0
  32. package/lib/descriptions.js +561 -0
  33. package/lib/dialog.js +862 -837
  34. package/lib/divider.js +2 -2
  35. package/lib/drawer.js +2 -2
  36. package/lib/dropdown-item.js +4 -4
  37. package/lib/dropdown-menu.js +1141 -942
  38. package/lib/dropdown.js +862 -837
  39. package/lib/email-login.js +862 -837
  40. package/lib/empty.js +2 -2
  41. package/lib/eoss.common.js +2485 -1819
  42. package/lib/flip.js +2 -2
  43. package/lib/flow-group.js +866 -841
  44. package/lib/flow.js +871 -846
  45. package/lib/flows.js +862 -837
  46. package/lib/footer.js +2 -2
  47. package/lib/form-item.js +875 -850
  48. package/lib/form.js +876 -849
  49. package/lib/guide.js +2 -2
  50. package/lib/header.js +2 -2
  51. package/lib/icon.js +862 -837
  52. package/lib/icons.js +2 -2
  53. package/lib/image-viewer.js +862 -837
  54. package/lib/image.js +4 -4
  55. package/lib/index.js +1 -1
  56. package/lib/infinite-scroll.js +2 -2
  57. package/lib/input-number.js +2 -2
  58. package/lib/input.js +884 -859
  59. package/lib/link.js +2 -2
  60. package/lib/loading.js +2 -2
  61. package/lib/login.js +913 -873
  62. package/lib/lowcode-view.js +862 -837
  63. package/lib/lowcode.js +901 -876
  64. package/lib/main.js +908 -880
  65. package/lib/marquee.js +862 -837
  66. package/lib/menu-item-group.js +2 -2
  67. package/lib/menu-item.js +2 -2
  68. package/lib/menu.js +2003 -1779
  69. package/lib/message-box.js +862 -837
  70. package/lib/message.js +884 -859
  71. package/lib/notification.js +862 -837
  72. package/lib/option-group.js +4 -4
  73. package/lib/option.js +871 -846
  74. package/lib/page-header.js +2 -2
  75. package/lib/pagination.js +862 -837
  76. package/lib/phone-login.js +862 -837
  77. package/lib/popconfirm.js +4 -4
  78. package/lib/popover.js +2001 -1777
  79. package/lib/process-config.js +869 -844
  80. package/lib/process-module.js +862 -837
  81. package/lib/process-rule.js +862 -837
  82. package/lib/progress.js +2 -2
  83. package/lib/qr-code.js +4 -4
  84. package/lib/qrcode-login.js +870 -845
  85. package/lib/radio-button.js +2 -2
  86. package/lib/radio-group.js +871 -846
  87. package/lib/radio.js +2 -2
  88. package/lib/rate.js +862 -837
  89. package/lib/row.js +2 -2
  90. package/lib/scrollbar.js +862 -837
  91. package/lib/select.js +2005 -1781
  92. package/lib/selector-panel.js +873 -848
  93. package/lib/selector.js +866 -841
  94. package/lib/slider.js +2 -2
  95. package/lib/step.js +5 -5
  96. package/lib/steps.js +865 -840
  97. package/lib/submenu.js +1143 -944
  98. package/lib/switch.js +862 -837
  99. package/lib/tab-pane.js +4 -4
  100. package/lib/table-column.js +862 -837
  101. package/lib/table.js +2003 -1779
  102. package/lib/tabs.js +864 -839
  103. package/lib/tag.js +2 -2
  104. package/lib/theme-chalk/base.css +1 -1
  105. package/lib/theme-chalk/descriptions.css +1 -1
  106. package/lib/theme-chalk/index.css +1 -1
  107. package/lib/theme-chalk/main.css +1 -1
  108. package/lib/time-picker.js +2004 -1780
  109. package/lib/time-select.js +2001 -1777
  110. package/lib/timeline-item.js +2 -2
  111. package/lib/timeline.js +2 -2
  112. package/lib/tips.js +862 -837
  113. package/lib/toolbar.js +2 -2
  114. package/lib/tooltip.js +2003 -1779
  115. package/lib/transfer.js +869 -844
  116. package/lib/tree-group.js +862 -837
  117. package/lib/tree.js +862 -837
  118. package/lib/update-history.js +2 -2
  119. package/lib/upload.js +868 -843
  120. package/lib/utils/popper.js +97 -48
  121. package/lib/wujie.js +866 -841
  122. package/package.json +1 -1
  123. package/packages/account-login/src/account-login.vue +29 -0
  124. package/packages/descriptions/index.js +8 -0
  125. package/packages/descriptions/src/index.js +181 -0
  126. package/packages/descriptions/src/item.js +30 -0
  127. package/packages/descriptions/src/row.js +120 -0
  128. package/packages/descriptions-item/index.js +8 -0
  129. package/packages/login/src/login.vue +8 -0
  130. package/packages/login/src/mixins.js +3 -1
  131. package/packages/main/src/minxs.js +1 -0
  132. package/packages/theme-chalk/src/base.scss +2 -1
  133. package/packages/theme-chalk/src/descriptions.scss +0 -1
  134. package/packages/theme-chalk/src/index.scss +2 -0
  135. package/src/index.js +333 -327
  136. package/src/utils/popper.js +109 -70
@@ -82,7 +82,7 @@ module.exports =
82
82
  /******/
83
83
  /******/
84
84
  /******/ // Load entry module and return exports
85
- /******/ return __webpack_require__(__webpack_require__.s = 154);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 155);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -3285,7 +3285,7 @@ var warning = function warning(content, _callback3) {
3285
3285
 
3286
3286
  /***/ }),
3287
3287
 
3288
- /***/ 102:
3288
+ /***/ 103:
3289
3289
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3290
3290
 
3291
3291
  "use strict";
@@ -3728,12 +3728,12 @@ var getRgb = function getRgb($color) {
3728
3728
 
3729
3729
  /***/ }),
3730
3730
 
3731
- /***/ 154:
3731
+ /***/ 155:
3732
3732
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3733
3733
 
3734
3734
  "use strict";
3735
3735
  __webpack_require__.r(__webpack_exports__);
3736
- /* harmony import */ var _carousel_src_carousel_item__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(102);
3736
+ /* harmony import */ var _carousel_src_carousel_item__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(103);
3737
3737
 
3738
3738
 
3739
3739
  /* istanbul ignore next */
@@ -4002,736 +4002,759 @@ function normalizeComponent(
4002
4002
  /* unused harmony export getSecond */
4003
4003
  /* unused harmony export getWeekday */
4004
4004
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
4005
-
4006
-
4005
+ /* Modified from https://github.com/taylorhakes/fecha
4006
+ *
4007
+ * The MIT License (MIT)
4008
+ *
4009
+ * Copyright (c) 2015 Taylor Hakes
4010
+ *
4011
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
4012
+ * of this software and associated documentation files (the "Software"), to deal
4013
+ * in the Software without restriction, including without limitation the rights
4014
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4015
+ * copies of the Software, and to permit persons to whom the Software is
4016
+ * furnished to do so, subject to the following conditions:
4017
+ *
4018
+ * The above copyright notice and this permission notice shall be included in all
4019
+ * copies or substantial portions of the Software.
4020
+ *
4021
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4022
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4023
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4024
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4025
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4026
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4027
+ * SOFTWARE.
4028
+ */
4029
+
4030
+ /*eslint-disable*/
4031
+ // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
4032
+
4033
+
4007
4034
  /**
4008
4035
  * Parse or format dates
4009
4036
  * @class fecha
4010
- */
4011
- var fecha = {};
4012
- var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
4013
- var twoDigits = '\\d\\d?';
4014
- var threeDigits = '\\d{3}';
4015
- var fourDigits = '\\d{4}';
4016
- var word = '[^\\s]+';
4017
- var literal = /\[([^]*?)\]/gm;
4018
- var noop = function noop() {};
4019
-
4020
- function regexEscape(str) {
4021
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
4022
- }
4023
-
4024
- function shorten(arr, sLen) {
4025
- var newArr = [];
4026
- for (var i = 0, len = arr.length; i < len; i++) {
4027
- newArr.push(arr[i].substr(0, sLen));
4028
- }
4029
- return newArr;
4030
- }
4031
-
4032
- function monthUpdate() {
4033
- return function (d, v) {
4034
- var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
4035
- if (~index) {
4036
- d.month = index;
4037
- }
4038
- };
4039
- }
4040
-
4041
- function pad(val, len) {
4042
- val = String(val);
4043
- len = len || 2;
4044
- while (val.length < len) {
4045
- val = '0' + val;
4046
- }
4047
- return val;
4048
- }
4049
-
4050
- // 直接使用中文日期名称常量
4051
- var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
4052
- var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
4053
- var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
4054
- var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
4055
- var amPm = ['上午', '下午'];
4056
- var DoFn = function DoFn(D) {
4057
- return D + '日';
4058
- };
4059
-
4060
- var formatFlags = {
4061
- D: function D(dateObj) {
4062
- return dateObj.getDay();
4063
- },
4064
- DD: function DD(dateObj) {
4065
- return pad(dateObj.getDay());
4066
- },
4067
- Do: function Do(dateObj) {
4068
- return DoFn(dateObj.getDate());
4069
- },
4070
- d: function d(dateObj) {
4071
- return dateObj.getDate();
4072
- },
4073
- dd: function dd(dateObj) {
4074
- return pad(dateObj.getDate());
4075
- },
4076
- ddd: function ddd(dateObj) {
4077
- return dayNamesShort[dateObj.getDay()];
4078
- },
4079
- dddd: function dddd(dateObj) {
4080
- return dayNames[dateObj.getDay()];
4081
- },
4082
- M: function M(dateObj) {
4083
- return dateObj.getMonth() + 1;
4084
- },
4085
- MM: function MM(dateObj) {
4086
- return pad(dateObj.getMonth() + 1);
4087
- },
4088
- MMM: function MMM(dateObj) {
4089
- return monthNamesShort[dateObj.getMonth()];
4090
- },
4091
- MMMM: function MMMM(dateObj) {
4092
- return monthNames[dateObj.getMonth()];
4093
- },
4094
- yy: function yy(dateObj) {
4095
- return pad(String(dateObj.getFullYear()), 4).substr(2);
4096
- },
4097
- yyyy: function yyyy(dateObj) {
4098
- return pad(dateObj.getFullYear(), 4);
4099
- },
4100
- h: function h(dateObj) {
4101
- return dateObj.getHours() % 12 || 12;
4102
- },
4103
- hh: function hh(dateObj) {
4104
- return pad(dateObj.getHours() % 12 || 12);
4105
- },
4106
- H: function H(dateObj) {
4107
- return dateObj.getHours();
4108
- },
4109
- HH: function HH(dateObj) {
4110
- return pad(dateObj.getHours());
4111
- },
4112
- m: function m(dateObj) {
4113
- return dateObj.getMinutes();
4114
- },
4115
- mm: function mm(dateObj) {
4116
- return pad(dateObj.getMinutes());
4117
- },
4118
- s: function s(dateObj) {
4119
- return dateObj.getSeconds();
4120
- },
4121
- ss: function ss(dateObj) {
4122
- return pad(dateObj.getSeconds());
4123
- },
4124
- S: function S(dateObj) {
4125
- return Math.round(dateObj.getMilliseconds() / 100);
4126
- },
4127
- SS: function SS(dateObj) {
4128
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
4129
- },
4130
- SSS: function SSS(dateObj) {
4131
- return pad(dateObj.getMilliseconds(), 3);
4132
- },
4133
- a: function a(dateObj) {
4134
- return dateObj.getHours() < 12 ? '上午' : '下午';
4135
- },
4136
- A: function A(dateObj) {
4137
- return dateObj.getHours() < 12 ? '上午' : '下午';
4138
- },
4139
- ZZ: function ZZ(dateObj) {
4140
- var o = dateObj.getTimezoneOffset();
4141
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
4142
- }
4143
- };
4144
-
4145
- var parseFlags = {
4146
- d: [twoDigits, function (d, v) {
4147
- d.day = v;
4148
- }],
4149
- Do: [twoDigits + word, function (d, v) {
4150
- d.day = parseInt(v, 10);
4151
- }],
4152
- M: [twoDigits, function (d, v) {
4153
- d.month = v - 1;
4154
- }],
4155
- yy: [twoDigits, function (d, v) {
4156
- var da = new Date(),
4157
- cent = +('' + da.getFullYear()).substr(0, 2);
4158
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
4159
- }],
4160
- h: [twoDigits, function (d, v) {
4161
- d.hour = v;
4162
- }],
4163
- m: [twoDigits, function (d, v) {
4164
- d.minute = v;
4165
- }],
4166
- s: [twoDigits, function (d, v) {
4167
- d.second = v;
4168
- }],
4169
- yyyy: [fourDigits, function (d, v) {
4170
- d.year = v;
4171
- }],
4172
- S: ['\\d', function (d, v) {
4173
- d.millisecond = v * 100;
4174
- }],
4175
- SS: ['\\d{2}', function (d, v) {
4176
- d.millisecond = v * 10;
4177
- }],
4178
- SSS: [threeDigits, function (d, v) {
4179
- d.millisecond = v;
4180
- }],
4181
- D: [twoDigits, noop],
4182
- ddd: [word, noop],
4183
- MMM: [word, monthUpdate('monthNamesShort')],
4184
- MMMM: [word, monthUpdate('monthNames')],
4185
- a: [word, function (d, v) {
4186
- var val = v.toLowerCase();
4187
- if (val === '上午') {
4188
- d.isPm = false;
4189
- } else if (val === '下午') {
4190
- d.isPm = true;
4191
- }
4192
- }],
4193
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
4194
- var parts = (v + '').match(/([+-]|\d\d)/gi),
4195
- minutes = void 0;
4196
-
4197
- if (parts) {
4198
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
4199
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
4200
- }
4201
- }]
4202
- };
4203
- parseFlags.dd = parseFlags.d;
4204
- parseFlags.dddd = parseFlags.ddd;
4205
- parseFlags.DD = parseFlags.D;
4206
- parseFlags.mm = parseFlags.m;
4207
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
4208
- parseFlags.MM = parseFlags.M;
4209
- parseFlags.ss = parseFlags.s;
4210
- parseFlags.A = parseFlags.a;
4211
-
4212
- // Some common format strings
4213
- fecha.masks = {
4214
- default: 'ddd MMM dd yyyy HH:mm:ss',
4215
- shortDate: 'M/D/yy',
4216
- mediumDate: 'MMM d, yyyy',
4217
- longDate: 'MMMM d, yyyy',
4218
- fullDate: 'dddd, MMMM d, yyyy',
4219
- shortTime: 'HH:mm',
4220
- mediumTime: 'HH:mm:ss',
4221
- longTime: 'HH:mm:ss.SSS'
4222
- };
4223
-
4037
+ */
4038
+ const fecha = {};
4039
+ const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
4040
+ const twoDigits = '\\d\\d?';
4041
+ const threeDigits = '\\d{3}';
4042
+ const fourDigits = '\\d{4}';
4043
+ const word = '[^\\s]+';
4044
+ const literal = /\[([^]*?)\]/gm;
4045
+ const noop = function () {};
4046
+
4047
+ function regexEscape(str) {
4048
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
4049
+ }
4050
+
4051
+ function shorten(arr, sLen) {
4052
+ const newArr = [];
4053
+ for (let i = 0, len = arr.length; i < len; i++) {
4054
+ newArr.push(arr[i].substr(0, sLen));
4055
+ }
4056
+ return newArr;
4057
+ }
4058
+
4059
+ function monthUpdate() {
4060
+ return function (d, v) {
4061
+ const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
4062
+ if (~index) {
4063
+ d.month = index;
4064
+ }
4065
+ };
4066
+ }
4067
+
4068
+ function pad(val, len) {
4069
+ val = String(val);
4070
+ len = len || 2;
4071
+ while (val.length < len) {
4072
+ val = '0' + val;
4073
+ }
4074
+ return val;
4075
+ }
4076
+
4077
+ // 直接使用中文日期名称常量
4078
+ const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
4079
+ const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
4080
+ const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
4081
+ const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
4082
+ const amPm = ['上午', '下午'];
4083
+ const DoFn = function DoFn(D) {
4084
+ return D + '日';
4085
+ };
4086
+
4087
+ const formatFlags = {
4088
+ D: function(dateObj) {
4089
+ return dateObj.getDay();
4090
+ },
4091
+ DD: function(dateObj) {
4092
+ return pad(dateObj.getDay());
4093
+ },
4094
+ Do: function(dateObj) {
4095
+ return DoFn(dateObj.getDate());
4096
+ },
4097
+ d: function(dateObj) {
4098
+ return dateObj.getDate();
4099
+ },
4100
+ dd: function(dateObj) {
4101
+ return pad(dateObj.getDate());
4102
+ },
4103
+ ddd: function(dateObj) {
4104
+ return dayNamesShort[dateObj.getDay()];
4105
+ },
4106
+ dddd: function(dateObj) {
4107
+ return dayNames[dateObj.getDay()];
4108
+ },
4109
+ M: function(dateObj) {
4110
+ return dateObj.getMonth() + 1;
4111
+ },
4112
+ MM: function(dateObj) {
4113
+ return pad(dateObj.getMonth() + 1);
4114
+ },
4115
+ MMM: function(dateObj) {
4116
+ return monthNamesShort[dateObj.getMonth()];
4117
+ },
4118
+ MMMM: function(dateObj) {
4119
+ return monthNames[dateObj.getMonth()];
4120
+ },
4121
+ yy: function(dateObj) {
4122
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
4123
+ },
4124
+ yyyy: function(dateObj) {
4125
+ return pad(dateObj.getFullYear(), 4);
4126
+ },
4127
+ h: function(dateObj) {
4128
+ return dateObj.getHours() % 12 || 12;
4129
+ },
4130
+ hh: function(dateObj) {
4131
+ return pad(dateObj.getHours() % 12 || 12);
4132
+ },
4133
+ H: function(dateObj) {
4134
+ return dateObj.getHours();
4135
+ },
4136
+ HH: function(dateObj) {
4137
+ return pad(dateObj.getHours());
4138
+ },
4139
+ m: function(dateObj) {
4140
+ return dateObj.getMinutes();
4141
+ },
4142
+ mm: function(dateObj) {
4143
+ return pad(dateObj.getMinutes());
4144
+ },
4145
+ s: function(dateObj) {
4146
+ return dateObj.getSeconds();
4147
+ },
4148
+ ss: function(dateObj) {
4149
+ return pad(dateObj.getSeconds());
4150
+ },
4151
+ S: function(dateObj) {
4152
+ return Math.round(dateObj.getMilliseconds() / 100);
4153
+ },
4154
+ SS: function(dateObj) {
4155
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
4156
+ },
4157
+ SSS: function(dateObj) {
4158
+ return pad(dateObj.getMilliseconds(), 3);
4159
+ },
4160
+ a: function(dateObj) {
4161
+ return dateObj.getHours() < 12 ? '上午' : '下午';
4162
+ },
4163
+ A: function(dateObj) {
4164
+ return dateObj.getHours() < 12 ? '上午' : '下午';
4165
+ },
4166
+ ZZ: function(dateObj) {
4167
+ const o = dateObj.getTimezoneOffset();
4168
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
4169
+ }
4170
+ };
4171
+
4172
+ const parseFlags = {
4173
+ d: [twoDigits, function (d, v) {
4174
+ d.day = v;
4175
+ }],
4176
+ Do: [twoDigits + word, function (d, v) {
4177
+ d.day = parseInt(v, 10);
4178
+ }],
4179
+ M: [twoDigits, function (d, v) {
4180
+ d.month = v - 1;
4181
+ }],
4182
+ yy: [twoDigits, function (d, v) {
4183
+ const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
4184
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
4185
+ }],
4186
+ h: [twoDigits, function (d, v) {
4187
+ d.hour = v;
4188
+ }],
4189
+ m: [twoDigits, function (d, v) {
4190
+ d.minute = v;
4191
+ }],
4192
+ s: [twoDigits, function (d, v) {
4193
+ d.second = v;
4194
+ }],
4195
+ yyyy: [fourDigits, function (d, v) {
4196
+ d.year = v;
4197
+ }],
4198
+ S: ['\\d', function (d, v) {
4199
+ d.millisecond = v * 100;
4200
+ }],
4201
+ SS: ['\\d{2}', function (d, v) {
4202
+ d.millisecond = v * 10;
4203
+ }],
4204
+ SSS: [threeDigits, function (d, v) {
4205
+ d.millisecond = v;
4206
+ }],
4207
+ D: [twoDigits, noop],
4208
+ ddd: [word, noop],
4209
+ MMM: [word, monthUpdate('monthNamesShort')],
4210
+ MMMM: [word, monthUpdate('monthNames')],
4211
+ a: [word, function (d, v) {
4212
+ const val = v.toLowerCase();
4213
+ if (val === '上午') {
4214
+ d.isPm = false;
4215
+ } else if (val === '下午') {
4216
+ d.isPm = true;
4217
+ }
4218
+ }],
4219
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
4220
+ let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
4221
+
4222
+ if (parts) {
4223
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
4224
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
4225
+ }
4226
+ }]
4227
+ };
4228
+ parseFlags.dd = parseFlags.d;
4229
+ parseFlags.dddd = parseFlags.ddd;
4230
+ parseFlags.DD = parseFlags.D;
4231
+ parseFlags.mm = parseFlags.m;
4232
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
4233
+ parseFlags.MM = parseFlags.M;
4234
+ parseFlags.ss = parseFlags.s;
4235
+ parseFlags.A = parseFlags.a;
4236
+
4237
+
4238
+ // Some common format strings
4239
+ fecha.masks = {
4240
+ default: 'ddd MMM dd yyyy HH:mm:ss',
4241
+ shortDate: 'M/D/yy',
4242
+ mediumDate: 'MMM d, yyyy',
4243
+ longDate: 'MMMM d, yyyy',
4244
+ fullDate: 'dddd, MMMM d, yyyy',
4245
+ shortTime: 'HH:mm',
4246
+ mediumTime: 'HH:mm:ss',
4247
+ longTime: 'HH:mm:ss.SSS'
4248
+ };
4249
+
4224
4250
  /***
4225
4251
  * Format a date
4226
4252
  * @method format
4227
4253
  * @param {Date|number} dateObj
4228
4254
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
4229
- */
4230
- fecha.format = function (dateObj, mask) {
4231
- if (typeof dateObj === 'number') {
4232
- dateObj = new Date(dateObj);
4233
- }
4234
-
4235
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
4236
- throw new Error('Invalid Date in fecha.format');
4237
- }
4238
-
4239
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
4240
-
4241
- var literals = [];
4242
-
4243
- // Make literals inactive by replacing them with ??
4244
- mask = mask.replace(literal, function ($0, $1) {
4245
- literals.push($1);
4246
- return '@@@';
4247
- });
4248
- // Apply formatting rules
4249
- mask = mask.replace(token, function ($0) {
4250
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
4251
- });
4252
- // Inline literal values back into the formatted value
4253
- return mask.replace(/@@@/g, function () {
4254
- return literals.shift();
4255
- });
4256
- };
4257
-
4255
+ */
4256
+ fecha.format = function (dateObj, mask) {
4257
+ if (typeof dateObj === 'number') {
4258
+ dateObj = new Date(dateObj);
4259
+ }
4260
+
4261
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
4262
+ throw new Error('Invalid Date in fecha.format');
4263
+ }
4264
+
4265
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
4266
+
4267
+ const literals = [];
4268
+
4269
+ // Make literals inactive by replacing them with ??
4270
+ mask = mask.replace(literal, function($0, $1) {
4271
+ literals.push($1);
4272
+ return '@@@';
4273
+ });
4274
+ // Apply formatting rules
4275
+ mask = mask.replace(token, function ($0) {
4276
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
4277
+ });
4278
+ // Inline literal values back into the formatted value
4279
+ return mask.replace(/@@@/g, function() {
4280
+ return literals.shift();
4281
+ });
4282
+ };
4283
+
4258
4284
  /**
4259
4285
  * Parse a date string into an object, changes - into /
4260
4286
  * @method parse
4261
4287
  * @param {string} dateStr Date string
4262
4288
  * @param {string} format Date parse format
4263
4289
  * @returns {Date|boolean}
4264
- */
4265
- fecha.parse = function (dateStr, format) {
4266
- if (typeof format !== 'string') {
4267
- throw new Error('Invalid format in fecha.parse');
4268
- }
4269
-
4270
- format = fecha.masks[format] || format;
4271
-
4272
- // Avoid regular expression denial of service, fail early for really long strings
4273
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
4274
- if (dateStr.length > 1000) {
4275
- return null;
4276
- }
4277
-
4278
- var dateInfo = {};
4279
- var parseInfo = [];
4280
- var literals = [];
4281
- format = format.replace(literal, function ($0, $1) {
4282
- literals.push($1);
4283
- return '@@@';
4284
- });
4285
- var newFormat = regexEscape(format).replace(token, function ($0) {
4286
- if (parseFlags[$0]) {
4287
- var info = parseFlags[$0];
4288
- parseInfo.push(info[1]);
4289
- return '(' + info[0] + ')';
4290
- }
4291
-
4292
- return $0;
4293
- });
4294
- newFormat = newFormat.replace(/@@@/g, function () {
4295
- return literals.shift();
4296
- });
4297
- var matches = dateStr.match(new RegExp(newFormat, 'i'));
4298
- if (!matches) {
4299
- return null;
4300
- }
4301
-
4302
- for (var i = 1; i < matches.length; i++) {
4303
- parseInfo[i - 1](dateInfo, matches[i]);
4304
- }
4305
-
4306
- var today = new Date();
4307
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
4308
- dateInfo.hour = +dateInfo.hour + 12;
4309
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
4310
- dateInfo.hour = 0;
4311
- }
4312
-
4313
- var date = void 0;
4314
- if (dateInfo.timezoneOffset != null) {
4315
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
4316
- 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));
4317
- } else {
4318
- 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);
4319
- }
4320
- return date;
4321
- };
4322
-
4323
- // 导出fecha对象
4324
-
4325
-
4326
- // 以下是从date-util.js合并的函数
4327
- var newArray = function newArray(start, end) {
4328
- var result = [];
4329
- for (var i = start; i <= end; i++) {
4330
- result.push(i);
4331
- }
4332
- return result;
4333
- };
4334
-
4335
- var getSettings = function getSettings() {
4336
- return {
4337
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
4338
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
4339
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
4340
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
4341
- amPm: ['上午', '下午']
4342
- };
4343
- };
4344
-
4345
- var toDate = function toDate(date) {
4346
- return isDate(date) ? new Date(date) : null;
4347
- };
4348
-
4349
- var isDate = function isDate(date) {
4350
- if (date === null || date === undefined) return false;
4351
- if (isNaN(new Date(date).getTime())) return false;
4352
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
4353
- return true;
4354
- };
4355
-
4356
- var isDateObject = function isDateObject(val) {
4357
- return val instanceof Date;
4358
- };
4359
-
4360
- var formatDate = function formatDate(date) {
4361
- var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
4362
-
4363
- // 处理多种输入类型
4364
- if (!date) return '';
4365
-
4366
- // 如果是时间戳,转成日期对象
4367
- if (typeof date === 'number') {
4368
- date = new Date(date);
4369
- }
4370
- // 如果是字符串,转成日期对象
4371
- if (typeof date === 'string') {
4372
- date = new Date(date);
4373
- }
4374
-
4375
- // 调用toDate进一步验证和转换
4376
- date = toDate(date);
4377
- if (!date) return '';
4378
-
4379
- // 兼容大写和小写的格式标记
4380
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
4381
- var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
4382
-
4383
- // 使用fecha库进行格式化,支持中文配置
4384
- var str = fecha.format(date, lowercaseFormat, getSettings());
4385
- return str;
4386
- };
4387
-
4388
- var parseDate = function parseDate(string, format) {
4389
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
4390
- };
4391
-
4392
- var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
4393
- if (month === 3 || month === 5 || month === 8 || month === 10) {
4394
- return 30;
4395
- }
4396
-
4397
- if (month === 1) {
4398
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
4399
- return 29;
4400
- } else {
4401
- return 28;
4402
- }
4403
- }
4404
-
4405
- return 31;
4406
- };
4407
-
4408
- var getDayCountOfYear = function getDayCountOfYear(year) {
4409
- var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
4410
- return isLeapYear ? 366 : 365;
4411
- };
4412
-
4413
- var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
4414
- var temp = new Date(date.getTime());
4415
- temp.setDate(1);
4416
- return temp.getDay();
4417
- };
4418
-
4419
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
4420
- // {prev, next} Date should work for Daylight Saving Time
4421
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
4422
- var prevDate = function prevDate(date) {
4423
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4424
-
4425
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
4426
- };
4427
-
4428
- var nextDate = function nextDate(date) {
4429
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4430
-
4431
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
4432
- };
4433
-
4434
- var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
4435
- var result = new Date(year, month, 1);
4436
- var day = result.getDay();
4437
-
4438
- if (day === 0) {
4439
- return prevDate(result, 7);
4440
- } else {
4441
- return prevDate(result, day);
4442
- }
4443
- };
4444
-
4445
- var getWeekNumber = function getWeekNumber(date) {
4446
- // 支持多种输入类型
4447
- if (!date || !isDate(date)) {
4448
- date = new Date();
4449
- }
4450
- if (typeof date === 'string') {
4451
- date = new Date(date);
4452
- }
4453
-
4454
- // 验证日期有效性
4455
- if (!isDate(date)) return null;
4456
-
4457
- var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
4458
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
4459
- // 将星期日的星期数设为7
4460
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
4461
- // 获取当年的第一天
4462
- var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
4463
- // 计算到最近的星期四的完整周数
4464
- var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
4465
- // 返回周数
4466
- return weekNo;
4467
- };
4468
-
4469
- var getRangeHours = function getRangeHours(ranges) {
4470
- var hours = [];
4471
- var disabledHours = [];
4472
-
4473
- (ranges || []).forEach(function (range) {
4474
- var value = range.map(function (date) {
4475
- return date.getHours();
4476
- });
4477
-
4478
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
4479
- });
4480
-
4481
- if (disabledHours.length) {
4482
- for (var i = 0; i < 24; i++) {
4483
- hours[i] = disabledHours.indexOf(i) === -1;
4484
- }
4485
- } else {
4486
- for (var _i = 0; _i < 24; _i++) {
4487
- hours[_i] = false;
4488
- }
4489
- }
4490
-
4491
- return hours;
4492
- };
4493
-
4494
- var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
4495
- if (amount <= 0) return [];
4496
- var temp = new Date(date.getTime());
4497
- temp.setDate(0);
4498
- var lastDay = temp.getDate();
4499
- return range(amount).map(function (_, index) {
4500
- return lastDay - (amount - index - 1);
4501
- });
4502
- };
4503
-
4504
- var getMonthDays = function getMonthDays(date) {
4505
- var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
4506
- var days = temp.getDate();
4507
- return range(days).map(function (_, index) {
4508
- return index + 1;
4509
- });
4510
- };
4511
-
4512
- function setRangeData(arr, start, end, value) {
4513
- for (var i = start; i < end; i++) {
4514
- arr[i] = value;
4515
- }
4516
- }
4517
-
4518
- var getRangeMinutes = function getRangeMinutes(ranges, hour) {
4519
- var minutes = new Array(60);
4520
-
4521
- if (ranges.length > 0) {
4522
- ranges.forEach(function (range) {
4523
- var start = range[0];
4524
- var end = range[1];
4525
- var startHour = start.getHours();
4526
- var startMinute = start.getMinutes();
4527
- var endHour = end.getHours();
4528
- var endMinute = end.getMinutes();
4529
- if (startHour === hour && endHour !== hour) {
4530
- setRangeData(minutes, startMinute, 60, true);
4531
- } else if (startHour === hour && endHour === hour) {
4532
- setRangeData(minutes, startMinute, endMinute + 1, true);
4533
- } else if (startHour !== hour && endHour === hour) {
4534
- setRangeData(minutes, 0, endMinute + 1, true);
4535
- } else if (startHour < hour && endHour > hour) {
4536
- setRangeData(minutes, 0, 60, true);
4537
- }
4538
- });
4539
- } else {
4540
- setRangeData(minutes, 0, 60, true);
4541
- }
4542
- return minutes;
4543
- };
4544
-
4545
- var range = function range(n) {
4546
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
4547
- return Array.apply(null, { length: n }).map(function (_, n) {
4548
- return n;
4549
- });
4550
- };
4551
-
4552
- var modifyDate = function modifyDate(date, y, m, d) {
4553
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
4554
- };
4555
-
4556
- var modifyTime = function modifyTime(date, h, m, s) {
4557
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
4558
- };
4559
-
4560
- var modifyWithTimeString = function modifyWithTimeString(date, time) {
4561
- if (date == null || !time) {
4562
- return date;
4563
- }
4564
- time = parseDate(time, 'HH:mm:ss');
4565
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
4566
- };
4567
-
4568
- var clearTime = function clearTime(date) {
4569
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
4570
- };
4571
-
4572
- var clearMilliseconds = function clearMilliseconds(date) {
4573
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
4574
- };
4575
-
4576
- var limitTimeRange = function limitTimeRange(date, ranges) {
4577
- var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
4578
-
4579
- // TODO: refactory a more elegant solution
4580
- if (ranges.length === 0) return date;
4581
- var normalizeDate = function normalizeDate(date) {
4582
- return fecha.parse(fecha.format(date, format), format);
4583
- };
4584
- var ndate = normalizeDate(date);
4585
- var nranges = ranges.map(function (range) {
4586
- return range.map(normalizeDate);
4587
- });
4588
- if (nranges.some(function (nrange) {
4589
- return ndate >= nrange[0] && ndate <= nrange[1];
4590
- })) return date;
4591
-
4592
- var minDate = nranges[0][0];
4593
- var maxDate = nranges[0][0];
4594
-
4595
- nranges.forEach(function (nrange) {
4596
- minDate = new Date(Math.min(nrange[0], minDate));
4597
- maxDate = new Date(Math.max(nrange[1], minDate));
4598
- });
4599
-
4600
- var ret = ndate < minDate ? minDate : maxDate;
4601
- // preserve Year/Month/Date
4602
- return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
4603
- };
4604
-
4605
- var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
4606
- var limitedDate = limitTimeRange(date, selectableRange, format);
4607
- return limitedDate.getTime() === date.getTime();
4608
- };
4609
-
4610
- var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
4611
- // clamp date to the number of days in `year`, `month`
4612
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
4613
- var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
4614
- return modifyDate(date, year, month, monthDate);
4615
- };
4616
-
4617
- var prevMonth = function prevMonth(date) {
4618
- var year = date.getFullYear();
4619
- var month = date.getMonth();
4620
- return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
4621
- };
4622
-
4623
- var nextMonth = function nextMonth(date) {
4624
- var year = date.getFullYear();
4625
- var month = date.getMonth();
4626
- return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
4627
- };
4628
-
4629
- var prevYear = function prevYear(date) {
4630
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4631
-
4632
- var year = date.getFullYear();
4633
- var month = date.getMonth();
4634
- return changeYearMonthAndClampDate(date, year - amount, month);
4635
- };
4636
-
4637
- var nextYear = function nextYear(date) {
4638
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4639
-
4640
- var year = date.getFullYear();
4641
- var month = date.getMonth();
4642
- return changeYearMonthAndClampDate(date, year + amount, month);
4643
- };
4644
-
4645
- var extractDateFormat = function extractDateFormat(format) {
4646
- return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
4647
- };
4648
-
4649
- var extractTimeFormat = function extractTimeFormat(format) {
4650
- return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
4651
- };
4652
-
4653
- var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
4654
- return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
4655
- };
4656
-
4290
+ */
4291
+ fecha.parse = function (dateStr, format) {
4292
+ if (typeof format !== 'string') {
4293
+ throw new Error('Invalid format in fecha.parse');
4294
+ }
4295
+
4296
+ format = fecha.masks[format] || format;
4297
+
4298
+ // Avoid regular expression denial of service, fail early for really long strings
4299
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
4300
+ if (dateStr.length > 1000) {
4301
+ return null;
4302
+ }
4303
+
4304
+ const dateInfo = {};
4305
+ const parseInfo = [];
4306
+ const literals = [];
4307
+ format = format.replace(literal, function($0, $1) {
4308
+ literals.push($1);
4309
+ return '@@@';
4310
+ });
4311
+ let newFormat = regexEscape(format).replace(token, function ($0) {
4312
+ if (parseFlags[$0]) {
4313
+ const info = parseFlags[$0];
4314
+ parseInfo.push(info[1]);
4315
+ return '(' + info[0] + ')';
4316
+ }
4317
+
4318
+ return $0;
4319
+ });
4320
+ newFormat = newFormat.replace(/@@@/g, function() {
4321
+ return literals.shift();
4322
+ });
4323
+ const matches = dateStr.match(new RegExp(newFormat, 'i'));
4324
+ if (!matches) {
4325
+ return null;
4326
+ }
4327
+
4328
+ for (let i = 1; i < matches.length; i++) {
4329
+ parseInfo[i - 1](dateInfo, matches[i]);
4330
+ }
4331
+
4332
+ const today = new Date();
4333
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
4334
+ dateInfo.hour = +dateInfo.hour + 12;
4335
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
4336
+ dateInfo.hour = 0;
4337
+ }
4338
+
4339
+ let date;
4340
+ if (dateInfo.timezoneOffset != null) {
4341
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
4342
+ date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
4343
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
4344
+ } else {
4345
+ date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
4346
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
4347
+ }
4348
+ return date;
4349
+ };
4350
+
4351
+ // 导出fecha对象
4352
+
4353
+
4354
+ // 以下是从date-util.js合并的函数
4355
+ const newArray = function(start, end) {
4356
+ let result = [];
4357
+ for (let i = start; i <= end; i++) {
4358
+ result.push(i);
4359
+ }
4360
+ return result;
4361
+ };
4362
+
4363
+ const getSettings = () => {
4364
+ return {
4365
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
4366
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
4367
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
4368
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
4369
+ amPm: ['上午', '下午']
4370
+ };
4371
+ };
4372
+
4373
+ const toDate = function(date) {
4374
+ return isDate(date) ? new Date(date) : null;
4375
+ };
4376
+
4377
+ const isDate = function(date) {
4378
+ if (date === null || date === undefined) return false;
4379
+ if (isNaN(new Date(date).getTime())) return false;
4380
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
4381
+ return true;
4382
+ };
4383
+
4384
+ const isDateObject = function(val) {
4385
+ return val instanceof Date;
4386
+ };
4387
+
4388
+ const formatDate = function (date, format = 'yyyy-MM-dd') {
4389
+ // 处理多种输入类型
4390
+ if (!date) return '';
4391
+
4392
+ // 如果是时间戳,转成日期对象
4393
+ if (typeof date === 'number') {
4394
+ date = new Date(date);
4395
+ }
4396
+ // 如果是字符串,转成日期对象
4397
+ if (typeof date === 'string') {
4398
+ date = new Date(date);
4399
+ }
4400
+
4401
+ // 调用toDate进一步验证和转换
4402
+ date = toDate(date);
4403
+ if (!date) return '';
4404
+
4405
+ // 兼容大写和小写的格式标记
4406
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
4407
+ const lowercaseFormat = format
4408
+ .replace(/YYYY/g, 'yyyy')
4409
+ .replace(/D/g, 'd')
4410
+
4411
+ // 使用fecha库进行格式化,支持中文配置
4412
+ const str = fecha.format(date, lowercaseFormat, getSettings());
4413
+ return str;
4414
+ };
4415
+
4416
+ const parseDate = function(string, format) {
4417
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
4418
+ };
4419
+
4420
+ const getDayCountOfMonth = function(year, month) {
4421
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
4422
+ return 30;
4423
+ }
4424
+
4425
+ if (month === 1) {
4426
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
4427
+ return 29;
4428
+ } else {
4429
+ return 28;
4430
+ }
4431
+ }
4432
+
4433
+ return 31;
4434
+ };
4435
+
4436
+ const getDayCountOfYear = function(year) {
4437
+ const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
4438
+ return isLeapYear ? 366 : 365;
4439
+ };
4440
+
4441
+ const getFirstDayOfMonth = function(date) {
4442
+ const temp = new Date(date.getTime());
4443
+ temp.setDate(1);
4444
+ return temp.getDay();
4445
+ };
4446
+
4447
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
4448
+ // {prev, next} Date should work for Daylight Saving Time
4449
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
4450
+ const prevDate = function(date, amount = 1) {
4451
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
4452
+ };
4453
+
4454
+ const nextDate = function(date, amount = 1) {
4455
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
4456
+ };
4457
+
4458
+ const getStartDateOfMonth = function(year, month) {
4459
+ const result = new Date(year, month, 1);
4460
+ const day = result.getDay();
4461
+
4462
+ if (day === 0) {
4463
+ return prevDate(result, 7);
4464
+ } else {
4465
+ return prevDate(result, day);
4466
+ }
4467
+ };
4468
+
4469
+ const getWeekNumber = function(date) {
4470
+ // 支持多种输入类型
4471
+ if (!date||!isDate(date)) {
4472
+ date = new Date();
4473
+ }
4474
+ if (typeof date === 'string') {
4475
+ date = new Date(date);
4476
+ }
4477
+
4478
+ // 验证日期有效性
4479
+ if (!isDate(date)) return null;
4480
+
4481
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
4482
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
4483
+ // 将星期日的星期数设为7
4484
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
4485
+ // 获取当年的第一天
4486
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
4487
+ // 计算到最近的星期四的完整周数
4488
+ const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
4489
+ // 返回周数
4490
+ return weekNo;
4491
+ };
4492
+
4493
+ const getRangeHours = function(ranges) {
4494
+ const hours = [];
4495
+ let disabledHours = [];
4496
+
4497
+ (ranges || []).forEach(range => {
4498
+ const value = range.map(date => date.getHours());
4499
+
4500
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
4501
+ });
4502
+
4503
+ if (disabledHours.length) {
4504
+ for (let i = 0; i < 24; i++) {
4505
+ hours[i] = disabledHours.indexOf(i) === -1;
4506
+ }
4507
+ } else {
4508
+ for (let i = 0; i < 24; i++) {
4509
+ hours[i] = false;
4510
+ }
4511
+ }
4512
+
4513
+ return hours;
4514
+ };
4515
+
4516
+ const getPrevMonthLastDays = (date, amount) => {
4517
+ if (amount <= 0) return [];
4518
+ const temp = new Date(date.getTime());
4519
+ temp.setDate(0);
4520
+ const lastDay = temp.getDate();
4521
+ return range(amount).map((_, index) => lastDay - (amount - index - 1));
4522
+ };
4523
+
4524
+ const getMonthDays = (date) => {
4525
+ const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
4526
+ const days = temp.getDate();
4527
+ return range(days).map((_, index) => index + 1);
4528
+ };
4529
+
4530
+ function setRangeData(arr, start, end, value) {
4531
+ for (let i = start; i < end; i++) {
4532
+ arr[i] = value;
4533
+ }
4534
+ }
4535
+
4536
+ const getRangeMinutes = function(ranges, hour) {
4537
+ const minutes = new Array(60);
4538
+
4539
+ if (ranges.length > 0) {
4540
+ ranges.forEach(range => {
4541
+ const start = range[0];
4542
+ const end = range[1];
4543
+ const startHour = start.getHours();
4544
+ const startMinute = start.getMinutes();
4545
+ const endHour = end.getHours();
4546
+ const endMinute = end.getMinutes();
4547
+ if (startHour === hour && endHour !== hour) {
4548
+ setRangeData(minutes, startMinute, 60, true);
4549
+ } else if (startHour === hour && endHour === hour) {
4550
+ setRangeData(minutes, startMinute, endMinute + 1, true);
4551
+ } else if (startHour !== hour && endHour === hour) {
4552
+ setRangeData(minutes, 0, endMinute + 1, true);
4553
+ } else if (startHour < hour && endHour > hour) {
4554
+ setRangeData(minutes, 0, 60, true);
4555
+ }
4556
+ });
4557
+ } else {
4558
+ setRangeData(minutes, 0, 60, true);
4559
+ }
4560
+ return minutes;
4561
+ };
4562
+
4563
+ const range = function(n) {
4564
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
4565
+ return Array.apply(null, {length: n}).map((_, n) => n);
4566
+ };
4567
+
4568
+ const modifyDate = function(date, y, m, d) {
4569
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
4570
+ };
4571
+
4572
+ const modifyTime = function(date, h, m, s) {
4573
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
4574
+ };
4575
+
4576
+ const modifyWithTimeString = (date, time) => {
4577
+ if (date == null || !time) {
4578
+ return date;
4579
+ }
4580
+ time = parseDate(time, 'HH:mm:ss');
4581
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
4582
+ };
4583
+
4584
+ const clearTime = function(date) {
4585
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
4586
+ };
4587
+
4588
+ const clearMilliseconds = function(date) {
4589
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
4590
+ };
4591
+
4592
+ const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
4593
+ // TODO: refactory a more elegant solution
4594
+ if (ranges.length === 0) return date;
4595
+ const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
4596
+ const ndate = normalizeDate(date);
4597
+ const nranges = ranges.map(range => range.map(normalizeDate));
4598
+ if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
4599
+
4600
+ let minDate = nranges[0][0];
4601
+ let maxDate = nranges[0][0];
4602
+
4603
+ nranges.forEach(nrange => {
4604
+ minDate = new Date(Math.min(nrange[0], minDate));
4605
+ maxDate = new Date(Math.max(nrange[1], minDate));
4606
+ });
4607
+
4608
+ const ret = ndate < minDate ? minDate : maxDate;
4609
+ // preserve Year/Month/Date
4610
+ return modifyDate(
4611
+ ret,
4612
+ date.getFullYear(),
4613
+ date.getMonth(),
4614
+ date.getDate()
4615
+ );
4616
+ };
4617
+
4618
+ const timeWithinRange = function(date, selectableRange, format) {
4619
+ const limitedDate = limitTimeRange(date, selectableRange, format);
4620
+ return limitedDate.getTime() === date.getTime();
4621
+ };
4622
+
4623
+ const changeYearMonthAndClampDate = function(date, year, month) {
4624
+ // clamp date to the number of days in `year`, `month`
4625
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
4626
+ const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
4627
+ return modifyDate(date, year, month, monthDate);
4628
+ };
4629
+
4630
+ const prevMonth = function(date) {
4631
+ const year = date.getFullYear();
4632
+ const month = date.getMonth();
4633
+ return month === 0
4634
+ ? changeYearMonthAndClampDate(date, year - 1, 11)
4635
+ : changeYearMonthAndClampDate(date, year, month - 1);
4636
+ };
4637
+
4638
+ const nextMonth = function(date) {
4639
+ const year = date.getFullYear();
4640
+ const month = date.getMonth();
4641
+ return month === 11
4642
+ ? changeYearMonthAndClampDate(date, year + 1, 0)
4643
+ : changeYearMonthAndClampDate(date, year, month + 1);
4644
+ };
4645
+
4646
+ const prevYear = function(date, amount = 1) {
4647
+ const year = date.getFullYear();
4648
+ const month = date.getMonth();
4649
+ return changeYearMonthAndClampDate(date, year - amount, month);
4650
+ };
4651
+
4652
+ const nextYear = function(date, amount = 1) {
4653
+ const year = date.getFullYear();
4654
+ const month = date.getMonth();
4655
+ return changeYearMonthAndClampDate(date, year + amount, month);
4656
+ };
4657
+
4658
+ const extractDateFormat = function(format) {
4659
+ return format
4660
+ .replace(/\W?m{1,2}|\W?ZZ/g, '')
4661
+ .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
4662
+ .trim();
4663
+ };
4664
+
4665
+ const extractTimeFormat = function(format) {
4666
+ return format
4667
+ .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
4668
+ .trim();
4669
+ };
4670
+
4671
+ const validateRangeInOneMonth = function(start, end) {
4672
+ return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
4673
+ };
4674
+
4657
4675
  /**
4658
4676
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
4659
4677
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
4660
4678
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
4661
4679
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
4662
4680
  * @returns {number} 工作日数量
4663
- */
4664
- var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
4665
- var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
4666
-
4667
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
4668
- throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
4669
- }
4670
-
4671
- var startDateObj = new Date(start_date);
4672
- var endDateObj = new Date(end_date);
4673
-
4674
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
4675
- throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
4676
- }
4677
-
4678
- if (startDateObj > endDateObj) {
4679
- throw new Error('Start date should be earlier than or equal to end date.');
4680
- }
4681
-
4682
- var workdays = 0;
4683
-
4684
- // Iterate through each day in the date range
4685
-
4686
- var _loop = function _loop(currentDate) {
4687
- // Check if the current day is a weekend (Saturday or Sunday)
4688
- var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
4689
-
4690
- // Check if the current day is a holiday
4691
- var isHoliday = holidays.some(function (holiday) {
4692
- var holidayDate = new Date(holiday);
4693
- return currentDate.toDateString() === holidayDate.toDateString();
4694
- });
4695
-
4696
- // If it's a workday (not a weekend or holiday), increment the workdays count
4697
- if (!isWeekend && !isHoliday) {
4698
- workdays++;
4699
- }
4700
- };
4701
-
4702
- for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
4703
- _loop(currentDate);
4704
- }
4705
-
4706
- return workdays;
4707
- };
4708
-
4681
+ */
4682
+ const calculateNetworkDays = function (start_date, end_date, holidays = []) {
4683
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
4684
+ throw new Error(
4685
+ "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
4686
+ );
4687
+ }
4688
+
4689
+ const startDateObj = new Date(start_date);
4690
+ const endDateObj = new Date(end_date);
4691
+
4692
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
4693
+ throw new Error(
4694
+ "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
4695
+ );
4696
+ }
4697
+
4698
+ if (startDateObj > endDateObj) {
4699
+ throw new Error('Start date should be earlier than or equal to end date.');
4700
+ }
4701
+
4702
+ let workdays = 0;
4703
+
4704
+ // Iterate through each day in the date range
4705
+ for (
4706
+ let currentDate = new Date(startDateObj);
4707
+ currentDate <= endDateObj;
4708
+ currentDate.setDate(currentDate.getDate() + 1)
4709
+ ) {
4710
+ // Check if the current day is a weekend (Saturday or Sunday)
4711
+ const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
4712
+
4713
+ // Check if the current day is a holiday
4714
+ const isHoliday = holidays.some((holiday) => {
4715
+ const holidayDate = new Date(holiday);
4716
+ return currentDate.toDateString() === holidayDate.toDateString();
4717
+ });
4718
+
4719
+ // If it's a workday (not a weekend or holiday), increment the workdays count
4720
+ if (!isWeekend && !isHoliday) {
4721
+ workdays++;
4722
+ }
4723
+ }
4724
+
4725
+ return workdays;
4726
+ };
4727
+
4709
4728
  /**
4710
4729
  * 日期加减天数
4711
4730
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
4712
4731
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
4713
4732
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
4714
- */
4715
- var dateAddDays = function dateAddDays(start_date, days) {
4716
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
4717
- 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.");
4718
- }
4719
-
4720
- var startDateObj = new Date(start_date);
4721
- if (isNaN(startDateObj.getTime())) {
4722
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
4723
- }
4724
-
4725
- var resultDateObj = new Date(startDateObj);
4726
- resultDateObj.setDate(resultDateObj.getDate() + days);
4727
-
4728
- var resultYear = resultDateObj.getFullYear();
4729
- var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
4730
- var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
4731
-
4732
- return resultYear + '-' + resultMonth + '-' + resultDay;
4733
- };
4734
-
4733
+ */
4734
+ const dateAddDays = function (start_date, days) {
4735
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
4736
+ throw new Error(
4737
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
4738
+ );
4739
+ }
4740
+
4741
+ const startDateObj = new Date(start_date);
4742
+ if (isNaN(startDateObj.getTime())) {
4743
+ throw new Error(
4744
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
4745
+ );
4746
+ }
4747
+
4748
+ const resultDateObj = new Date(startDateObj);
4749
+ resultDateObj.setDate(resultDateObj.getDate() + days);
4750
+
4751
+ const resultYear = resultDateObj.getFullYear();
4752
+ const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
4753
+ const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
4754
+
4755
+ return `${resultYear}-${resultMonth}-${resultDay}`;
4756
+ };
4757
+
4735
4758
  /**
4736
4759
  * 计算两个日期之间的差值
4737
4760
  * @date 2023年12月14日
@@ -4739,180 +4762,182 @@ var dateAddDays = function dateAddDays(start_date, days) {
4739
4762
  * @param {String} end_date - 结束日期字符串
4740
4763
  * @param {String} unit - 单位:year/month/day
4741
4764
  * @returns {Number} 差值
4742
- */
4743
- var dateDiff = function dateDiff(start_date, end_date) {
4744
- var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
4745
-
4746
- // Assuming date strings are in "YYYY-MM-DD" format
4747
- var startDate = new Date(start_date);
4748
- var endDate = new Date(end_date);
4749
-
4750
- // If the date is invalid, return 0
4751
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
4752
- return 0;
4753
- }
4754
-
4755
- if (unit === 'year') {
4756
- return endDate.getFullYear() - startDate.getFullYear();
4757
- } else if (unit === 'month') {
4758
- return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
4759
- } else {
4760
- // Default to day
4761
- var timeDifference = endDate - startDate;
4762
- // Calculate days (86400000 milliseconds per day)
4763
- return Math.floor(timeDifference / 86400000);
4764
- }
4765
- };
4766
-
4765
+ */
4766
+ const dateDiff = function (start_date, end_date, unit = 'day') {
4767
+ // Assuming date strings are in "YYYY-MM-DD" format
4768
+ var startDate = new Date(start_date);
4769
+ var endDate = new Date(end_date);
4770
+
4771
+ // If the date is invalid, return 0
4772
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
4773
+ return 0;
4774
+ }
4775
+
4776
+ if (unit === 'year') {
4777
+ return endDate.getFullYear() - startDate.getFullYear();
4778
+ } else if (unit === 'month') {
4779
+ return (
4780
+ (endDate.getFullYear() - startDate.getFullYear()) * 12 +
4781
+ (endDate.getMonth() - startDate.getMonth())
4782
+ );
4783
+ } else {
4784
+ // Default to day
4785
+ var timeDifference = endDate - startDate;
4786
+ // Calculate days (86400000 milliseconds per day)
4787
+ return Math.floor(timeDifference / 86400000);
4788
+ }
4789
+ };
4790
+
4767
4791
  /**
4768
4792
  * 获取月份中的日期
4769
4793
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
4770
4794
  * @returns {number} 月份中的日期(1-31)
4771
- */
4772
- var dayOfMonth = function dayOfMonth(date) {
4773
- if (typeof date !== 'string') {
4774
- throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
4775
- }
4776
-
4777
- var dateObj = new Date(date);
4778
- if (isNaN(dateObj.getTime())) {
4779
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
4780
- }
4781
-
4782
- return dateObj.getDate();
4783
- };
4784
-
4795
+ */
4796
+ const dayOfMonth = function (date) {
4797
+ if (typeof date !== 'string') {
4798
+ throw new Error(
4799
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
4800
+ );
4801
+ }
4802
+
4803
+ const dateObj = new Date(date);
4804
+ if (isNaN(dateObj.getTime())) {
4805
+ throw new Error(
4806
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
4807
+ );
4808
+ }
4809
+
4810
+ return dateObj.getDate();
4811
+ };
4812
+
4785
4813
  /**
4786
4814
  * 获取当前日期
4787
4815
  * @date 2022年5月7日
4788
4816
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
4789
4817
  * @returns {string} 当前日期的格式化字符串
4790
- */
4791
- var getCurrentDate = function getCurrentDate() {
4792
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
4793
-
4794
- return formatDate(new Date(), format);
4795
- };
4796
-
4818
+ */
4819
+ const getCurrentDate = function (format = 'YYYY-MM-DD') {
4820
+ return formatDate(new Date(), format);
4821
+ };
4822
+
4797
4823
  /**
4798
4824
  * 获取当前日期时间
4799
4825
  * @date 2022年5月7日
4800
4826
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
4801
4827
  * @returns {string} 当前日期时间的格式化字符串
4802
- */
4803
- var getCurrentDateTime = function getCurrentDateTime() {
4804
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
4805
-
4806
- return formatDate(new Date(), format);
4807
- };
4808
-
4828
+ */
4829
+ const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
4830
+ return formatDate(new Date(), format);
4831
+ };
4832
+
4809
4833
  /**
4810
4834
  * 获取小时
4811
4835
  * @date 2022年5月7日
4812
4836
  * @param {Date|string} [date] - 日期对象或日期字符串
4813
4837
  * @returns {number} 小时数(0-23)
4814
- */
4815
- var getHour = function getHour(date) {
4816
- if (!date) {
4817
- return new Date().getHours();
4818
- }
4819
- if (typeof date === 'string') {
4820
- date = new Date(date);
4821
- }
4822
- return date.getHours();
4823
- };
4824
-
4838
+ */
4839
+ const getHour = function (date) {
4840
+ if (!date) {
4841
+ return new Date().getHours();
4842
+ }
4843
+ if (typeof date === 'string') {
4844
+ date = new Date(date);
4845
+ }
4846
+ return date.getHours();
4847
+ };
4848
+
4825
4849
  /**
4826
4850
  * 获取分钟
4827
4851
  * @date 2022年5月7日
4828
4852
  * @param {Date|string} [date] - 日期对象或日期字符串
4829
4853
  * @returns {number} 分钟数(0-59)
4830
- */
4831
- var getMinute = function getMinute(date) {
4832
- if (!date) {
4833
- return new Date().getMinutes();
4834
- }
4835
- if (typeof date === 'string') {
4836
- date = new Date(date);
4837
- }
4838
- return date.getMinutes();
4839
- };
4840
-
4854
+ */
4855
+ const getMinute = function (date) {
4856
+ if (!date) {
4857
+ return new Date().getMinutes();
4858
+ }
4859
+ if (typeof date === 'string') {
4860
+ date = new Date(date);
4861
+ }
4862
+ return date.getMinutes();
4863
+ };
4864
+
4841
4865
  /**
4842
4866
  * 获取月份
4843
4867
  * @date 2022年5月7日
4844
4868
  * @param {Date|string} [date] - 日期对象或日期字符串
4845
4869
  * @returns {number} 月份数(1-12)
4846
- */
4847
- var getMonth = function getMonth(date) {
4848
- if (!date) {
4849
- return new Date().getMonth() + 1;
4850
- }
4851
- if (typeof date === 'string') {
4852
- date = new Date(date);
4853
- }
4854
- return date.getMonth() + 1;
4855
- };
4856
-
4870
+ */
4871
+ const getMonth = function (date) {
4872
+ if (!date) {
4873
+ return new Date().getMonth() + 1;
4874
+ }
4875
+ if (typeof date === 'string') {
4876
+ date = new Date(date);
4877
+ }
4878
+ return date.getMonth() + 1;
4879
+ };
4880
+
4857
4881
  /**
4858
4882
  * 获取秒
4859
4883
  * @date 2022年5月7日
4860
4884
  * @param {Date|string} [date] - 日期对象或日期字符串
4861
4885
  * @returns {number} 秒数(0-59)
4862
- */
4863
- var getSecond = function getSecond(date) {
4864
- if (!date) {
4865
- return new Date().getSeconds();
4866
- }
4867
- if (typeof date === 'string') {
4868
- date = new Date(date);
4869
- }
4870
- return date.getSeconds();
4871
- };
4872
-
4886
+ */
4887
+ const getSecond = function (date) {
4888
+ if (!date) {
4889
+ return new Date().getSeconds();
4890
+ }
4891
+ if (typeof date === 'string') {
4892
+ date = new Date(date);
4893
+ }
4894
+ return date.getSeconds();
4895
+ };
4896
+
4873
4897
  /**
4874
4898
  * 获取星期几
4875
4899
  * @date 2022年5月7日
4876
4900
  * @param {Date|string} [date] - 日期对象或日期字符串
4877
4901
  * @returns {number} 星期几(0-6,0表示星期日)
4878
- */
4879
- var getWeekday = function getWeekday(date) {
4880
- if (!date) {
4881
- return new Date().getDay();
4882
- }
4883
- if (typeof date === 'string') {
4884
- date = new Date(date);
4885
- }
4886
- return date.getDay();
4887
- };
4888
-
4902
+ */
4903
+ const getWeekday = function (date) {
4904
+ if (!date) {
4905
+ return new Date().getDay();
4906
+ }
4907
+ if (typeof date === 'string') {
4908
+ date = new Date(date);
4909
+ }
4910
+ return date.getDay();
4911
+ };
4912
+
4913
+
4889
4914
  /**
4890
4915
  * @desc 获取上午/下午/晚上
4891
4916
  * @author huangbo
4892
4917
  * @date 2022年5月7日
4893
4918
  * @param {String} [time] - 时间
4894
- **/
4895
- var timeCycle = function timeCycle(time) {
4896
- var hour = 0;
4897
- if (!time) {
4898
- hour = new Date().getHours();
4899
- } else if (typeof time === 'string') {
4900
- // 从时间字符串中提取小时
4901
- var match = time.match(/^(\d{1,2})/);
4902
- if (match) {
4903
- hour = parseInt(match[1], 10);
4904
- }
4905
- } else if (typeof time === 'number') {
4906
- hour = time;
4907
- }
4908
- // 判断时间段
4909
- if (hour >= 5 && hour < 12) {
4910
- return '上午';
4911
- } else if (hour >= 12 && hour < 18) {
4912
- return '下午';
4913
- } else {
4914
- return '晚上';
4915
- }
4919
+ **/
4920
+ const timeCycle = function (time) {
4921
+ let hour = 0;
4922
+ if (!time) {
4923
+ hour = new Date().getHours();
4924
+ } else if (typeof time === 'string') {
4925
+ // 从时间字符串中提取小时
4926
+ const match = time.match(/^(\d{1,2})/);
4927
+ if (match) {
4928
+ hour = parseInt(match[1], 10);
4929
+ }
4930
+ } else if (typeof time === 'number') {
4931
+ hour = time;
4932
+ }
4933
+ // 判断时间段
4934
+ if (hour >= 5 && hour < 12) {
4935
+ return '上午';
4936
+ } else if (hour >= 12 && hour < 18) {
4937
+ return '下午';
4938
+ } else {
4939
+ return '晚上';
4940
+ }
4916
4941
  };
4917
4942
 
4918
4943
  /***/ }),