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 = 187);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 189);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -3521,7 +3521,7 @@ module.exports = require("lodash/set");
3521
3521
 
3522
3522
  /***/ }),
3523
3523
 
3524
- /***/ 187:
3524
+ /***/ 189:
3525
3525
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3526
3526
 
3527
3527
  "use strict";
@@ -6961,736 +6961,759 @@ var changeInTime = '/baseIssueRules/changeInTime';
6961
6961
  /* unused harmony export getSecond */
6962
6962
  /* unused harmony export getWeekday */
6963
6963
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
6964
-
6965
-
6964
+ /* Modified from https://github.com/taylorhakes/fecha
6965
+ *
6966
+ * The MIT License (MIT)
6967
+ *
6968
+ * Copyright (c) 2015 Taylor Hakes
6969
+ *
6970
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6971
+ * of this software and associated documentation files (the "Software"), to deal
6972
+ * in the Software without restriction, including without limitation the rights
6973
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6974
+ * copies of the Software, and to permit persons to whom the Software is
6975
+ * furnished to do so, subject to the following conditions:
6976
+ *
6977
+ * The above copyright notice and this permission notice shall be included in all
6978
+ * copies or substantial portions of the Software.
6979
+ *
6980
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6981
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6982
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6983
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6984
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
6985
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
6986
+ * SOFTWARE.
6987
+ */
6988
+
6989
+ /*eslint-disable*/
6990
+ // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
6991
+
6992
+
6966
6993
  /**
6967
6994
  * Parse or format dates
6968
6995
  * @class fecha
6969
- */
6970
- var fecha = {};
6971
- var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
6972
- var twoDigits = '\\d\\d?';
6973
- var threeDigits = '\\d{3}';
6974
- var fourDigits = '\\d{4}';
6975
- var word = '[^\\s]+';
6976
- var literal = /\[([^]*?)\]/gm;
6977
- var noop = function noop() {};
6978
-
6979
- function regexEscape(str) {
6980
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
6981
- }
6982
-
6983
- function shorten(arr, sLen) {
6984
- var newArr = [];
6985
- for (var i = 0, len = arr.length; i < len; i++) {
6986
- newArr.push(arr[i].substr(0, sLen));
6987
- }
6988
- return newArr;
6989
- }
6990
-
6991
- function monthUpdate() {
6992
- return function (d, v) {
6993
- var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
6994
- if (~index) {
6995
- d.month = index;
6996
- }
6997
- };
6998
- }
6999
-
7000
- function pad(val, len) {
7001
- val = String(val);
7002
- len = len || 2;
7003
- while (val.length < len) {
7004
- val = '0' + val;
7005
- }
7006
- return val;
7007
- }
7008
-
7009
- // 直接使用中文日期名称常量
7010
- var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
7011
- var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
7012
- var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
7013
- var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
7014
- var amPm = ['上午', '下午'];
7015
- var DoFn = function DoFn(D) {
7016
- return D + '日';
7017
- };
7018
-
7019
- var formatFlags = {
7020
- D: function D(dateObj) {
7021
- return dateObj.getDay();
7022
- },
7023
- DD: function DD(dateObj) {
7024
- return pad(dateObj.getDay());
7025
- },
7026
- Do: function Do(dateObj) {
7027
- return DoFn(dateObj.getDate());
7028
- },
7029
- d: function d(dateObj) {
7030
- return dateObj.getDate();
7031
- },
7032
- dd: function dd(dateObj) {
7033
- return pad(dateObj.getDate());
7034
- },
7035
- ddd: function ddd(dateObj) {
7036
- return dayNamesShort[dateObj.getDay()];
7037
- },
7038
- dddd: function dddd(dateObj) {
7039
- return dayNames[dateObj.getDay()];
7040
- },
7041
- M: function M(dateObj) {
7042
- return dateObj.getMonth() + 1;
7043
- },
7044
- MM: function MM(dateObj) {
7045
- return pad(dateObj.getMonth() + 1);
7046
- },
7047
- MMM: function MMM(dateObj) {
7048
- return monthNamesShort[dateObj.getMonth()];
7049
- },
7050
- MMMM: function MMMM(dateObj) {
7051
- return monthNames[dateObj.getMonth()];
7052
- },
7053
- yy: function yy(dateObj) {
7054
- return pad(String(dateObj.getFullYear()), 4).substr(2);
7055
- },
7056
- yyyy: function yyyy(dateObj) {
7057
- return pad(dateObj.getFullYear(), 4);
7058
- },
7059
- h: function h(dateObj) {
7060
- return dateObj.getHours() % 12 || 12;
7061
- },
7062
- hh: function hh(dateObj) {
7063
- return pad(dateObj.getHours() % 12 || 12);
7064
- },
7065
- H: function H(dateObj) {
7066
- return dateObj.getHours();
7067
- },
7068
- HH: function HH(dateObj) {
7069
- return pad(dateObj.getHours());
7070
- },
7071
- m: function m(dateObj) {
7072
- return dateObj.getMinutes();
7073
- },
7074
- mm: function mm(dateObj) {
7075
- return pad(dateObj.getMinutes());
7076
- },
7077
- s: function s(dateObj) {
7078
- return dateObj.getSeconds();
7079
- },
7080
- ss: function ss(dateObj) {
7081
- return pad(dateObj.getSeconds());
7082
- },
7083
- S: function S(dateObj) {
7084
- return Math.round(dateObj.getMilliseconds() / 100);
7085
- },
7086
- SS: function SS(dateObj) {
7087
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
7088
- },
7089
- SSS: function SSS(dateObj) {
7090
- return pad(dateObj.getMilliseconds(), 3);
7091
- },
7092
- a: function a(dateObj) {
7093
- return dateObj.getHours() < 12 ? '上午' : '下午';
7094
- },
7095
- A: function A(dateObj) {
7096
- return dateObj.getHours() < 12 ? '上午' : '下午';
7097
- },
7098
- ZZ: function ZZ(dateObj) {
7099
- var o = dateObj.getTimezoneOffset();
7100
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
7101
- }
7102
- };
7103
-
7104
- var parseFlags = {
7105
- d: [twoDigits, function (d, v) {
7106
- d.day = v;
7107
- }],
7108
- Do: [twoDigits + word, function (d, v) {
7109
- d.day = parseInt(v, 10);
7110
- }],
7111
- M: [twoDigits, function (d, v) {
7112
- d.month = v - 1;
7113
- }],
7114
- yy: [twoDigits, function (d, v) {
7115
- var da = new Date(),
7116
- cent = +('' + da.getFullYear()).substr(0, 2);
7117
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
7118
- }],
7119
- h: [twoDigits, function (d, v) {
7120
- d.hour = v;
7121
- }],
7122
- m: [twoDigits, function (d, v) {
7123
- d.minute = v;
7124
- }],
7125
- s: [twoDigits, function (d, v) {
7126
- d.second = v;
7127
- }],
7128
- yyyy: [fourDigits, function (d, v) {
7129
- d.year = v;
7130
- }],
7131
- S: ['\\d', function (d, v) {
7132
- d.millisecond = v * 100;
7133
- }],
7134
- SS: ['\\d{2}', function (d, v) {
7135
- d.millisecond = v * 10;
7136
- }],
7137
- SSS: [threeDigits, function (d, v) {
7138
- d.millisecond = v;
7139
- }],
7140
- D: [twoDigits, noop],
7141
- ddd: [word, noop],
7142
- MMM: [word, monthUpdate('monthNamesShort')],
7143
- MMMM: [word, monthUpdate('monthNames')],
7144
- a: [word, function (d, v) {
7145
- var val = v.toLowerCase();
7146
- if (val === '上午') {
7147
- d.isPm = false;
7148
- } else if (val === '下午') {
7149
- d.isPm = true;
7150
- }
7151
- }],
7152
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
7153
- var parts = (v + '').match(/([+-]|\d\d)/gi),
7154
- minutes = void 0;
7155
-
7156
- if (parts) {
7157
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
7158
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
7159
- }
7160
- }]
7161
- };
7162
- parseFlags.dd = parseFlags.d;
7163
- parseFlags.dddd = parseFlags.ddd;
7164
- parseFlags.DD = parseFlags.D;
7165
- parseFlags.mm = parseFlags.m;
7166
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
7167
- parseFlags.MM = parseFlags.M;
7168
- parseFlags.ss = parseFlags.s;
7169
- parseFlags.A = parseFlags.a;
7170
-
7171
- // Some common format strings
7172
- fecha.masks = {
7173
- default: 'ddd MMM dd yyyy HH:mm:ss',
7174
- shortDate: 'M/D/yy',
7175
- mediumDate: 'MMM d, yyyy',
7176
- longDate: 'MMMM d, yyyy',
7177
- fullDate: 'dddd, MMMM d, yyyy',
7178
- shortTime: 'HH:mm',
7179
- mediumTime: 'HH:mm:ss',
7180
- longTime: 'HH:mm:ss.SSS'
7181
- };
7182
-
6996
+ */
6997
+ const fecha = {};
6998
+ const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
6999
+ const twoDigits = '\\d\\d?';
7000
+ const threeDigits = '\\d{3}';
7001
+ const fourDigits = '\\d{4}';
7002
+ const word = '[^\\s]+';
7003
+ const literal = /\[([^]*?)\]/gm;
7004
+ const noop = function () {};
7005
+
7006
+ function regexEscape(str) {
7007
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
7008
+ }
7009
+
7010
+ function shorten(arr, sLen) {
7011
+ const newArr = [];
7012
+ for (let i = 0, len = arr.length; i < len; i++) {
7013
+ newArr.push(arr[i].substr(0, sLen));
7014
+ }
7015
+ return newArr;
7016
+ }
7017
+
7018
+ function monthUpdate() {
7019
+ return function (d, v) {
7020
+ const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
7021
+ if (~index) {
7022
+ d.month = index;
7023
+ }
7024
+ };
7025
+ }
7026
+
7027
+ function pad(val, len) {
7028
+ val = String(val);
7029
+ len = len || 2;
7030
+ while (val.length < len) {
7031
+ val = '0' + val;
7032
+ }
7033
+ return val;
7034
+ }
7035
+
7036
+ // 直接使用中文日期名称常量
7037
+ const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
7038
+ const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
7039
+ const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
7040
+ const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
7041
+ const amPm = ['上午', '下午'];
7042
+ const DoFn = function DoFn(D) {
7043
+ return D + '日';
7044
+ };
7045
+
7046
+ const formatFlags = {
7047
+ D: function(dateObj) {
7048
+ return dateObj.getDay();
7049
+ },
7050
+ DD: function(dateObj) {
7051
+ return pad(dateObj.getDay());
7052
+ },
7053
+ Do: function(dateObj) {
7054
+ return DoFn(dateObj.getDate());
7055
+ },
7056
+ d: function(dateObj) {
7057
+ return dateObj.getDate();
7058
+ },
7059
+ dd: function(dateObj) {
7060
+ return pad(dateObj.getDate());
7061
+ },
7062
+ ddd: function(dateObj) {
7063
+ return dayNamesShort[dateObj.getDay()];
7064
+ },
7065
+ dddd: function(dateObj) {
7066
+ return dayNames[dateObj.getDay()];
7067
+ },
7068
+ M: function(dateObj) {
7069
+ return dateObj.getMonth() + 1;
7070
+ },
7071
+ MM: function(dateObj) {
7072
+ return pad(dateObj.getMonth() + 1);
7073
+ },
7074
+ MMM: function(dateObj) {
7075
+ return monthNamesShort[dateObj.getMonth()];
7076
+ },
7077
+ MMMM: function(dateObj) {
7078
+ return monthNames[dateObj.getMonth()];
7079
+ },
7080
+ yy: function(dateObj) {
7081
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
7082
+ },
7083
+ yyyy: function(dateObj) {
7084
+ return pad(dateObj.getFullYear(), 4);
7085
+ },
7086
+ h: function(dateObj) {
7087
+ return dateObj.getHours() % 12 || 12;
7088
+ },
7089
+ hh: function(dateObj) {
7090
+ return pad(dateObj.getHours() % 12 || 12);
7091
+ },
7092
+ H: function(dateObj) {
7093
+ return dateObj.getHours();
7094
+ },
7095
+ HH: function(dateObj) {
7096
+ return pad(dateObj.getHours());
7097
+ },
7098
+ m: function(dateObj) {
7099
+ return dateObj.getMinutes();
7100
+ },
7101
+ mm: function(dateObj) {
7102
+ return pad(dateObj.getMinutes());
7103
+ },
7104
+ s: function(dateObj) {
7105
+ return dateObj.getSeconds();
7106
+ },
7107
+ ss: function(dateObj) {
7108
+ return pad(dateObj.getSeconds());
7109
+ },
7110
+ S: function(dateObj) {
7111
+ return Math.round(dateObj.getMilliseconds() / 100);
7112
+ },
7113
+ SS: function(dateObj) {
7114
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
7115
+ },
7116
+ SSS: function(dateObj) {
7117
+ return pad(dateObj.getMilliseconds(), 3);
7118
+ },
7119
+ a: function(dateObj) {
7120
+ return dateObj.getHours() < 12 ? '上午' : '下午';
7121
+ },
7122
+ A: function(dateObj) {
7123
+ return dateObj.getHours() < 12 ? '上午' : '下午';
7124
+ },
7125
+ ZZ: function(dateObj) {
7126
+ const o = dateObj.getTimezoneOffset();
7127
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
7128
+ }
7129
+ };
7130
+
7131
+ const parseFlags = {
7132
+ d: [twoDigits, function (d, v) {
7133
+ d.day = v;
7134
+ }],
7135
+ Do: [twoDigits + word, function (d, v) {
7136
+ d.day = parseInt(v, 10);
7137
+ }],
7138
+ M: [twoDigits, function (d, v) {
7139
+ d.month = v - 1;
7140
+ }],
7141
+ yy: [twoDigits, function (d, v) {
7142
+ const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
7143
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
7144
+ }],
7145
+ h: [twoDigits, function (d, v) {
7146
+ d.hour = v;
7147
+ }],
7148
+ m: [twoDigits, function (d, v) {
7149
+ d.minute = v;
7150
+ }],
7151
+ s: [twoDigits, function (d, v) {
7152
+ d.second = v;
7153
+ }],
7154
+ yyyy: [fourDigits, function (d, v) {
7155
+ d.year = v;
7156
+ }],
7157
+ S: ['\\d', function (d, v) {
7158
+ d.millisecond = v * 100;
7159
+ }],
7160
+ SS: ['\\d{2}', function (d, v) {
7161
+ d.millisecond = v * 10;
7162
+ }],
7163
+ SSS: [threeDigits, function (d, v) {
7164
+ d.millisecond = v;
7165
+ }],
7166
+ D: [twoDigits, noop],
7167
+ ddd: [word, noop],
7168
+ MMM: [word, monthUpdate('monthNamesShort')],
7169
+ MMMM: [word, monthUpdate('monthNames')],
7170
+ a: [word, function (d, v) {
7171
+ const val = v.toLowerCase();
7172
+ if (val === '上午') {
7173
+ d.isPm = false;
7174
+ } else if (val === '下午') {
7175
+ d.isPm = true;
7176
+ }
7177
+ }],
7178
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
7179
+ let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
7180
+
7181
+ if (parts) {
7182
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
7183
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
7184
+ }
7185
+ }]
7186
+ };
7187
+ parseFlags.dd = parseFlags.d;
7188
+ parseFlags.dddd = parseFlags.ddd;
7189
+ parseFlags.DD = parseFlags.D;
7190
+ parseFlags.mm = parseFlags.m;
7191
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
7192
+ parseFlags.MM = parseFlags.M;
7193
+ parseFlags.ss = parseFlags.s;
7194
+ parseFlags.A = parseFlags.a;
7195
+
7196
+
7197
+ // Some common format strings
7198
+ fecha.masks = {
7199
+ default: 'ddd MMM dd yyyy HH:mm:ss',
7200
+ shortDate: 'M/D/yy',
7201
+ mediumDate: 'MMM d, yyyy',
7202
+ longDate: 'MMMM d, yyyy',
7203
+ fullDate: 'dddd, MMMM d, yyyy',
7204
+ shortTime: 'HH:mm',
7205
+ mediumTime: 'HH:mm:ss',
7206
+ longTime: 'HH:mm:ss.SSS'
7207
+ };
7208
+
7183
7209
  /***
7184
7210
  * Format a date
7185
7211
  * @method format
7186
7212
  * @param {Date|number} dateObj
7187
7213
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
7188
- */
7189
- fecha.format = function (dateObj, mask) {
7190
- if (typeof dateObj === 'number') {
7191
- dateObj = new Date(dateObj);
7192
- }
7193
-
7194
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
7195
- throw new Error('Invalid Date in fecha.format');
7196
- }
7197
-
7198
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
7199
-
7200
- var literals = [];
7201
-
7202
- // Make literals inactive by replacing them with ??
7203
- mask = mask.replace(literal, function ($0, $1) {
7204
- literals.push($1);
7205
- return '@@@';
7206
- });
7207
- // Apply formatting rules
7208
- mask = mask.replace(token, function ($0) {
7209
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
7210
- });
7211
- // Inline literal values back into the formatted value
7212
- return mask.replace(/@@@/g, function () {
7213
- return literals.shift();
7214
- });
7215
- };
7216
-
7214
+ */
7215
+ fecha.format = function (dateObj, mask) {
7216
+ if (typeof dateObj === 'number') {
7217
+ dateObj = new Date(dateObj);
7218
+ }
7219
+
7220
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
7221
+ throw new Error('Invalid Date in fecha.format');
7222
+ }
7223
+
7224
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
7225
+
7226
+ const literals = [];
7227
+
7228
+ // Make literals inactive by replacing them with ??
7229
+ mask = mask.replace(literal, function($0, $1) {
7230
+ literals.push($1);
7231
+ return '@@@';
7232
+ });
7233
+ // Apply formatting rules
7234
+ mask = mask.replace(token, function ($0) {
7235
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
7236
+ });
7237
+ // Inline literal values back into the formatted value
7238
+ return mask.replace(/@@@/g, function() {
7239
+ return literals.shift();
7240
+ });
7241
+ };
7242
+
7217
7243
  /**
7218
7244
  * Parse a date string into an object, changes - into /
7219
7245
  * @method parse
7220
7246
  * @param {string} dateStr Date string
7221
7247
  * @param {string} format Date parse format
7222
7248
  * @returns {Date|boolean}
7223
- */
7224
- fecha.parse = function (dateStr, format) {
7225
- if (typeof format !== 'string') {
7226
- throw new Error('Invalid format in fecha.parse');
7227
- }
7228
-
7229
- format = fecha.masks[format] || format;
7230
-
7231
- // Avoid regular expression denial of service, fail early for really long strings
7232
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
7233
- if (dateStr.length > 1000) {
7234
- return null;
7235
- }
7236
-
7237
- var dateInfo = {};
7238
- var parseInfo = [];
7239
- var literals = [];
7240
- format = format.replace(literal, function ($0, $1) {
7241
- literals.push($1);
7242
- return '@@@';
7243
- });
7244
- var newFormat = regexEscape(format).replace(token, function ($0) {
7245
- if (parseFlags[$0]) {
7246
- var info = parseFlags[$0];
7247
- parseInfo.push(info[1]);
7248
- return '(' + info[0] + ')';
7249
- }
7250
-
7251
- return $0;
7252
- });
7253
- newFormat = newFormat.replace(/@@@/g, function () {
7254
- return literals.shift();
7255
- });
7256
- var matches = dateStr.match(new RegExp(newFormat, 'i'));
7257
- if (!matches) {
7258
- return null;
7259
- }
7260
-
7261
- for (var i = 1; i < matches.length; i++) {
7262
- parseInfo[i - 1](dateInfo, matches[i]);
7263
- }
7264
-
7265
- var today = new Date();
7266
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
7267
- dateInfo.hour = +dateInfo.hour + 12;
7268
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
7269
- dateInfo.hour = 0;
7270
- }
7271
-
7272
- var date = void 0;
7273
- if (dateInfo.timezoneOffset != null) {
7274
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
7275
- 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));
7276
- } else {
7277
- 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);
7278
- }
7279
- return date;
7280
- };
7281
-
7282
- // 导出fecha对象
7283
-
7284
-
7285
- // 以下是从date-util.js合并的函数
7286
- var newArray = function newArray(start, end) {
7287
- var result = [];
7288
- for (var i = start; i <= end; i++) {
7289
- result.push(i);
7290
- }
7291
- return result;
7292
- };
7293
-
7294
- var getSettings = function getSettings() {
7295
- return {
7296
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
7297
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
7298
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
7299
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
7300
- amPm: ['上午', '下午']
7301
- };
7302
- };
7303
-
7304
- var toDate = function toDate(date) {
7305
- return isDate(date) ? new Date(date) : null;
7306
- };
7307
-
7308
- var isDate = function isDate(date) {
7309
- if (date === null || date === undefined) return false;
7310
- if (isNaN(new Date(date).getTime())) return false;
7311
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
7312
- return true;
7313
- };
7314
-
7315
- var isDateObject = function isDateObject(val) {
7316
- return val instanceof Date;
7317
- };
7318
-
7319
- var formatDate = function formatDate(date) {
7320
- var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
7321
-
7322
- // 处理多种输入类型
7323
- if (!date) return '';
7324
-
7325
- // 如果是时间戳,转成日期对象
7326
- if (typeof date === 'number') {
7327
- date = new Date(date);
7328
- }
7329
- // 如果是字符串,转成日期对象
7330
- if (typeof date === 'string') {
7331
- date = new Date(date);
7332
- }
7333
-
7334
- // 调用toDate进一步验证和转换
7335
- date = toDate(date);
7336
- if (!date) return '';
7337
-
7338
- // 兼容大写和小写的格式标记
7339
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
7340
- var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
7341
-
7342
- // 使用fecha库进行格式化,支持中文配置
7343
- var str = fecha.format(date, lowercaseFormat, getSettings());
7344
- return str;
7345
- };
7346
-
7347
- var parseDate = function parseDate(string, format) {
7348
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
7349
- };
7350
-
7351
- var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
7352
- if (month === 3 || month === 5 || month === 8 || month === 10) {
7353
- return 30;
7354
- }
7355
-
7356
- if (month === 1) {
7357
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
7358
- return 29;
7359
- } else {
7360
- return 28;
7361
- }
7362
- }
7363
-
7364
- return 31;
7365
- };
7366
-
7367
- var getDayCountOfYear = function getDayCountOfYear(year) {
7368
- var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
7369
- return isLeapYear ? 366 : 365;
7370
- };
7371
-
7372
- var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
7373
- var temp = new Date(date.getTime());
7374
- temp.setDate(1);
7375
- return temp.getDay();
7376
- };
7377
-
7378
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
7379
- // {prev, next} Date should work for Daylight Saving Time
7380
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
7381
- var prevDate = function prevDate(date) {
7382
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
7383
-
7384
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
7385
- };
7386
-
7387
- var nextDate = function nextDate(date) {
7388
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
7389
-
7390
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
7391
- };
7392
-
7393
- var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
7394
- var result = new Date(year, month, 1);
7395
- var day = result.getDay();
7396
-
7397
- if (day === 0) {
7398
- return prevDate(result, 7);
7399
- } else {
7400
- return prevDate(result, day);
7401
- }
7402
- };
7403
-
7404
- var getWeekNumber = function getWeekNumber(date) {
7405
- // 支持多种输入类型
7406
- if (!date || !isDate(date)) {
7407
- date = new Date();
7408
- }
7409
- if (typeof date === 'string') {
7410
- date = new Date(date);
7411
- }
7412
-
7413
- // 验证日期有效性
7414
- if (!isDate(date)) return null;
7415
-
7416
- var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
7417
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
7418
- // 将星期日的星期数设为7
7419
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
7420
- // 获取当年的第一天
7421
- var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
7422
- // 计算到最近的星期四的完整周数
7423
- var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
7424
- // 返回周数
7425
- return weekNo;
7426
- };
7427
-
7428
- var getRangeHours = function getRangeHours(ranges) {
7429
- var hours = [];
7430
- var disabledHours = [];
7431
-
7432
- (ranges || []).forEach(function (range) {
7433
- var value = range.map(function (date) {
7434
- return date.getHours();
7435
- });
7436
-
7437
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
7438
- });
7439
-
7440
- if (disabledHours.length) {
7441
- for (var i = 0; i < 24; i++) {
7442
- hours[i] = disabledHours.indexOf(i) === -1;
7443
- }
7444
- } else {
7445
- for (var _i = 0; _i < 24; _i++) {
7446
- hours[_i] = false;
7447
- }
7448
- }
7449
-
7450
- return hours;
7451
- };
7452
-
7453
- var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
7454
- if (amount <= 0) return [];
7455
- var temp = new Date(date.getTime());
7456
- temp.setDate(0);
7457
- var lastDay = temp.getDate();
7458
- return range(amount).map(function (_, index) {
7459
- return lastDay - (amount - index - 1);
7460
- });
7461
- };
7462
-
7463
- var getMonthDays = function getMonthDays(date) {
7464
- var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
7465
- var days = temp.getDate();
7466
- return range(days).map(function (_, index) {
7467
- return index + 1;
7468
- });
7469
- };
7470
-
7471
- function setRangeData(arr, start, end, value) {
7472
- for (var i = start; i < end; i++) {
7473
- arr[i] = value;
7474
- }
7475
- }
7476
-
7477
- var getRangeMinutes = function getRangeMinutes(ranges, hour) {
7478
- var minutes = new Array(60);
7479
-
7480
- if (ranges.length > 0) {
7481
- ranges.forEach(function (range) {
7482
- var start = range[0];
7483
- var end = range[1];
7484
- var startHour = start.getHours();
7485
- var startMinute = start.getMinutes();
7486
- var endHour = end.getHours();
7487
- var endMinute = end.getMinutes();
7488
- if (startHour === hour && endHour !== hour) {
7489
- setRangeData(minutes, startMinute, 60, true);
7490
- } else if (startHour === hour && endHour === hour) {
7491
- setRangeData(minutes, startMinute, endMinute + 1, true);
7492
- } else if (startHour !== hour && endHour === hour) {
7493
- setRangeData(minutes, 0, endMinute + 1, true);
7494
- } else if (startHour < hour && endHour > hour) {
7495
- setRangeData(minutes, 0, 60, true);
7496
- }
7497
- });
7498
- } else {
7499
- setRangeData(minutes, 0, 60, true);
7500
- }
7501
- return minutes;
7502
- };
7503
-
7504
- var range = function range(n) {
7505
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
7506
- return Array.apply(null, { length: n }).map(function (_, n) {
7507
- return n;
7508
- });
7509
- };
7510
-
7511
- var modifyDate = function modifyDate(date, y, m, d) {
7512
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
7513
- };
7514
-
7515
- var modifyTime = function modifyTime(date, h, m, s) {
7516
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
7517
- };
7518
-
7519
- var modifyWithTimeString = function modifyWithTimeString(date, time) {
7520
- if (date == null || !time) {
7521
- return date;
7522
- }
7523
- time = parseDate(time, 'HH:mm:ss');
7524
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
7525
- };
7526
-
7527
- var clearTime = function clearTime(date) {
7528
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
7529
- };
7530
-
7531
- var clearMilliseconds = function clearMilliseconds(date) {
7532
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
7533
- };
7534
-
7535
- var limitTimeRange = function limitTimeRange(date, ranges) {
7536
- var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
7537
-
7538
- // TODO: refactory a more elegant solution
7539
- if (ranges.length === 0) return date;
7540
- var normalizeDate = function normalizeDate(date) {
7541
- return fecha.parse(fecha.format(date, format), format);
7542
- };
7543
- var ndate = normalizeDate(date);
7544
- var nranges = ranges.map(function (range) {
7545
- return range.map(normalizeDate);
7546
- });
7547
- if (nranges.some(function (nrange) {
7548
- return ndate >= nrange[0] && ndate <= nrange[1];
7549
- })) return date;
7550
-
7551
- var minDate = nranges[0][0];
7552
- var maxDate = nranges[0][0];
7553
-
7554
- nranges.forEach(function (nrange) {
7555
- minDate = new Date(Math.min(nrange[0], minDate));
7556
- maxDate = new Date(Math.max(nrange[1], minDate));
7557
- });
7558
-
7559
- var ret = ndate < minDate ? minDate : maxDate;
7560
- // preserve Year/Month/Date
7561
- return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
7562
- };
7563
-
7564
- var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
7565
- var limitedDate = limitTimeRange(date, selectableRange, format);
7566
- return limitedDate.getTime() === date.getTime();
7567
- };
7568
-
7569
- var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
7570
- // clamp date to the number of days in `year`, `month`
7571
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
7572
- var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
7573
- return modifyDate(date, year, month, monthDate);
7574
- };
7575
-
7576
- var prevMonth = function prevMonth(date) {
7577
- var year = date.getFullYear();
7578
- var month = date.getMonth();
7579
- return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
7580
- };
7581
-
7582
- var nextMonth = function nextMonth(date) {
7583
- var year = date.getFullYear();
7584
- var month = date.getMonth();
7585
- return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
7586
- };
7587
-
7588
- var prevYear = function prevYear(date) {
7589
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
7590
-
7591
- var year = date.getFullYear();
7592
- var month = date.getMonth();
7593
- return changeYearMonthAndClampDate(date, year - amount, month);
7594
- };
7595
-
7596
- var nextYear = function nextYear(date) {
7597
- var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
7598
-
7599
- var year = date.getFullYear();
7600
- var month = date.getMonth();
7601
- return changeYearMonthAndClampDate(date, year + amount, month);
7602
- };
7603
-
7604
- var extractDateFormat = function extractDateFormat(format) {
7605
- return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
7606
- };
7607
-
7608
- var extractTimeFormat = function extractTimeFormat(format) {
7609
- return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
7610
- };
7611
-
7612
- var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
7613
- return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
7614
- };
7615
-
7249
+ */
7250
+ fecha.parse = function (dateStr, format) {
7251
+ if (typeof format !== 'string') {
7252
+ throw new Error('Invalid format in fecha.parse');
7253
+ }
7254
+
7255
+ format = fecha.masks[format] || format;
7256
+
7257
+ // Avoid regular expression denial of service, fail early for really long strings
7258
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
7259
+ if (dateStr.length > 1000) {
7260
+ return null;
7261
+ }
7262
+
7263
+ const dateInfo = {};
7264
+ const parseInfo = [];
7265
+ const literals = [];
7266
+ format = format.replace(literal, function($0, $1) {
7267
+ literals.push($1);
7268
+ return '@@@';
7269
+ });
7270
+ let newFormat = regexEscape(format).replace(token, function ($0) {
7271
+ if (parseFlags[$0]) {
7272
+ const info = parseFlags[$0];
7273
+ parseInfo.push(info[1]);
7274
+ return '(' + info[0] + ')';
7275
+ }
7276
+
7277
+ return $0;
7278
+ });
7279
+ newFormat = newFormat.replace(/@@@/g, function() {
7280
+ return literals.shift();
7281
+ });
7282
+ const matches = dateStr.match(new RegExp(newFormat, 'i'));
7283
+ if (!matches) {
7284
+ return null;
7285
+ }
7286
+
7287
+ for (let i = 1; i < matches.length; i++) {
7288
+ parseInfo[i - 1](dateInfo, matches[i]);
7289
+ }
7290
+
7291
+ const today = new Date();
7292
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
7293
+ dateInfo.hour = +dateInfo.hour + 12;
7294
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
7295
+ dateInfo.hour = 0;
7296
+ }
7297
+
7298
+ let date;
7299
+ if (dateInfo.timezoneOffset != null) {
7300
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
7301
+ date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
7302
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
7303
+ } else {
7304
+ date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
7305
+ dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
7306
+ }
7307
+ return date;
7308
+ };
7309
+
7310
+ // 导出fecha对象
7311
+
7312
+
7313
+ // 以下是从date-util.js合并的函数
7314
+ const newArray = function(start, end) {
7315
+ let result = [];
7316
+ for (let i = start; i <= end; i++) {
7317
+ result.push(i);
7318
+ }
7319
+ return result;
7320
+ };
7321
+
7322
+ const getSettings = () => {
7323
+ return {
7324
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
7325
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
7326
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
7327
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
7328
+ amPm: ['上午', '下午']
7329
+ };
7330
+ };
7331
+
7332
+ const toDate = function(date) {
7333
+ return isDate(date) ? new Date(date) : null;
7334
+ };
7335
+
7336
+ const isDate = function(date) {
7337
+ if (date === null || date === undefined) return false;
7338
+ if (isNaN(new Date(date).getTime())) return false;
7339
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
7340
+ return true;
7341
+ };
7342
+
7343
+ const isDateObject = function(val) {
7344
+ return val instanceof Date;
7345
+ };
7346
+
7347
+ const formatDate = function (date, format = 'yyyy-MM-dd') {
7348
+ // 处理多种输入类型
7349
+ if (!date) return '';
7350
+
7351
+ // 如果是时间戳,转成日期对象
7352
+ if (typeof date === 'number') {
7353
+ date = new Date(date);
7354
+ }
7355
+ // 如果是字符串,转成日期对象
7356
+ if (typeof date === 'string') {
7357
+ date = new Date(date);
7358
+ }
7359
+
7360
+ // 调用toDate进一步验证和转换
7361
+ date = toDate(date);
7362
+ if (!date) return '';
7363
+
7364
+ // 兼容大写和小写的格式标记
7365
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
7366
+ const lowercaseFormat = format
7367
+ .replace(/YYYY/g, 'yyyy')
7368
+ .replace(/D/g, 'd')
7369
+
7370
+ // 使用fecha库进行格式化,支持中文配置
7371
+ const str = fecha.format(date, lowercaseFormat, getSettings());
7372
+ return str;
7373
+ };
7374
+
7375
+ const parseDate = function(string, format) {
7376
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
7377
+ };
7378
+
7379
+ const getDayCountOfMonth = function(year, month) {
7380
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
7381
+ return 30;
7382
+ }
7383
+
7384
+ if (month === 1) {
7385
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
7386
+ return 29;
7387
+ } else {
7388
+ return 28;
7389
+ }
7390
+ }
7391
+
7392
+ return 31;
7393
+ };
7394
+
7395
+ const getDayCountOfYear = function(year) {
7396
+ const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
7397
+ return isLeapYear ? 366 : 365;
7398
+ };
7399
+
7400
+ const getFirstDayOfMonth = function(date) {
7401
+ const temp = new Date(date.getTime());
7402
+ temp.setDate(1);
7403
+ return temp.getDay();
7404
+ };
7405
+
7406
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
7407
+ // {prev, next} Date should work for Daylight Saving Time
7408
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
7409
+ const prevDate = function(date, amount = 1) {
7410
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
7411
+ };
7412
+
7413
+ const nextDate = function(date, amount = 1) {
7414
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
7415
+ };
7416
+
7417
+ const getStartDateOfMonth = function(year, month) {
7418
+ const result = new Date(year, month, 1);
7419
+ const day = result.getDay();
7420
+
7421
+ if (day === 0) {
7422
+ return prevDate(result, 7);
7423
+ } else {
7424
+ return prevDate(result, day);
7425
+ }
7426
+ };
7427
+
7428
+ const getWeekNumber = function(date) {
7429
+ // 支持多种输入类型
7430
+ if (!date||!isDate(date)) {
7431
+ date = new Date();
7432
+ }
7433
+ if (typeof date === 'string') {
7434
+ date = new Date(date);
7435
+ }
7436
+
7437
+ // 验证日期有效性
7438
+ if (!isDate(date)) return null;
7439
+
7440
+ const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
7441
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
7442
+ // 将星期日的星期数设为7
7443
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
7444
+ // 获取当年的第一天
7445
+ const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
7446
+ // 计算到最近的星期四的完整周数
7447
+ const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
7448
+ // 返回周数
7449
+ return weekNo;
7450
+ };
7451
+
7452
+ const getRangeHours = function(ranges) {
7453
+ const hours = [];
7454
+ let disabledHours = [];
7455
+
7456
+ (ranges || []).forEach(range => {
7457
+ const value = range.map(date => date.getHours());
7458
+
7459
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
7460
+ });
7461
+
7462
+ if (disabledHours.length) {
7463
+ for (let i = 0; i < 24; i++) {
7464
+ hours[i] = disabledHours.indexOf(i) === -1;
7465
+ }
7466
+ } else {
7467
+ for (let i = 0; i < 24; i++) {
7468
+ hours[i] = false;
7469
+ }
7470
+ }
7471
+
7472
+ return hours;
7473
+ };
7474
+
7475
+ const getPrevMonthLastDays = (date, amount) => {
7476
+ if (amount <= 0) return [];
7477
+ const temp = new Date(date.getTime());
7478
+ temp.setDate(0);
7479
+ const lastDay = temp.getDate();
7480
+ return range(amount).map((_, index) => lastDay - (amount - index - 1));
7481
+ };
7482
+
7483
+ const getMonthDays = (date) => {
7484
+ const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
7485
+ const days = temp.getDate();
7486
+ return range(days).map((_, index) => index + 1);
7487
+ };
7488
+
7489
+ function setRangeData(arr, start, end, value) {
7490
+ for (let i = start; i < end; i++) {
7491
+ arr[i] = value;
7492
+ }
7493
+ }
7494
+
7495
+ const getRangeMinutes = function(ranges, hour) {
7496
+ const minutes = new Array(60);
7497
+
7498
+ if (ranges.length > 0) {
7499
+ ranges.forEach(range => {
7500
+ const start = range[0];
7501
+ const end = range[1];
7502
+ const startHour = start.getHours();
7503
+ const startMinute = start.getMinutes();
7504
+ const endHour = end.getHours();
7505
+ const endMinute = end.getMinutes();
7506
+ if (startHour === hour && endHour !== hour) {
7507
+ setRangeData(minutes, startMinute, 60, true);
7508
+ } else if (startHour === hour && endHour === hour) {
7509
+ setRangeData(minutes, startMinute, endMinute + 1, true);
7510
+ } else if (startHour !== hour && endHour === hour) {
7511
+ setRangeData(minutes, 0, endMinute + 1, true);
7512
+ } else if (startHour < hour && endHour > hour) {
7513
+ setRangeData(minutes, 0, 60, true);
7514
+ }
7515
+ });
7516
+ } else {
7517
+ setRangeData(minutes, 0, 60, true);
7518
+ }
7519
+ return minutes;
7520
+ };
7521
+
7522
+ const range = function(n) {
7523
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
7524
+ return Array.apply(null, {length: n}).map((_, n) => n);
7525
+ };
7526
+
7527
+ const modifyDate = function(date, y, m, d) {
7528
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
7529
+ };
7530
+
7531
+ const modifyTime = function(date, h, m, s) {
7532
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
7533
+ };
7534
+
7535
+ const modifyWithTimeString = (date, time) => {
7536
+ if (date == null || !time) {
7537
+ return date;
7538
+ }
7539
+ time = parseDate(time, 'HH:mm:ss');
7540
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
7541
+ };
7542
+
7543
+ const clearTime = function(date) {
7544
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
7545
+ };
7546
+
7547
+ const clearMilliseconds = function(date) {
7548
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
7549
+ };
7550
+
7551
+ const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
7552
+ // TODO: refactory a more elegant solution
7553
+ if (ranges.length === 0) return date;
7554
+ const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
7555
+ const ndate = normalizeDate(date);
7556
+ const nranges = ranges.map(range => range.map(normalizeDate));
7557
+ if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
7558
+
7559
+ let minDate = nranges[0][0];
7560
+ let maxDate = nranges[0][0];
7561
+
7562
+ nranges.forEach(nrange => {
7563
+ minDate = new Date(Math.min(nrange[0], minDate));
7564
+ maxDate = new Date(Math.max(nrange[1], minDate));
7565
+ });
7566
+
7567
+ const ret = ndate < minDate ? minDate : maxDate;
7568
+ // preserve Year/Month/Date
7569
+ return modifyDate(
7570
+ ret,
7571
+ date.getFullYear(),
7572
+ date.getMonth(),
7573
+ date.getDate()
7574
+ );
7575
+ };
7576
+
7577
+ const timeWithinRange = function(date, selectableRange, format) {
7578
+ const limitedDate = limitTimeRange(date, selectableRange, format);
7579
+ return limitedDate.getTime() === date.getTime();
7580
+ };
7581
+
7582
+ const changeYearMonthAndClampDate = function(date, year, month) {
7583
+ // clamp date to the number of days in `year`, `month`
7584
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
7585
+ const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
7586
+ return modifyDate(date, year, month, monthDate);
7587
+ };
7588
+
7589
+ const prevMonth = function(date) {
7590
+ const year = date.getFullYear();
7591
+ const month = date.getMonth();
7592
+ return month === 0
7593
+ ? changeYearMonthAndClampDate(date, year - 1, 11)
7594
+ : changeYearMonthAndClampDate(date, year, month - 1);
7595
+ };
7596
+
7597
+ const nextMonth = function(date) {
7598
+ const year = date.getFullYear();
7599
+ const month = date.getMonth();
7600
+ return month === 11
7601
+ ? changeYearMonthAndClampDate(date, year + 1, 0)
7602
+ : changeYearMonthAndClampDate(date, year, month + 1);
7603
+ };
7604
+
7605
+ const prevYear = function(date, amount = 1) {
7606
+ const year = date.getFullYear();
7607
+ const month = date.getMonth();
7608
+ return changeYearMonthAndClampDate(date, year - amount, month);
7609
+ };
7610
+
7611
+ const nextYear = function(date, amount = 1) {
7612
+ const year = date.getFullYear();
7613
+ const month = date.getMonth();
7614
+ return changeYearMonthAndClampDate(date, year + amount, month);
7615
+ };
7616
+
7617
+ const extractDateFormat = function(format) {
7618
+ return format
7619
+ .replace(/\W?m{1,2}|\W?ZZ/g, '')
7620
+ .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
7621
+ .trim();
7622
+ };
7623
+
7624
+ const extractTimeFormat = function(format) {
7625
+ return format
7626
+ .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
7627
+ .trim();
7628
+ };
7629
+
7630
+ const validateRangeInOneMonth = function(start, end) {
7631
+ return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
7632
+ };
7633
+
7616
7634
  /**
7617
7635
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
7618
7636
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
7619
7637
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
7620
7638
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
7621
7639
  * @returns {number} 工作日数量
7622
- */
7623
- var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
7624
- var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
7625
-
7626
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
7627
- throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
7628
- }
7629
-
7630
- var startDateObj = new Date(start_date);
7631
- var endDateObj = new Date(end_date);
7632
-
7633
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
7634
- throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
7635
- }
7636
-
7637
- if (startDateObj > endDateObj) {
7638
- throw new Error('Start date should be earlier than or equal to end date.');
7639
- }
7640
-
7641
- var workdays = 0;
7642
-
7643
- // Iterate through each day in the date range
7644
-
7645
- var _loop = function _loop(currentDate) {
7646
- // Check if the current day is a weekend (Saturday or Sunday)
7647
- var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
7648
-
7649
- // Check if the current day is a holiday
7650
- var isHoliday = holidays.some(function (holiday) {
7651
- var holidayDate = new Date(holiday);
7652
- return currentDate.toDateString() === holidayDate.toDateString();
7653
- });
7654
-
7655
- // If it's a workday (not a weekend or holiday), increment the workdays count
7656
- if (!isWeekend && !isHoliday) {
7657
- workdays++;
7658
- }
7659
- };
7660
-
7661
- for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
7662
- _loop(currentDate);
7663
- }
7664
-
7665
- return workdays;
7666
- };
7667
-
7640
+ */
7641
+ const calculateNetworkDays = function (start_date, end_date, holidays = []) {
7642
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
7643
+ throw new Error(
7644
+ "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
7645
+ );
7646
+ }
7647
+
7648
+ const startDateObj = new Date(start_date);
7649
+ const endDateObj = new Date(end_date);
7650
+
7651
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
7652
+ throw new Error(
7653
+ "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
7654
+ );
7655
+ }
7656
+
7657
+ if (startDateObj > endDateObj) {
7658
+ throw new Error('Start date should be earlier than or equal to end date.');
7659
+ }
7660
+
7661
+ let workdays = 0;
7662
+
7663
+ // Iterate through each day in the date range
7664
+ for (
7665
+ let currentDate = new Date(startDateObj);
7666
+ currentDate <= endDateObj;
7667
+ currentDate.setDate(currentDate.getDate() + 1)
7668
+ ) {
7669
+ // Check if the current day is a weekend (Saturday or Sunday)
7670
+ const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
7671
+
7672
+ // Check if the current day is a holiday
7673
+ const isHoliday = holidays.some((holiday) => {
7674
+ const holidayDate = new Date(holiday);
7675
+ return currentDate.toDateString() === holidayDate.toDateString();
7676
+ });
7677
+
7678
+ // If it's a workday (not a weekend or holiday), increment the workdays count
7679
+ if (!isWeekend && !isHoliday) {
7680
+ workdays++;
7681
+ }
7682
+ }
7683
+
7684
+ return workdays;
7685
+ };
7686
+
7668
7687
  /**
7669
7688
  * 日期加减天数
7670
7689
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
7671
7690
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
7672
7691
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
7673
- */
7674
- var dateAddDays = function dateAddDays(start_date, days) {
7675
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
7676
- 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.");
7677
- }
7678
-
7679
- var startDateObj = new Date(start_date);
7680
- if (isNaN(startDateObj.getTime())) {
7681
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
7682
- }
7683
-
7684
- var resultDateObj = new Date(startDateObj);
7685
- resultDateObj.setDate(resultDateObj.getDate() + days);
7686
-
7687
- var resultYear = resultDateObj.getFullYear();
7688
- var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
7689
- var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
7690
-
7691
- return resultYear + '-' + resultMonth + '-' + resultDay;
7692
- };
7693
-
7692
+ */
7693
+ const dateAddDays = function (start_date, days) {
7694
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
7695
+ throw new Error(
7696
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
7697
+ );
7698
+ }
7699
+
7700
+ const startDateObj = new Date(start_date);
7701
+ if (isNaN(startDateObj.getTime())) {
7702
+ throw new Error(
7703
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
7704
+ );
7705
+ }
7706
+
7707
+ const resultDateObj = new Date(startDateObj);
7708
+ resultDateObj.setDate(resultDateObj.getDate() + days);
7709
+
7710
+ const resultYear = resultDateObj.getFullYear();
7711
+ const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
7712
+ const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
7713
+
7714
+ return `${resultYear}-${resultMonth}-${resultDay}`;
7715
+ };
7716
+
7694
7717
  /**
7695
7718
  * 计算两个日期之间的差值
7696
7719
  * @date 2023年12月14日
@@ -7698,180 +7721,182 @@ var dateAddDays = function dateAddDays(start_date, days) {
7698
7721
  * @param {String} end_date - 结束日期字符串
7699
7722
  * @param {String} unit - 单位:year/month/day
7700
7723
  * @returns {Number} 差值
7701
- */
7702
- var dateDiff = function dateDiff(start_date, end_date) {
7703
- var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
7704
-
7705
- // Assuming date strings are in "YYYY-MM-DD" format
7706
- var startDate = new Date(start_date);
7707
- var endDate = new Date(end_date);
7708
-
7709
- // If the date is invalid, return 0
7710
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
7711
- return 0;
7712
- }
7713
-
7714
- if (unit === 'year') {
7715
- return endDate.getFullYear() - startDate.getFullYear();
7716
- } else if (unit === 'month') {
7717
- return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
7718
- } else {
7719
- // Default to day
7720
- var timeDifference = endDate - startDate;
7721
- // Calculate days (86400000 milliseconds per day)
7722
- return Math.floor(timeDifference / 86400000);
7723
- }
7724
- };
7725
-
7724
+ */
7725
+ const dateDiff = function (start_date, end_date, unit = 'day') {
7726
+ // Assuming date strings are in "YYYY-MM-DD" format
7727
+ var startDate = new Date(start_date);
7728
+ var endDate = new Date(end_date);
7729
+
7730
+ // If the date is invalid, return 0
7731
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
7732
+ return 0;
7733
+ }
7734
+
7735
+ if (unit === 'year') {
7736
+ return endDate.getFullYear() - startDate.getFullYear();
7737
+ } else if (unit === 'month') {
7738
+ return (
7739
+ (endDate.getFullYear() - startDate.getFullYear()) * 12 +
7740
+ (endDate.getMonth() - startDate.getMonth())
7741
+ );
7742
+ } else {
7743
+ // Default to day
7744
+ var timeDifference = endDate - startDate;
7745
+ // Calculate days (86400000 milliseconds per day)
7746
+ return Math.floor(timeDifference / 86400000);
7747
+ }
7748
+ };
7749
+
7726
7750
  /**
7727
7751
  * 获取月份中的日期
7728
7752
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
7729
7753
  * @returns {number} 月份中的日期(1-31)
7730
- */
7731
- var dayOfMonth = function dayOfMonth(date) {
7732
- if (typeof date !== 'string') {
7733
- throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
7734
- }
7735
-
7736
- var dateObj = new Date(date);
7737
- if (isNaN(dateObj.getTime())) {
7738
- throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
7739
- }
7740
-
7741
- return dateObj.getDate();
7742
- };
7743
-
7754
+ */
7755
+ const dayOfMonth = function (date) {
7756
+ if (typeof date !== 'string') {
7757
+ throw new Error(
7758
+ "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
7759
+ );
7760
+ }
7761
+
7762
+ const dateObj = new Date(date);
7763
+ if (isNaN(dateObj.getTime())) {
7764
+ throw new Error(
7765
+ "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
7766
+ );
7767
+ }
7768
+
7769
+ return dateObj.getDate();
7770
+ };
7771
+
7744
7772
  /**
7745
7773
  * 获取当前日期
7746
7774
  * @date 2022年5月7日
7747
7775
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
7748
7776
  * @returns {string} 当前日期的格式化字符串
7749
- */
7750
- var getCurrentDate = function getCurrentDate() {
7751
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
7752
-
7753
- return formatDate(new Date(), format);
7754
- };
7755
-
7777
+ */
7778
+ const getCurrentDate = function (format = 'YYYY-MM-DD') {
7779
+ return formatDate(new Date(), format);
7780
+ };
7781
+
7756
7782
  /**
7757
7783
  * 获取当前日期时间
7758
7784
  * @date 2022年5月7日
7759
7785
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
7760
7786
  * @returns {string} 当前日期时间的格式化字符串
7761
- */
7762
- var getCurrentDateTime = function getCurrentDateTime() {
7763
- var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
7764
-
7765
- return formatDate(new Date(), format);
7766
- };
7767
-
7787
+ */
7788
+ const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
7789
+ return formatDate(new Date(), format);
7790
+ };
7791
+
7768
7792
  /**
7769
7793
  * 获取小时
7770
7794
  * @date 2022年5月7日
7771
7795
  * @param {Date|string} [date] - 日期对象或日期字符串
7772
7796
  * @returns {number} 小时数(0-23)
7773
- */
7774
- var getHour = function getHour(date) {
7775
- if (!date) {
7776
- return new Date().getHours();
7777
- }
7778
- if (typeof date === 'string') {
7779
- date = new Date(date);
7780
- }
7781
- return date.getHours();
7782
- };
7783
-
7797
+ */
7798
+ const getHour = function (date) {
7799
+ if (!date) {
7800
+ return new Date().getHours();
7801
+ }
7802
+ if (typeof date === 'string') {
7803
+ date = new Date(date);
7804
+ }
7805
+ return date.getHours();
7806
+ };
7807
+
7784
7808
  /**
7785
7809
  * 获取分钟
7786
7810
  * @date 2022年5月7日
7787
7811
  * @param {Date|string} [date] - 日期对象或日期字符串
7788
7812
  * @returns {number} 分钟数(0-59)
7789
- */
7790
- var getMinute = function getMinute(date) {
7791
- if (!date) {
7792
- return new Date().getMinutes();
7793
- }
7794
- if (typeof date === 'string') {
7795
- date = new Date(date);
7796
- }
7797
- return date.getMinutes();
7798
- };
7799
-
7813
+ */
7814
+ const getMinute = function (date) {
7815
+ if (!date) {
7816
+ return new Date().getMinutes();
7817
+ }
7818
+ if (typeof date === 'string') {
7819
+ date = new Date(date);
7820
+ }
7821
+ return date.getMinutes();
7822
+ };
7823
+
7800
7824
  /**
7801
7825
  * 获取月份
7802
7826
  * @date 2022年5月7日
7803
7827
  * @param {Date|string} [date] - 日期对象或日期字符串
7804
7828
  * @returns {number} 月份数(1-12)
7805
- */
7806
- var getMonth = function getMonth(date) {
7807
- if (!date) {
7808
- return new Date().getMonth() + 1;
7809
- }
7810
- if (typeof date === 'string') {
7811
- date = new Date(date);
7812
- }
7813
- return date.getMonth() + 1;
7814
- };
7815
-
7829
+ */
7830
+ const getMonth = function (date) {
7831
+ if (!date) {
7832
+ return new Date().getMonth() + 1;
7833
+ }
7834
+ if (typeof date === 'string') {
7835
+ date = new Date(date);
7836
+ }
7837
+ return date.getMonth() + 1;
7838
+ };
7839
+
7816
7840
  /**
7817
7841
  * 获取秒
7818
7842
  * @date 2022年5月7日
7819
7843
  * @param {Date|string} [date] - 日期对象或日期字符串
7820
7844
  * @returns {number} 秒数(0-59)
7821
- */
7822
- var getSecond = function getSecond(date) {
7823
- if (!date) {
7824
- return new Date().getSeconds();
7825
- }
7826
- if (typeof date === 'string') {
7827
- date = new Date(date);
7828
- }
7829
- return date.getSeconds();
7830
- };
7831
-
7845
+ */
7846
+ const getSecond = function (date) {
7847
+ if (!date) {
7848
+ return new Date().getSeconds();
7849
+ }
7850
+ if (typeof date === 'string') {
7851
+ date = new Date(date);
7852
+ }
7853
+ return date.getSeconds();
7854
+ };
7855
+
7832
7856
  /**
7833
7857
  * 获取星期几
7834
7858
  * @date 2022年5月7日
7835
7859
  * @param {Date|string} [date] - 日期对象或日期字符串
7836
7860
  * @returns {number} 星期几(0-6,0表示星期日)
7837
- */
7838
- var getWeekday = function getWeekday(date) {
7839
- if (!date) {
7840
- return new Date().getDay();
7841
- }
7842
- if (typeof date === 'string') {
7843
- date = new Date(date);
7844
- }
7845
- return date.getDay();
7846
- };
7847
-
7861
+ */
7862
+ const getWeekday = function (date) {
7863
+ if (!date) {
7864
+ return new Date().getDay();
7865
+ }
7866
+ if (typeof date === 'string') {
7867
+ date = new Date(date);
7868
+ }
7869
+ return date.getDay();
7870
+ };
7871
+
7872
+
7848
7873
  /**
7849
7874
  * @desc 获取上午/下午/晚上
7850
7875
  * @author huangbo
7851
7876
  * @date 2022年5月7日
7852
7877
  * @param {String} [time] - 时间
7853
- **/
7854
- var timeCycle = function timeCycle(time) {
7855
- var hour = 0;
7856
- if (!time) {
7857
- hour = new Date().getHours();
7858
- } else if (typeof time === 'string') {
7859
- // 从时间字符串中提取小时
7860
- var match = time.match(/^(\d{1,2})/);
7861
- if (match) {
7862
- hour = parseInt(match[1], 10);
7863
- }
7864
- } else if (typeof time === 'number') {
7865
- hour = time;
7866
- }
7867
- // 判断时间段
7868
- if (hour >= 5 && hour < 12) {
7869
- return '上午';
7870
- } else if (hour >= 12 && hour < 18) {
7871
- return '下午';
7872
- } else {
7873
- return '晚上';
7874
- }
7878
+ **/
7879
+ const timeCycle = function (time) {
7880
+ let hour = 0;
7881
+ if (!time) {
7882
+ hour = new Date().getHours();
7883
+ } else if (typeof time === 'string') {
7884
+ // 从时间字符串中提取小时
7885
+ const match = time.match(/^(\d{1,2})/);
7886
+ if (match) {
7887
+ hour = parseInt(match[1], 10);
7888
+ }
7889
+ } else if (typeof time === 'number') {
7890
+ hour = time;
7891
+ }
7892
+ // 判断时间段
7893
+ if (hour >= 5 && hour < 12) {
7894
+ return '上午';
7895
+ } else if (hour >= 12 && hour < 18) {
7896
+ return '下午';
7897
+ } else {
7898
+ return '晚上';
7899
+ }
7875
7900
  };
7876
7901
 
7877
7902
  /***/ }),