eoss 0.1.0-alpha.39 → 0.1.0-alpha.40

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 (233) hide show
  1. package/lib/0.js +1 -1
  2. package/lib/1.js +1 -1
  3. package/lib/10.js +1 -1
  4. package/lib/11.js +1 -1
  5. package/lib/12.js +1 -1
  6. package/lib/13.js +1 -1
  7. package/lib/14.js +1 -1
  8. package/lib/15.js +1 -1
  9. package/lib/16.js +1 -1
  10. package/lib/17.js +1 -1
  11. package/lib/18.js +1 -1
  12. package/lib/19.js +1 -1
  13. package/lib/20.js +1 -1
  14. package/lib/21.js +1 -1
  15. package/lib/22.js +1 -1
  16. package/lib/23.js +1 -1
  17. package/lib/24.js +1 -1
  18. package/lib/25.js +1 -1
  19. package/lib/26.js +1 -1
  20. package/lib/27.js +1 -1
  21. package/lib/28.js +1 -1
  22. package/lib/29.js +1 -1
  23. package/lib/3.js +1 -1
  24. package/lib/30.js +1 -1
  25. package/lib/31.js +1 -1
  26. package/lib/32.js +1 -1
  27. package/lib/33.js +1 -1
  28. package/lib/34.js +1 -1
  29. package/lib/35.js +1 -1
  30. package/lib/36.js +1 -1
  31. package/lib/37.js +1 -1
  32. package/lib/38.js +1 -1
  33. package/lib/39.js +1 -1
  34. package/lib/4.js +1 -1
  35. package/lib/40.js +1 -1
  36. package/lib/41.js +1 -1
  37. package/lib/42.js +1 -1
  38. package/lib/43.js +1 -1
  39. package/lib/44.js +1 -1
  40. package/lib/45.js +1 -1
  41. package/lib/46.js +1 -1
  42. package/lib/47.js +1 -1
  43. package/lib/48.js +1 -1
  44. package/lib/49.js +1 -1
  45. package/lib/5.js +1 -1
  46. package/lib/50.js +1 -1
  47. package/lib/51.js +1 -1
  48. package/lib/52.js +1 -1
  49. package/lib/53.js +1 -1
  50. package/lib/54.js +1 -1
  51. package/lib/55.js +1 -1
  52. package/lib/56.js +1 -1
  53. package/lib/57.js +1 -1
  54. package/lib/58.js +1 -1
  55. package/lib/59.js +1 -1
  56. package/lib/6.js +1 -1
  57. package/lib/60.js +1 -1
  58. package/lib/61.js +1 -1
  59. package/lib/62.js +1 -1
  60. package/lib/63.js +1 -1
  61. package/lib/64.js +1 -1
  62. package/lib/65.js +1 -1
  63. package/lib/66.js +1 -1
  64. package/lib/67.js +1 -1
  65. package/lib/68.js +1 -1
  66. package/lib/69.js +1 -1
  67. package/lib/7.js +1 -1
  68. package/lib/70.js +1 -1
  69. package/lib/71.js +1 -1
  70. package/lib/72.js +1 -1
  71. package/lib/73.js +1 -1
  72. package/lib/74.js +1 -1
  73. package/lib/75.js +1 -1
  74. package/lib/76.js +1 -1
  75. package/lib/77.js +1 -1
  76. package/lib/78.js +1 -1
  77. package/lib/79.js +1 -1
  78. package/lib/8.js +1 -1
  79. package/lib/80.js +1 -1
  80. package/lib/81.js +1 -1
  81. package/lib/9.js +1 -1
  82. package/lib/account-login.js +837 -862
  83. package/lib/alert.js +2 -2
  84. package/lib/aside.js +2 -2
  85. package/lib/audit-trajectory.js +4 -4
  86. package/lib/autocomplete.js +1813 -1988
  87. package/lib/avatar.js +2 -2
  88. package/lib/backtop.js +2 -2
  89. package/lib/badge.js +2 -2
  90. package/lib/breadcrumb-item.js +4 -4
  91. package/lib/breadcrumb.js +4 -4
  92. package/lib/button-group.js +4 -4
  93. package/lib/button.js +2 -2
  94. package/lib/ca-login.js +837 -862
  95. package/lib/calendar.js +839 -864
  96. package/lib/card.js +2 -2
  97. package/lib/carousel-item.js +846 -871
  98. package/lib/carousel.js +839 -864
  99. package/lib/cascader-panel.js +852 -877
  100. package/lib/cascader.js +2048 -2223
  101. package/lib/checkbox-button.js +4 -4
  102. package/lib/checkbox-group.js +859 -884
  103. package/lib/checkbox.js +4 -4
  104. package/lib/col.js +2 -2
  105. package/lib/collapse-item.js +1040 -1065
  106. package/lib/collapse.js +1040 -1065
  107. package/lib/color-picker.js +972 -1122
  108. package/lib/container.js +2 -2
  109. package/lib/cron.js +12 -12
  110. package/lib/data-table.js +843 -868
  111. package/lib/date-picker.js +10520 -10695
  112. package/lib/descriptions-item.js +4 -4
  113. package/lib/descriptions.js +4 -4
  114. package/lib/dialog.js +837 -862
  115. package/lib/divider.js +2 -2
  116. package/lib/drawer.js +2 -2
  117. package/lib/dropdown-item.js +4 -4
  118. package/lib/dropdown-menu.js +974 -1124
  119. package/lib/dropdown.js +841 -866
  120. package/lib/email-login.js +837 -862
  121. package/lib/empty.js +2 -2
  122. package/lib/eoss.common.js +4023 -2668
  123. package/lib/flip.js +2 -2
  124. package/lib/flow-group.js +853 -878
  125. package/lib/flow.js +868 -893
  126. package/lib/flows.js +854 -879
  127. package/lib/footer.js +2 -2
  128. package/lib/form-item.js +860 -885
  129. package/lib/form.js +933 -950
  130. package/lib/guide.js +2 -2
  131. package/lib/header.js +2 -2
  132. package/lib/icon.js +837 -862
  133. package/lib/icons.js +2 -2
  134. package/lib/image-viewer.js +837 -862
  135. package/lib/image.js +4 -4
  136. package/lib/index.js +1 -1
  137. package/lib/infinite-scroll.js +2 -2
  138. package/lib/input-number.js +6 -6
  139. package/lib/input.js +839 -864
  140. package/lib/link.js +2 -2
  141. package/lib/loading.js +2 -2
  142. package/lib/login.js +867 -891
  143. package/lib/lowcode-view.js +1843 -1185
  144. package/lib/lowcode.js +3050 -1569
  145. package/lib/main.js +970 -988
  146. package/lib/marquee.js +837 -862
  147. package/lib/menu-item-group.js +15 -15
  148. package/lib/menu-item.js +6 -6
  149. package/lib/menu.js +2227 -2368
  150. package/lib/message-box.js +843 -868
  151. package/lib/message.js +839 -864
  152. package/lib/notification.js +861 -886
  153. package/lib/option-group.js +4 -4
  154. package/lib/option.js +839 -864
  155. package/lib/page-header.js +2 -2
  156. package/lib/pagination.js +839 -864
  157. package/lib/phone-login.js +847 -866
  158. package/lib/popconfirm.js +4 -4
  159. package/lib/popover.js +1831 -2006
  160. package/lib/process-config.js +839 -864
  161. package/lib/process-module.js +846 -871
  162. package/lib/process-rule.js +905 -930
  163. package/lib/progress.js +2 -2
  164. package/lib/qr-code.js +4 -4
  165. package/lib/qrcode-login.js +839 -864
  166. package/lib/radio-button.js +4 -4
  167. package/lib/radio-group.js +850 -875
  168. package/lib/radio.js +4 -4
  169. package/lib/rate.js +837 -862
  170. package/lib/retrial-auth.js +837 -862
  171. package/lib/row.js +2 -2
  172. package/lib/scrollbar.js +839 -864
  173. package/lib/select.js +2139 -2314
  174. package/lib/selector-panel.js +940 -965
  175. package/lib/selector.js +852 -877
  176. package/lib/slider.js +4 -4
  177. package/lib/step.js +32 -32
  178. package/lib/steps.js +874 -899
  179. package/lib/submenu.js +1269 -1385
  180. package/lib/switch.js +839 -864
  181. package/lib/tab-pane.js +4 -4
  182. package/lib/table-column.js +840 -865
  183. package/lib/table.js +1825 -2000
  184. package/lib/tabs.js +846 -871
  185. package/lib/tag.js +2 -2
  186. package/lib/theme-chalk/fonts/iconfont.ttf +0 -0
  187. package/lib/theme-chalk/fonts/iconfont.woff +0 -0
  188. package/lib/theme-chalk/index.css +1 -1
  189. package/lib/theme-chalk/lowcode.css +1 -1
  190. package/lib/time-picker.js +6471 -6646
  191. package/lib/time-select.js +5039 -5214
  192. package/lib/timeline-item.js +2 -2
  193. package/lib/timeline.js +2 -2
  194. package/lib/tips.js +837 -862
  195. package/lib/toolbar.js +4 -4
  196. package/lib/tooltip.js +1813 -1988
  197. package/lib/transfer.js +837 -862
  198. package/lib/tree-group.js +853 -878
  199. package/lib/tree.js +1026 -1051
  200. package/lib/update-history.js +4 -4
  201. package/lib/upload.js +859 -884
  202. package/lib/wujie.js +841 -866
  203. package/package.json +1 -1
  204. package/packages/flow-group/src/main.vue +2 -2
  205. package/packages/form/src/form-item-render.vue +1 -0
  206. package/packages/form/src/form-item.vue +12 -6
  207. package/packages/form/src/form.vue +5 -5
  208. package/packages/login/src/login.vue +1 -0
  209. package/packages/lowcode/src/attribute/function.vue +28 -9
  210. package/packages/lowcode/src/attribute/props.vue +202 -0
  211. package/packages/lowcode/src/attribute/styles.vue +79 -5
  212. package/packages/lowcode/src/attribute.vue +61 -4
  213. package/packages/lowcode/src/canvas.vue +159 -2
  214. package/packages/lowcode/src/form-render.vue +305 -0
  215. package/packages/lowcode/src/lowcode.vue +33 -13
  216. package/packages/lowcode/src/modules.vue +53 -37
  217. package/packages/lowcode/src/render.vue +80 -25
  218. package/packages/lowcode/src/util/components.js +100 -0
  219. package/packages/lowcode/src/util/props-util.js +67 -0
  220. package/packages/lowcode/src/util/source-generator.js +69 -9
  221. package/packages/lowcode/src/util/source-parser.js +64 -10
  222. package/packages/lowcode-view/src/render.vue +48 -18
  223. package/packages/main/src/components/userinfo.vue +0 -1
  224. package/packages/menu/src/menu-item-group.vue +1 -1
  225. package/packages/menu/src/mixins.js +8 -4
  226. package/packages/menu/src/submenu.vue +35 -5
  227. package/packages/phone-login/src/phone-login.vue +5 -2
  228. package/packages/theme-chalk/dist/fonts/iconfont.ttf +0 -0
  229. package/packages/theme-chalk/dist/fonts/iconfont.woff +0 -0
  230. package/packages/theme-chalk/src/fonts/iconfont.ttf +0 -0
  231. package/packages/theme-chalk/src/fonts/iconfont.woff +0 -0
  232. package/packages/theme-chalk/src/lowcode.scss +21 -2
  233. package/src/index.js +336 -336
package/lib/transfer.js CHANGED
@@ -82,7 +82,7 @@ module.exports =
82
82
  /******/
83
83
  /******/
84
84
  /******/ // Load entry module and return exports
85
- /******/ return __webpack_require__(__webpack_require__.s = 202);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 209);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -3575,7 +3575,7 @@ module.exports = require("vue");
3575
3575
 
3576
3576
  /***/ }),
3577
3577
 
3578
- /***/ 202:
3578
+ /***/ 209:
3579
3579
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
3580
3580
 
3581
3581
  "use strict";
@@ -4987,759 +4987,736 @@ module.exports = require("eoss/lib/checkbox-group");
4987
4987
  /* unused harmony export getSecond */
4988
4988
  /* unused harmony export getWeekday */
4989
4989
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
4990
- /* Modified from https://github.com/taylorhakes/fecha
4991
- *
4992
- * The MIT License (MIT)
4993
- *
4994
- * Copyright (c) 2015 Taylor Hakes
4995
- *
4996
- * Permission is hereby granted, free of charge, to any person obtaining a copy
4997
- * of this software and associated documentation files (the "Software"), to deal
4998
- * in the Software without restriction, including without limitation the rights
4999
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5000
- * copies of the Software, and to permit persons to whom the Software is
5001
- * furnished to do so, subject to the following conditions:
5002
- *
5003
- * The above copyright notice and this permission notice shall be included in all
5004
- * copies or substantial portions of the Software.
5005
- *
5006
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
5007
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
5008
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
5009
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
5010
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
5011
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
5012
- * SOFTWARE.
5013
- */
5014
-
5015
- /*eslint-disable*/
5016
- // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
5017
-
5018
-
4990
+
4991
+
5019
4992
  /**
5020
4993
  * Parse or format dates
5021
4994
  * @class fecha
5022
- */
5023
- const fecha = {};
5024
- const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
5025
- const twoDigits = '\\d\\d?';
5026
- const threeDigits = '\\d{3}';
5027
- const fourDigits = '\\d{4}';
5028
- const word = '[^\\s]+';
5029
- const literal = /\[([^]*?)\]/gm;
5030
- const noop = function () {};
5031
-
5032
- function regexEscape(str) {
5033
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
5034
- }
5035
-
5036
- function shorten(arr, sLen) {
5037
- const newArr = [];
5038
- for (let i = 0, len = arr.length; i < len; i++) {
5039
- newArr.push(arr[i].substr(0, sLen));
5040
- }
5041
- return newArr;
5042
- }
5043
-
5044
- function monthUpdate() {
5045
- return function (d, v) {
5046
- const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
5047
- if (~index) {
5048
- d.month = index;
5049
- }
5050
- };
5051
- }
5052
-
5053
- function pad(val, len) {
5054
- val = String(val);
5055
- len = len || 2;
5056
- while (val.length < len) {
5057
- val = '0' + val;
5058
- }
5059
- return val;
5060
- }
5061
-
5062
- // 直接使用中文日期名称常量
5063
- const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
5064
- const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
5065
- const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
5066
- const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
5067
- const amPm = ['上午', '下午'];
5068
- const DoFn = function DoFn(D) {
5069
- return D + '日';
5070
- };
5071
-
5072
- const formatFlags = {
5073
- D: function(dateObj) {
5074
- return dateObj.getDay();
5075
- },
5076
- DD: function(dateObj) {
5077
- return pad(dateObj.getDay());
5078
- },
5079
- Do: function(dateObj) {
5080
- return DoFn(dateObj.getDate());
5081
- },
5082
- d: function(dateObj) {
5083
- return dateObj.getDate();
5084
- },
5085
- dd: function(dateObj) {
5086
- return pad(dateObj.getDate());
5087
- },
5088
- ddd: function(dateObj) {
5089
- return dayNamesShort[dateObj.getDay()];
5090
- },
5091
- dddd: function(dateObj) {
5092
- return dayNames[dateObj.getDay()];
5093
- },
5094
- M: function(dateObj) {
5095
- return dateObj.getMonth() + 1;
5096
- },
5097
- MM: function(dateObj) {
5098
- return pad(dateObj.getMonth() + 1);
5099
- },
5100
- MMM: function(dateObj) {
5101
- return monthNamesShort[dateObj.getMonth()];
5102
- },
5103
- MMMM: function(dateObj) {
5104
- return monthNames[dateObj.getMonth()];
5105
- },
5106
- yy: function(dateObj) {
5107
- return pad(String(dateObj.getFullYear()), 4).substr(2);
5108
- },
5109
- yyyy: function(dateObj) {
5110
- return pad(dateObj.getFullYear(), 4);
5111
- },
5112
- h: function(dateObj) {
5113
- return dateObj.getHours() % 12 || 12;
5114
- },
5115
- hh: function(dateObj) {
5116
- return pad(dateObj.getHours() % 12 || 12);
5117
- },
5118
- H: function(dateObj) {
5119
- return dateObj.getHours();
5120
- },
5121
- HH: function(dateObj) {
5122
- return pad(dateObj.getHours());
5123
- },
5124
- m: function(dateObj) {
5125
- return dateObj.getMinutes();
5126
- },
5127
- mm: function(dateObj) {
5128
- return pad(dateObj.getMinutes());
5129
- },
5130
- s: function(dateObj) {
5131
- return dateObj.getSeconds();
5132
- },
5133
- ss: function(dateObj) {
5134
- return pad(dateObj.getSeconds());
5135
- },
5136
- S: function(dateObj) {
5137
- return Math.round(dateObj.getMilliseconds() / 100);
5138
- },
5139
- SS: function(dateObj) {
5140
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
5141
- },
5142
- SSS: function(dateObj) {
5143
- return pad(dateObj.getMilliseconds(), 3);
5144
- },
5145
- a: function(dateObj) {
5146
- return dateObj.getHours() < 12 ? '上午' : '下午';
5147
- },
5148
- A: function(dateObj) {
5149
- return dateObj.getHours() < 12 ? '上午' : '下午';
5150
- },
5151
- ZZ: function(dateObj) {
5152
- const o = dateObj.getTimezoneOffset();
5153
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
5154
- }
5155
- };
5156
-
5157
- const parseFlags = {
5158
- d: [twoDigits, function (d, v) {
5159
- d.day = v;
5160
- }],
5161
- Do: [twoDigits + word, function (d, v) {
5162
- d.day = parseInt(v, 10);
5163
- }],
5164
- M: [twoDigits, function (d, v) {
5165
- d.month = v - 1;
5166
- }],
5167
- yy: [twoDigits, function (d, v) {
5168
- const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
5169
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
5170
- }],
5171
- h: [twoDigits, function (d, v) {
5172
- d.hour = v;
5173
- }],
5174
- m: [twoDigits, function (d, v) {
5175
- d.minute = v;
5176
- }],
5177
- s: [twoDigits, function (d, v) {
5178
- d.second = v;
5179
- }],
5180
- yyyy: [fourDigits, function (d, v) {
5181
- d.year = v;
5182
- }],
5183
- S: ['\\d', function (d, v) {
5184
- d.millisecond = v * 100;
5185
- }],
5186
- SS: ['\\d{2}', function (d, v) {
5187
- d.millisecond = v * 10;
5188
- }],
5189
- SSS: [threeDigits, function (d, v) {
5190
- d.millisecond = v;
5191
- }],
5192
- D: [twoDigits, noop],
5193
- ddd: [word, noop],
5194
- MMM: [word, monthUpdate('monthNamesShort')],
5195
- MMMM: [word, monthUpdate('monthNames')],
5196
- a: [word, function (d, v) {
5197
- const val = v.toLowerCase();
5198
- if (val === '上午') {
5199
- d.isPm = false;
5200
- } else if (val === '下午') {
5201
- d.isPm = true;
5202
- }
5203
- }],
5204
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
5205
- let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
5206
-
5207
- if (parts) {
5208
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
5209
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
5210
- }
5211
- }]
5212
- };
5213
- parseFlags.dd = parseFlags.d;
5214
- parseFlags.dddd = parseFlags.ddd;
5215
- parseFlags.DD = parseFlags.D;
5216
- parseFlags.mm = parseFlags.m;
5217
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
5218
- parseFlags.MM = parseFlags.M;
5219
- parseFlags.ss = parseFlags.s;
5220
- parseFlags.A = parseFlags.a;
5221
-
5222
-
5223
- // Some common format strings
5224
- fecha.masks = {
5225
- default: 'ddd MMM dd yyyy HH:mm:ss',
5226
- shortDate: 'M/D/yy',
5227
- mediumDate: 'MMM d, yyyy',
5228
- longDate: 'MMMM d, yyyy',
5229
- fullDate: 'dddd, MMMM d, yyyy',
5230
- shortTime: 'HH:mm',
5231
- mediumTime: 'HH:mm:ss',
5232
- longTime: 'HH:mm:ss.SSS'
5233
- };
5234
-
4995
+ */
4996
+ var fecha = {};
4997
+ var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
4998
+ var twoDigits = '\\d\\d?';
4999
+ var threeDigits = '\\d{3}';
5000
+ var fourDigits = '\\d{4}';
5001
+ var word = '[^\\s]+';
5002
+ var literal = /\[([^]*?)\]/gm;
5003
+ var noop = function noop() {};
5004
+
5005
+ function regexEscape(str) {
5006
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
5007
+ }
5008
+
5009
+ function shorten(arr, sLen) {
5010
+ var newArr = [];
5011
+ for (var i = 0, len = arr.length; i < len; i++) {
5012
+ newArr.push(arr[i].substr(0, sLen));
5013
+ }
5014
+ return newArr;
5015
+ }
5016
+
5017
+ function monthUpdate() {
5018
+ return function (d, v) {
5019
+ var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
5020
+ if (~index) {
5021
+ d.month = index;
5022
+ }
5023
+ };
5024
+ }
5025
+
5026
+ function pad(val, len) {
5027
+ val = String(val);
5028
+ len = len || 2;
5029
+ while (val.length < len) {
5030
+ val = '0' + val;
5031
+ }
5032
+ return val;
5033
+ }
5034
+
5035
+ // 直接使用中文日期名称常量
5036
+ var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
5037
+ var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
5038
+ var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
5039
+ var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
5040
+ var amPm = ['上午', '下午'];
5041
+ var DoFn = function DoFn(D) {
5042
+ return D + '日';
5043
+ };
5044
+
5045
+ var formatFlags = {
5046
+ D: function D(dateObj) {
5047
+ return dateObj.getDay();
5048
+ },
5049
+ DD: function DD(dateObj) {
5050
+ return pad(dateObj.getDay());
5051
+ },
5052
+ Do: function Do(dateObj) {
5053
+ return DoFn(dateObj.getDate());
5054
+ },
5055
+ d: function d(dateObj) {
5056
+ return dateObj.getDate();
5057
+ },
5058
+ dd: function dd(dateObj) {
5059
+ return pad(dateObj.getDate());
5060
+ },
5061
+ ddd: function ddd(dateObj) {
5062
+ return dayNamesShort[dateObj.getDay()];
5063
+ },
5064
+ dddd: function dddd(dateObj) {
5065
+ return dayNames[dateObj.getDay()];
5066
+ },
5067
+ M: function M(dateObj) {
5068
+ return dateObj.getMonth() + 1;
5069
+ },
5070
+ MM: function MM(dateObj) {
5071
+ return pad(dateObj.getMonth() + 1);
5072
+ },
5073
+ MMM: function MMM(dateObj) {
5074
+ return monthNamesShort[dateObj.getMonth()];
5075
+ },
5076
+ MMMM: function MMMM(dateObj) {
5077
+ return monthNames[dateObj.getMonth()];
5078
+ },
5079
+ yy: function yy(dateObj) {
5080
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
5081
+ },
5082
+ yyyy: function yyyy(dateObj) {
5083
+ return pad(dateObj.getFullYear(), 4);
5084
+ },
5085
+ h: function h(dateObj) {
5086
+ return dateObj.getHours() % 12 || 12;
5087
+ },
5088
+ hh: function hh(dateObj) {
5089
+ return pad(dateObj.getHours() % 12 || 12);
5090
+ },
5091
+ H: function H(dateObj) {
5092
+ return dateObj.getHours();
5093
+ },
5094
+ HH: function HH(dateObj) {
5095
+ return pad(dateObj.getHours());
5096
+ },
5097
+ m: function m(dateObj) {
5098
+ return dateObj.getMinutes();
5099
+ },
5100
+ mm: function mm(dateObj) {
5101
+ return pad(dateObj.getMinutes());
5102
+ },
5103
+ s: function s(dateObj) {
5104
+ return dateObj.getSeconds();
5105
+ },
5106
+ ss: function ss(dateObj) {
5107
+ return pad(dateObj.getSeconds());
5108
+ },
5109
+ S: function S(dateObj) {
5110
+ return Math.round(dateObj.getMilliseconds() / 100);
5111
+ },
5112
+ SS: function SS(dateObj) {
5113
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
5114
+ },
5115
+ SSS: function SSS(dateObj) {
5116
+ return pad(dateObj.getMilliseconds(), 3);
5117
+ },
5118
+ a: function a(dateObj) {
5119
+ return dateObj.getHours() < 12 ? '上午' : '下午';
5120
+ },
5121
+ A: function A(dateObj) {
5122
+ return dateObj.getHours() < 12 ? '上午' : '下午';
5123
+ },
5124
+ ZZ: function ZZ(dateObj) {
5125
+ var o = dateObj.getTimezoneOffset();
5126
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
5127
+ }
5128
+ };
5129
+
5130
+ var parseFlags = {
5131
+ d: [twoDigits, function (d, v) {
5132
+ d.day = v;
5133
+ }],
5134
+ Do: [twoDigits + word, function (d, v) {
5135
+ d.day = parseInt(v, 10);
5136
+ }],
5137
+ M: [twoDigits, function (d, v) {
5138
+ d.month = v - 1;
5139
+ }],
5140
+ yy: [twoDigits, function (d, v) {
5141
+ var da = new Date(),
5142
+ cent = +('' + da.getFullYear()).substr(0, 2);
5143
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
5144
+ }],
5145
+ h: [twoDigits, function (d, v) {
5146
+ d.hour = v;
5147
+ }],
5148
+ m: [twoDigits, function (d, v) {
5149
+ d.minute = v;
5150
+ }],
5151
+ s: [twoDigits, function (d, v) {
5152
+ d.second = v;
5153
+ }],
5154
+ yyyy: [fourDigits, function (d, v) {
5155
+ d.year = v;
5156
+ }],
5157
+ S: ['\\d', function (d, v) {
5158
+ d.millisecond = v * 100;
5159
+ }],
5160
+ SS: ['\\d{2}', function (d, v) {
5161
+ d.millisecond = v * 10;
5162
+ }],
5163
+ SSS: [threeDigits, function (d, v) {
5164
+ d.millisecond = v;
5165
+ }],
5166
+ D: [twoDigits, noop],
5167
+ ddd: [word, noop],
5168
+ MMM: [word, monthUpdate('monthNamesShort')],
5169
+ MMMM: [word, monthUpdate('monthNames')],
5170
+ a: [word, function (d, v) {
5171
+ var val = v.toLowerCase();
5172
+ if (val === '上午') {
5173
+ d.isPm = false;
5174
+ } else if (val === '下午') {
5175
+ d.isPm = true;
5176
+ }
5177
+ }],
5178
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
5179
+ var parts = (v + '').match(/([+-]|\d\d)/gi),
5180
+ minutes = void 0;
5181
+
5182
+ if (parts) {
5183
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
5184
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
5185
+ }
5186
+ }]
5187
+ };
5188
+ parseFlags.dd = parseFlags.d;
5189
+ parseFlags.dddd = parseFlags.ddd;
5190
+ parseFlags.DD = parseFlags.D;
5191
+ parseFlags.mm = parseFlags.m;
5192
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
5193
+ parseFlags.MM = parseFlags.M;
5194
+ parseFlags.ss = parseFlags.s;
5195
+ parseFlags.A = parseFlags.a;
5196
+
5197
+ // Some common format strings
5198
+ fecha.masks = {
5199
+ default: 'ddd MMM dd yyyy HH:mm:ss',
5200
+ shortDate: 'M/D/yy',
5201
+ mediumDate: 'MMM d, yyyy',
5202
+ longDate: 'MMMM d, yyyy',
5203
+ fullDate: 'dddd, MMMM d, yyyy',
5204
+ shortTime: 'HH:mm',
5205
+ mediumTime: 'HH:mm:ss',
5206
+ longTime: 'HH:mm:ss.SSS'
5207
+ };
5208
+
5235
5209
  /***
5236
5210
  * Format a date
5237
5211
  * @method format
5238
5212
  * @param {Date|number} dateObj
5239
5213
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
5240
- */
5241
- fecha.format = function (dateObj, mask) {
5242
- if (typeof dateObj === 'number') {
5243
- dateObj = new Date(dateObj);
5244
- }
5245
-
5246
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
5247
- throw new Error('Invalid Date in fecha.format');
5248
- }
5249
-
5250
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
5251
-
5252
- const literals = [];
5253
-
5254
- // Make literals inactive by replacing them with ??
5255
- mask = mask.replace(literal, function($0, $1) {
5256
- literals.push($1);
5257
- return '@@@';
5258
- });
5259
- // Apply formatting rules
5260
- mask = mask.replace(token, function ($0) {
5261
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
5262
- });
5263
- // Inline literal values back into the formatted value
5264
- return mask.replace(/@@@/g, function() {
5265
- return literals.shift();
5266
- });
5267
- };
5268
-
5214
+ */
5215
+ fecha.format = function (dateObj, mask) {
5216
+ if (typeof dateObj === 'number') {
5217
+ dateObj = new Date(dateObj);
5218
+ }
5219
+
5220
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
5221
+ throw new Error('Invalid Date in fecha.format');
5222
+ }
5223
+
5224
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
5225
+
5226
+ var literals = [];
5227
+
5228
+ // Make literals inactive by replacing them with ??
5229
+ mask = mask.replace(literal, function ($0, $1) {
5230
+ literals.push($1);
5231
+ return '@@@';
5232
+ });
5233
+ // Apply formatting rules
5234
+ mask = mask.replace(token, function ($0) {
5235
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
5236
+ });
5237
+ // Inline literal values back into the formatted value
5238
+ return mask.replace(/@@@/g, function () {
5239
+ return literals.shift();
5240
+ });
5241
+ };
5242
+
5269
5243
  /**
5270
5244
  * Parse a date string into an object, changes - into /
5271
5245
  * @method parse
5272
5246
  * @param {string} dateStr Date string
5273
5247
  * @param {string} format Date parse format
5274
5248
  * @returns {Date|boolean}
5275
- */
5276
- fecha.parse = function (dateStr, format) {
5277
- if (typeof format !== 'string') {
5278
- throw new Error('Invalid format in fecha.parse');
5279
- }
5280
-
5281
- format = fecha.masks[format] || format;
5282
-
5283
- // Avoid regular expression denial of service, fail early for really long strings
5284
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
5285
- if (dateStr.length > 1000) {
5286
- return null;
5287
- }
5288
-
5289
- const dateInfo = {};
5290
- const parseInfo = [];
5291
- const literals = [];
5292
- format = format.replace(literal, function($0, $1) {
5293
- literals.push($1);
5294
- return '@@@';
5295
- });
5296
- let newFormat = regexEscape(format).replace(token, function ($0) {
5297
- if (parseFlags[$0]) {
5298
- const info = parseFlags[$0];
5299
- parseInfo.push(info[1]);
5300
- return '(' + info[0] + ')';
5301
- }
5302
-
5303
- return $0;
5304
- });
5305
- newFormat = newFormat.replace(/@@@/g, function() {
5306
- return literals.shift();
5307
- });
5308
- const matches = dateStr.match(new RegExp(newFormat, 'i'));
5309
- if (!matches) {
5310
- return null;
5311
- }
5312
-
5313
- for (let i = 1; i < matches.length; i++) {
5314
- parseInfo[i - 1](dateInfo, matches[i]);
5315
- }
5316
-
5317
- const today = new Date();
5318
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
5319
- dateInfo.hour = +dateInfo.hour + 12;
5320
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
5321
- dateInfo.hour = 0;
5322
- }
5323
-
5324
- let date;
5325
- if (dateInfo.timezoneOffset != null) {
5326
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
5327
- date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
5328
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
5329
- } else {
5330
- date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
5331
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
5332
- }
5333
- return date;
5334
- };
5335
-
5336
- // 导出fecha对象
5337
-
5338
-
5339
- // 以下是从date-util.js合并的函数
5340
- const newArray = function(start, end) {
5341
- let result = [];
5342
- for (let i = start; i <= end; i++) {
5343
- result.push(i);
5344
- }
5345
- return result;
5346
- };
5347
-
5348
- const getSettings = () => {
5349
- return {
5350
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
5351
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
5352
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
5353
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
5354
- amPm: ['上午', '下午']
5355
- };
5356
- };
5357
-
5358
- const toDate = function(date) {
5359
- return isDate(date) ? new Date(date) : null;
5360
- };
5361
-
5362
- const isDate = function(date) {
5363
- if (date === null || date === undefined) return false;
5364
- if (isNaN(new Date(date).getTime())) return false;
5365
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
5366
- return true;
5367
- };
5368
-
5369
- const isDateObject = function(val) {
5370
- return val instanceof Date;
5371
- };
5372
-
5373
- const formatDate = function (date, format = 'yyyy-MM-dd') {
5374
- // 处理多种输入类型
5375
- if (!date) return '';
5376
-
5377
- // 如果是时间戳,转成日期对象
5378
- if (typeof date === 'number') {
5379
- date = new Date(date);
5380
- }
5381
- // 如果是字符串,转成日期对象
5382
- if (typeof date === 'string') {
5383
- date = new Date(date);
5384
- }
5385
-
5386
- // 调用toDate进一步验证和转换
5387
- date = toDate(date);
5388
- if (!date) return '';
5389
-
5390
- // 兼容大写和小写的格式标记
5391
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
5392
- const lowercaseFormat = format
5393
- .replace(/YYYY/g, 'yyyy')
5394
- .replace(/D/g, 'd')
5395
-
5396
- // 使用fecha库进行格式化,支持中文配置
5397
- const str = fecha.format(date, lowercaseFormat, getSettings());
5398
- return str;
5399
- };
5400
-
5401
- const parseDate = function(string, format) {
5402
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
5403
- };
5404
-
5405
- const getDayCountOfMonth = function(year, month) {
5406
- if (month === 3 || month === 5 || month === 8 || month === 10) {
5407
- return 30;
5408
- }
5409
-
5410
- if (month === 1) {
5411
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
5412
- return 29;
5413
- } else {
5414
- return 28;
5415
- }
5416
- }
5417
-
5418
- return 31;
5419
- };
5420
-
5421
- const getDayCountOfYear = function(year) {
5422
- const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
5423
- return isLeapYear ? 366 : 365;
5424
- };
5425
-
5426
- const getFirstDayOfMonth = function(date) {
5427
- const temp = new Date(date.getTime());
5428
- temp.setDate(1);
5429
- return temp.getDay();
5430
- };
5431
-
5432
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
5433
- // {prev, next} Date should work for Daylight Saving Time
5434
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
5435
- const prevDate = function(date, amount = 1) {
5436
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
5437
- };
5438
-
5439
- const nextDate = function(date, amount = 1) {
5440
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
5441
- };
5442
-
5443
- const getStartDateOfMonth = function(year, month) {
5444
- const result = new Date(year, month, 1);
5445
- const day = result.getDay();
5446
-
5447
- if (day === 0) {
5448
- return prevDate(result, 7);
5449
- } else {
5450
- return prevDate(result, day);
5451
- }
5452
- };
5453
-
5454
- const getWeekNumber = function(date) {
5455
- // 支持多种输入类型
5456
- if (!date||!isDate(date)) {
5457
- date = new Date();
5458
- }
5459
- if (typeof date === 'string') {
5460
- date = new Date(date);
5461
- }
5462
-
5463
- // 验证日期有效性
5464
- if (!isDate(date)) return null;
5465
-
5466
- const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
5467
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
5468
- // 将星期日的星期数设为7
5469
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
5470
- // 获取当年的第一天
5471
- const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
5472
- // 计算到最近的星期四的完整周数
5473
- const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
5474
- // 返回周数
5475
- return weekNo;
5476
- };
5477
-
5478
- const getRangeHours = function(ranges) {
5479
- const hours = [];
5480
- let disabledHours = [];
5481
-
5482
- (ranges || []).forEach(range => {
5483
- const value = range.map(date => date.getHours());
5484
-
5485
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
5486
- });
5487
-
5488
- if (disabledHours.length) {
5489
- for (let i = 0; i < 24; i++) {
5490
- hours[i] = disabledHours.indexOf(i) === -1;
5491
- }
5492
- } else {
5493
- for (let i = 0; i < 24; i++) {
5494
- hours[i] = false;
5495
- }
5496
- }
5497
-
5498
- return hours;
5499
- };
5500
-
5501
- const getPrevMonthLastDays = (date, amount) => {
5502
- if (amount <= 0) return [];
5503
- const temp = new Date(date.getTime());
5504
- temp.setDate(0);
5505
- const lastDay = temp.getDate();
5506
- return range(amount).map((_, index) => lastDay - (amount - index - 1));
5507
- };
5508
-
5509
- const getMonthDays = (date) => {
5510
- const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
5511
- const days = temp.getDate();
5512
- return range(days).map((_, index) => index + 1);
5513
- };
5514
-
5515
- function setRangeData(arr, start, end, value) {
5516
- for (let i = start; i < end; i++) {
5517
- arr[i] = value;
5518
- }
5519
- }
5520
-
5521
- const getRangeMinutes = function(ranges, hour) {
5522
- const minutes = new Array(60);
5523
-
5524
- if (ranges.length > 0) {
5525
- ranges.forEach(range => {
5526
- const start = range[0];
5527
- const end = range[1];
5528
- const startHour = start.getHours();
5529
- const startMinute = start.getMinutes();
5530
- const endHour = end.getHours();
5531
- const endMinute = end.getMinutes();
5532
- if (startHour === hour && endHour !== hour) {
5533
- setRangeData(minutes, startMinute, 60, true);
5534
- } else if (startHour === hour && endHour === hour) {
5535
- setRangeData(minutes, startMinute, endMinute + 1, true);
5536
- } else if (startHour !== hour && endHour === hour) {
5537
- setRangeData(minutes, 0, endMinute + 1, true);
5538
- } else if (startHour < hour && endHour > hour) {
5539
- setRangeData(minutes, 0, 60, true);
5540
- }
5541
- });
5542
- } else {
5543
- setRangeData(minutes, 0, 60, true);
5544
- }
5545
- return minutes;
5546
- };
5547
-
5548
- const range = function(n) {
5549
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
5550
- return Array.apply(null, {length: n}).map((_, n) => n);
5551
- };
5552
-
5553
- const modifyDate = function(date, y, m, d) {
5554
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
5555
- };
5556
-
5557
- const modifyTime = function(date, h, m, s) {
5558
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
5559
- };
5560
-
5561
- const modifyWithTimeString = (date, time) => {
5562
- if (date == null || !time) {
5563
- return date;
5564
- }
5565
- time = parseDate(time, 'HH:mm:ss');
5566
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
5567
- };
5568
-
5569
- const clearTime = function(date) {
5570
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
5571
- };
5572
-
5573
- const clearMilliseconds = function(date) {
5574
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
5575
- };
5576
-
5577
- const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
5578
- // TODO: refactory a more elegant solution
5579
- if (ranges.length === 0) return date;
5580
- const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
5581
- const ndate = normalizeDate(date);
5582
- const nranges = ranges.map(range => range.map(normalizeDate));
5583
- if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
5584
-
5585
- let minDate = nranges[0][0];
5586
- let maxDate = nranges[0][0];
5587
-
5588
- nranges.forEach(nrange => {
5589
- minDate = new Date(Math.min(nrange[0], minDate));
5590
- maxDate = new Date(Math.max(nrange[1], minDate));
5591
- });
5592
-
5593
- const ret = ndate < minDate ? minDate : maxDate;
5594
- // preserve Year/Month/Date
5595
- return modifyDate(
5596
- ret,
5597
- date.getFullYear(),
5598
- date.getMonth(),
5599
- date.getDate()
5600
- );
5601
- };
5602
-
5603
- const timeWithinRange = function(date, selectableRange, format) {
5604
- const limitedDate = limitTimeRange(date, selectableRange, format);
5605
- return limitedDate.getTime() === date.getTime();
5606
- };
5607
-
5608
- const changeYearMonthAndClampDate = function(date, year, month) {
5609
- // clamp date to the number of days in `year`, `month`
5610
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
5611
- const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
5612
- return modifyDate(date, year, month, monthDate);
5613
- };
5614
-
5615
- const prevMonth = function(date) {
5616
- const year = date.getFullYear();
5617
- const month = date.getMonth();
5618
- return month === 0
5619
- ? changeYearMonthAndClampDate(date, year - 1, 11)
5620
- : changeYearMonthAndClampDate(date, year, month - 1);
5621
- };
5622
-
5623
- const nextMonth = function(date) {
5624
- const year = date.getFullYear();
5625
- const month = date.getMonth();
5626
- return month === 11
5627
- ? changeYearMonthAndClampDate(date, year + 1, 0)
5628
- : changeYearMonthAndClampDate(date, year, month + 1);
5629
- };
5630
-
5631
- const prevYear = function(date, amount = 1) {
5632
- const year = date.getFullYear();
5633
- const month = date.getMonth();
5634
- return changeYearMonthAndClampDate(date, year - amount, month);
5635
- };
5636
-
5637
- const nextYear = function(date, amount = 1) {
5638
- const year = date.getFullYear();
5639
- const month = date.getMonth();
5640
- return changeYearMonthAndClampDate(date, year + amount, month);
5641
- };
5642
-
5643
- const extractDateFormat = function(format) {
5644
- return format
5645
- .replace(/\W?m{1,2}|\W?ZZ/g, '')
5646
- .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
5647
- .trim();
5648
- };
5649
-
5650
- const extractTimeFormat = function(format) {
5651
- return format
5652
- .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
5653
- .trim();
5654
- };
5655
-
5656
- const validateRangeInOneMonth = function(start, end) {
5657
- return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
5658
- };
5659
-
5249
+ */
5250
+ fecha.parse = function (dateStr, format) {
5251
+ if (typeof format !== 'string') {
5252
+ throw new Error('Invalid format in fecha.parse');
5253
+ }
5254
+
5255
+ format = fecha.masks[format] || format;
5256
+
5257
+ // Avoid regular expression denial of service, fail early for really long strings
5258
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
5259
+ if (dateStr.length > 1000) {
5260
+ return null;
5261
+ }
5262
+
5263
+ var dateInfo = {};
5264
+ var parseInfo = [];
5265
+ var literals = [];
5266
+ format = format.replace(literal, function ($0, $1) {
5267
+ literals.push($1);
5268
+ return '@@@';
5269
+ });
5270
+ var newFormat = regexEscape(format).replace(token, function ($0) {
5271
+ if (parseFlags[$0]) {
5272
+ var info = parseFlags[$0];
5273
+ parseInfo.push(info[1]);
5274
+ return '(' + info[0] + ')';
5275
+ }
5276
+
5277
+ return $0;
5278
+ });
5279
+ newFormat = newFormat.replace(/@@@/g, function () {
5280
+ return literals.shift();
5281
+ });
5282
+ var matches = dateStr.match(new RegExp(newFormat, 'i'));
5283
+ if (!matches) {
5284
+ return null;
5285
+ }
5286
+
5287
+ for (var i = 1; i < matches.length; i++) {
5288
+ parseInfo[i - 1](dateInfo, matches[i]);
5289
+ }
5290
+
5291
+ var today = new Date();
5292
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
5293
+ dateInfo.hour = +dateInfo.hour + 12;
5294
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
5295
+ dateInfo.hour = 0;
5296
+ }
5297
+
5298
+ var date = void 0;
5299
+ if (dateInfo.timezoneOffset != null) {
5300
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
5301
+ 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));
5302
+ } else {
5303
+ 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);
5304
+ }
5305
+ return date;
5306
+ };
5307
+
5308
+ // 导出fecha对象
5309
+
5310
+
5311
+ // 以下是从date-util.js合并的函数
5312
+ var newArray = function newArray(start, end) {
5313
+ var result = [];
5314
+ for (var i = start; i <= end; i++) {
5315
+ result.push(i);
5316
+ }
5317
+ return result;
5318
+ };
5319
+
5320
+ var getSettings = function getSettings() {
5321
+ return {
5322
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
5323
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
5324
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
5325
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
5326
+ amPm: ['上午', '下午']
5327
+ };
5328
+ };
5329
+
5330
+ var toDate = function toDate(date) {
5331
+ return isDate(date) ? new Date(date) : null;
5332
+ };
5333
+
5334
+ var isDate = function isDate(date) {
5335
+ if (date === null || date === undefined) return false;
5336
+ if (isNaN(new Date(date).getTime())) return false;
5337
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
5338
+ return true;
5339
+ };
5340
+
5341
+ var isDateObject = function isDateObject(val) {
5342
+ return val instanceof Date;
5343
+ };
5344
+
5345
+ var formatDate = function formatDate(date) {
5346
+ var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
5347
+
5348
+ // 处理多种输入类型
5349
+ if (!date) return '';
5350
+
5351
+ // 如果是时间戳,转成日期对象
5352
+ if (typeof date === 'number') {
5353
+ date = new Date(date);
5354
+ }
5355
+ // 如果是字符串,转成日期对象
5356
+ if (typeof date === 'string') {
5357
+ date = new Date(date);
5358
+ }
5359
+
5360
+ // 调用toDate进一步验证和转换
5361
+ date = toDate(date);
5362
+ if (!date) return '';
5363
+
5364
+ // 兼容大写和小写的格式标记
5365
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
5366
+ var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
5367
+
5368
+ // 使用fecha库进行格式化,支持中文配置
5369
+ var str = fecha.format(date, lowercaseFormat, getSettings());
5370
+ return str;
5371
+ };
5372
+
5373
+ var parseDate = function parseDate(string, format) {
5374
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
5375
+ };
5376
+
5377
+ var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
5378
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
5379
+ return 30;
5380
+ }
5381
+
5382
+ if (month === 1) {
5383
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
5384
+ return 29;
5385
+ } else {
5386
+ return 28;
5387
+ }
5388
+ }
5389
+
5390
+ return 31;
5391
+ };
5392
+
5393
+ var getDayCountOfYear = function getDayCountOfYear(year) {
5394
+ var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
5395
+ return isLeapYear ? 366 : 365;
5396
+ };
5397
+
5398
+ var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
5399
+ var temp = new Date(date.getTime());
5400
+ temp.setDate(1);
5401
+ return temp.getDay();
5402
+ };
5403
+
5404
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
5405
+ // {prev, next} Date should work for Daylight Saving Time
5406
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
5407
+ var prevDate = function prevDate(date) {
5408
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5409
+
5410
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
5411
+ };
5412
+
5413
+ var nextDate = function nextDate(date) {
5414
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5415
+
5416
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
5417
+ };
5418
+
5419
+ var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
5420
+ var result = new Date(year, month, 1);
5421
+ var day = result.getDay();
5422
+
5423
+ if (day === 0) {
5424
+ return prevDate(result, 7);
5425
+ } else {
5426
+ return prevDate(result, day);
5427
+ }
5428
+ };
5429
+
5430
+ var getWeekNumber = function getWeekNumber(date) {
5431
+ // 支持多种输入类型
5432
+ if (!date || !isDate(date)) {
5433
+ date = new Date();
5434
+ }
5435
+ if (typeof date === 'string') {
5436
+ date = new Date(date);
5437
+ }
5438
+
5439
+ // 验证日期有效性
5440
+ if (!isDate(date)) return null;
5441
+
5442
+ var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
5443
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
5444
+ // 将星期日的星期数设为7
5445
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
5446
+ // 获取当年的第一天
5447
+ var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
5448
+ // 计算到最近的星期四的完整周数
5449
+ var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
5450
+ // 返回周数
5451
+ return weekNo;
5452
+ };
5453
+
5454
+ var getRangeHours = function getRangeHours(ranges) {
5455
+ var hours = [];
5456
+ var disabledHours = [];
5457
+
5458
+ (ranges || []).forEach(function (range) {
5459
+ var value = range.map(function (date) {
5460
+ return date.getHours();
5461
+ });
5462
+
5463
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
5464
+ });
5465
+
5466
+ if (disabledHours.length) {
5467
+ for (var i = 0; i < 24; i++) {
5468
+ hours[i] = disabledHours.indexOf(i) === -1;
5469
+ }
5470
+ } else {
5471
+ for (var _i = 0; _i < 24; _i++) {
5472
+ hours[_i] = false;
5473
+ }
5474
+ }
5475
+
5476
+ return hours;
5477
+ };
5478
+
5479
+ var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
5480
+ if (amount <= 0) return [];
5481
+ var temp = new Date(date.getTime());
5482
+ temp.setDate(0);
5483
+ var lastDay = temp.getDate();
5484
+ return range(amount).map(function (_, index) {
5485
+ return lastDay - (amount - index - 1);
5486
+ });
5487
+ };
5488
+
5489
+ var getMonthDays = function getMonthDays(date) {
5490
+ var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
5491
+ var days = temp.getDate();
5492
+ return range(days).map(function (_, index) {
5493
+ return index + 1;
5494
+ });
5495
+ };
5496
+
5497
+ function setRangeData(arr, start, end, value) {
5498
+ for (var i = start; i < end; i++) {
5499
+ arr[i] = value;
5500
+ }
5501
+ }
5502
+
5503
+ var getRangeMinutes = function getRangeMinutes(ranges, hour) {
5504
+ var minutes = new Array(60);
5505
+
5506
+ if (ranges.length > 0) {
5507
+ ranges.forEach(function (range) {
5508
+ var start = range[0];
5509
+ var end = range[1];
5510
+ var startHour = start.getHours();
5511
+ var startMinute = start.getMinutes();
5512
+ var endHour = end.getHours();
5513
+ var endMinute = end.getMinutes();
5514
+ if (startHour === hour && endHour !== hour) {
5515
+ setRangeData(minutes, startMinute, 60, true);
5516
+ } else if (startHour === hour && endHour === hour) {
5517
+ setRangeData(minutes, startMinute, endMinute + 1, true);
5518
+ } else if (startHour !== hour && endHour === hour) {
5519
+ setRangeData(minutes, 0, endMinute + 1, true);
5520
+ } else if (startHour < hour && endHour > hour) {
5521
+ setRangeData(minutes, 0, 60, true);
5522
+ }
5523
+ });
5524
+ } else {
5525
+ setRangeData(minutes, 0, 60, true);
5526
+ }
5527
+ return minutes;
5528
+ };
5529
+
5530
+ var range = function range(n) {
5531
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
5532
+ return Array.apply(null, { length: n }).map(function (_, n) {
5533
+ return n;
5534
+ });
5535
+ };
5536
+
5537
+ var modifyDate = function modifyDate(date, y, m, d) {
5538
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
5539
+ };
5540
+
5541
+ var modifyTime = function modifyTime(date, h, m, s) {
5542
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
5543
+ };
5544
+
5545
+ var modifyWithTimeString = function modifyWithTimeString(date, time) {
5546
+ if (date == null || !time) {
5547
+ return date;
5548
+ }
5549
+ time = parseDate(time, 'HH:mm:ss');
5550
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
5551
+ };
5552
+
5553
+ var clearTime = function clearTime(date) {
5554
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
5555
+ };
5556
+
5557
+ var clearMilliseconds = function clearMilliseconds(date) {
5558
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
5559
+ };
5560
+
5561
+ var limitTimeRange = function limitTimeRange(date, ranges) {
5562
+ var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
5563
+
5564
+ // TODO: refactory a more elegant solution
5565
+ if (ranges.length === 0) return date;
5566
+ var normalizeDate = function normalizeDate(date) {
5567
+ return fecha.parse(fecha.format(date, format), format);
5568
+ };
5569
+ var ndate = normalizeDate(date);
5570
+ var nranges = ranges.map(function (range) {
5571
+ return range.map(normalizeDate);
5572
+ });
5573
+ if (nranges.some(function (nrange) {
5574
+ return ndate >= nrange[0] && ndate <= nrange[1];
5575
+ })) return date;
5576
+
5577
+ var minDate = nranges[0][0];
5578
+ var maxDate = nranges[0][0];
5579
+
5580
+ nranges.forEach(function (nrange) {
5581
+ minDate = new Date(Math.min(nrange[0], minDate));
5582
+ maxDate = new Date(Math.max(nrange[1], minDate));
5583
+ });
5584
+
5585
+ var ret = ndate < minDate ? minDate : maxDate;
5586
+ // preserve Year/Month/Date
5587
+ return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
5588
+ };
5589
+
5590
+ var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
5591
+ var limitedDate = limitTimeRange(date, selectableRange, format);
5592
+ return limitedDate.getTime() === date.getTime();
5593
+ };
5594
+
5595
+ var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
5596
+ // clamp date to the number of days in `year`, `month`
5597
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
5598
+ var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
5599
+ return modifyDate(date, year, month, monthDate);
5600
+ };
5601
+
5602
+ var prevMonth = function prevMonth(date) {
5603
+ var year = date.getFullYear();
5604
+ var month = date.getMonth();
5605
+ return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
5606
+ };
5607
+
5608
+ var nextMonth = function nextMonth(date) {
5609
+ var year = date.getFullYear();
5610
+ var month = date.getMonth();
5611
+ return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
5612
+ };
5613
+
5614
+ var prevYear = function prevYear(date) {
5615
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5616
+
5617
+ var year = date.getFullYear();
5618
+ var month = date.getMonth();
5619
+ return changeYearMonthAndClampDate(date, year - amount, month);
5620
+ };
5621
+
5622
+ var nextYear = function nextYear(date) {
5623
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
5624
+
5625
+ var year = date.getFullYear();
5626
+ var month = date.getMonth();
5627
+ return changeYearMonthAndClampDate(date, year + amount, month);
5628
+ };
5629
+
5630
+ var extractDateFormat = function extractDateFormat(format) {
5631
+ return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
5632
+ };
5633
+
5634
+ var extractTimeFormat = function extractTimeFormat(format) {
5635
+ return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
5636
+ };
5637
+
5638
+ var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
5639
+ return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
5640
+ };
5641
+
5660
5642
  /**
5661
5643
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
5662
5644
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
5663
5645
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
5664
5646
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
5665
5647
  * @returns {number} 工作日数量
5666
- */
5667
- const calculateNetworkDays = function (start_date, end_date, holidays = []) {
5668
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
5669
- throw new Error(
5670
- "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
5671
- );
5672
- }
5673
-
5674
- const startDateObj = new Date(start_date);
5675
- const endDateObj = new Date(end_date);
5676
-
5677
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
5678
- throw new Error(
5679
- "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
5680
- );
5681
- }
5682
-
5683
- if (startDateObj > endDateObj) {
5684
- throw new Error('Start date should be earlier than or equal to end date.');
5685
- }
5686
-
5687
- let workdays = 0;
5688
-
5689
- // Iterate through each day in the date range
5690
- for (
5691
- let currentDate = new Date(startDateObj);
5692
- currentDate <= endDateObj;
5693
- currentDate.setDate(currentDate.getDate() + 1)
5694
- ) {
5695
- // Check if the current day is a weekend (Saturday or Sunday)
5696
- const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
5697
-
5698
- // Check if the current day is a holiday
5699
- const isHoliday = holidays.some((holiday) => {
5700
- const holidayDate = new Date(holiday);
5701
- return currentDate.toDateString() === holidayDate.toDateString();
5702
- });
5703
-
5704
- // If it's a workday (not a weekend or holiday), increment the workdays count
5705
- if (!isWeekend && !isHoliday) {
5706
- workdays++;
5707
- }
5708
- }
5709
-
5710
- return workdays;
5711
- };
5712
-
5648
+ */
5649
+ var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
5650
+ var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
5651
+
5652
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
5653
+ throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
5654
+ }
5655
+
5656
+ var startDateObj = new Date(start_date);
5657
+ var endDateObj = new Date(end_date);
5658
+
5659
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
5660
+ throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
5661
+ }
5662
+
5663
+ if (startDateObj > endDateObj) {
5664
+ throw new Error('Start date should be earlier than or equal to end date.');
5665
+ }
5666
+
5667
+ var workdays = 0;
5668
+
5669
+ // Iterate through each day in the date range
5670
+
5671
+ var _loop = function _loop(currentDate) {
5672
+ // Check if the current day is a weekend (Saturday or Sunday)
5673
+ var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
5674
+
5675
+ // Check if the current day is a holiday
5676
+ var isHoliday = holidays.some(function (holiday) {
5677
+ var holidayDate = new Date(holiday);
5678
+ return currentDate.toDateString() === holidayDate.toDateString();
5679
+ });
5680
+
5681
+ // If it's a workday (not a weekend or holiday), increment the workdays count
5682
+ if (!isWeekend && !isHoliday) {
5683
+ workdays++;
5684
+ }
5685
+ };
5686
+
5687
+ for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
5688
+ _loop(currentDate);
5689
+ }
5690
+
5691
+ return workdays;
5692
+ };
5693
+
5713
5694
  /**
5714
5695
  * 日期加减天数
5715
5696
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
5716
5697
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
5717
5698
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
5718
- */
5719
- const dateAddDays = function (start_date, days) {
5720
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
5721
- throw new Error(
5722
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
5723
- );
5724
- }
5725
-
5726
- const startDateObj = new Date(start_date);
5727
- if (isNaN(startDateObj.getTime())) {
5728
- throw new Error(
5729
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
5730
- );
5731
- }
5732
-
5733
- const resultDateObj = new Date(startDateObj);
5734
- resultDateObj.setDate(resultDateObj.getDate() + days);
5735
-
5736
- const resultYear = resultDateObj.getFullYear();
5737
- const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
5738
- const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
5739
-
5740
- return `${resultYear}-${resultMonth}-${resultDay}`;
5741
- };
5742
-
5699
+ */
5700
+ var dateAddDays = function dateAddDays(start_date, days) {
5701
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
5702
+ 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.");
5703
+ }
5704
+
5705
+ var startDateObj = new Date(start_date);
5706
+ if (isNaN(startDateObj.getTime())) {
5707
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5708
+ }
5709
+
5710
+ var resultDateObj = new Date(startDateObj);
5711
+ resultDateObj.setDate(resultDateObj.getDate() + days);
5712
+
5713
+ var resultYear = resultDateObj.getFullYear();
5714
+ var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
5715
+ var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
5716
+
5717
+ return resultYear + '-' + resultMonth + '-' + resultDay;
5718
+ };
5719
+
5743
5720
  /**
5744
5721
  * 计算两个日期之间的差值
5745
5722
  * @date 2023年12月14日
@@ -5747,182 +5724,180 @@ const dateAddDays = function (start_date, days) {
5747
5724
  * @param {String} end_date - 结束日期字符串
5748
5725
  * @param {String} unit - 单位:year/month/day
5749
5726
  * @returns {Number} 差值
5750
- */
5751
- const dateDiff = function (start_date, end_date, unit = 'day') {
5752
- // Assuming date strings are in "YYYY-MM-DD" format
5753
- var startDate = new Date(start_date);
5754
- var endDate = new Date(end_date);
5755
-
5756
- // If the date is invalid, return 0
5757
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
5758
- return 0;
5759
- }
5760
-
5761
- if (unit === 'year') {
5762
- return endDate.getFullYear() - startDate.getFullYear();
5763
- } else if (unit === 'month') {
5764
- return (
5765
- (endDate.getFullYear() - startDate.getFullYear()) * 12 +
5766
- (endDate.getMonth() - startDate.getMonth())
5767
- );
5768
- } else {
5769
- // Default to day
5770
- var timeDifference = endDate - startDate;
5771
- // Calculate days (86400000 milliseconds per day)
5772
- return Math.floor(timeDifference / 86400000);
5773
- }
5774
- };
5775
-
5727
+ */
5728
+ var dateDiff = function dateDiff(start_date, end_date) {
5729
+ var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
5730
+
5731
+ // Assuming date strings are in "YYYY-MM-DD" format
5732
+ var startDate = new Date(start_date);
5733
+ var endDate = new Date(end_date);
5734
+
5735
+ // If the date is invalid, return 0
5736
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
5737
+ return 0;
5738
+ }
5739
+
5740
+ if (unit === 'year') {
5741
+ return endDate.getFullYear() - startDate.getFullYear();
5742
+ } else if (unit === 'month') {
5743
+ return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
5744
+ } else {
5745
+ // Default to day
5746
+ var timeDifference = endDate - startDate;
5747
+ // Calculate days (86400000 milliseconds per day)
5748
+ return Math.floor(timeDifference / 86400000);
5749
+ }
5750
+ };
5751
+
5776
5752
  /**
5777
5753
  * 获取月份中的日期
5778
5754
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
5779
5755
  * @returns {number} 月份中的日期(1-31)
5780
- */
5781
- const dayOfMonth = function (date) {
5782
- if (typeof date !== 'string') {
5783
- throw new Error(
5784
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
5785
- );
5786
- }
5787
-
5788
- const dateObj = new Date(date);
5789
- if (isNaN(dateObj.getTime())) {
5790
- throw new Error(
5791
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
5792
- );
5793
- }
5794
-
5795
- return dateObj.getDate();
5796
- };
5797
-
5756
+ */
5757
+ var dayOfMonth = function dayOfMonth(date) {
5758
+ if (typeof date !== 'string') {
5759
+ throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5760
+ }
5761
+
5762
+ var dateObj = new Date(date);
5763
+ if (isNaN(dateObj.getTime())) {
5764
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
5765
+ }
5766
+
5767
+ return dateObj.getDate();
5768
+ };
5769
+
5798
5770
  /**
5799
5771
  * 获取当前日期
5800
5772
  * @date 2022年5月7日
5801
5773
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
5802
5774
  * @returns {string} 当前日期的格式化字符串
5803
- */
5804
- const getCurrentDate = function (format = 'YYYY-MM-DD') {
5805
- return formatDate(new Date(), format);
5806
- };
5807
-
5775
+ */
5776
+ var getCurrentDate = function getCurrentDate() {
5777
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
5778
+
5779
+ return formatDate(new Date(), format);
5780
+ };
5781
+
5808
5782
  /**
5809
5783
  * 获取当前日期时间
5810
5784
  * @date 2022年5月7日
5811
5785
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
5812
5786
  * @returns {string} 当前日期时间的格式化字符串
5813
- */
5814
- const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
5815
- return formatDate(new Date(), format);
5816
- };
5817
-
5787
+ */
5788
+ var getCurrentDateTime = function getCurrentDateTime() {
5789
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
5790
+
5791
+ return formatDate(new Date(), format);
5792
+ };
5793
+
5818
5794
  /**
5819
5795
  * 获取小时
5820
5796
  * @date 2022年5月7日
5821
5797
  * @param {Date|string} [date] - 日期对象或日期字符串
5822
5798
  * @returns {number} 小时数(0-23)
5823
- */
5824
- const getHour = function (date) {
5825
- if (!date) {
5826
- return new Date().getHours();
5827
- }
5828
- if (typeof date === 'string') {
5829
- date = new Date(date);
5830
- }
5831
- return date.getHours();
5832
- };
5833
-
5799
+ */
5800
+ var getHour = function getHour(date) {
5801
+ if (!date) {
5802
+ return new Date().getHours();
5803
+ }
5804
+ if (typeof date === 'string') {
5805
+ date = new Date(date);
5806
+ }
5807
+ return date.getHours();
5808
+ };
5809
+
5834
5810
  /**
5835
5811
  * 获取分钟
5836
5812
  * @date 2022年5月7日
5837
5813
  * @param {Date|string} [date] - 日期对象或日期字符串
5838
5814
  * @returns {number} 分钟数(0-59)
5839
- */
5840
- const getMinute = function (date) {
5841
- if (!date) {
5842
- return new Date().getMinutes();
5843
- }
5844
- if (typeof date === 'string') {
5845
- date = new Date(date);
5846
- }
5847
- return date.getMinutes();
5848
- };
5849
-
5815
+ */
5816
+ var getMinute = function getMinute(date) {
5817
+ if (!date) {
5818
+ return new Date().getMinutes();
5819
+ }
5820
+ if (typeof date === 'string') {
5821
+ date = new Date(date);
5822
+ }
5823
+ return date.getMinutes();
5824
+ };
5825
+
5850
5826
  /**
5851
5827
  * 获取月份
5852
5828
  * @date 2022年5月7日
5853
5829
  * @param {Date|string} [date] - 日期对象或日期字符串
5854
5830
  * @returns {number} 月份数(1-12)
5855
- */
5856
- const getMonth = function (date) {
5857
- if (!date) {
5858
- return new Date().getMonth() + 1;
5859
- }
5860
- if (typeof date === 'string') {
5861
- date = new Date(date);
5862
- }
5863
- return date.getMonth() + 1;
5864
- };
5865
-
5831
+ */
5832
+ var getMonth = function getMonth(date) {
5833
+ if (!date) {
5834
+ return new Date().getMonth() + 1;
5835
+ }
5836
+ if (typeof date === 'string') {
5837
+ date = new Date(date);
5838
+ }
5839
+ return date.getMonth() + 1;
5840
+ };
5841
+
5866
5842
  /**
5867
5843
  * 获取秒
5868
5844
  * @date 2022年5月7日
5869
5845
  * @param {Date|string} [date] - 日期对象或日期字符串
5870
5846
  * @returns {number} 秒数(0-59)
5871
- */
5872
- const getSecond = function (date) {
5873
- if (!date) {
5874
- return new Date().getSeconds();
5875
- }
5876
- if (typeof date === 'string') {
5877
- date = new Date(date);
5878
- }
5879
- return date.getSeconds();
5880
- };
5881
-
5847
+ */
5848
+ var getSecond = function getSecond(date) {
5849
+ if (!date) {
5850
+ return new Date().getSeconds();
5851
+ }
5852
+ if (typeof date === 'string') {
5853
+ date = new Date(date);
5854
+ }
5855
+ return date.getSeconds();
5856
+ };
5857
+
5882
5858
  /**
5883
5859
  * 获取星期几
5884
5860
  * @date 2022年5月7日
5885
5861
  * @param {Date|string} [date] - 日期对象或日期字符串
5886
5862
  * @returns {number} 星期几(0-6,0表示星期日)
5887
- */
5888
- const getWeekday = function (date) {
5889
- if (!date) {
5890
- return new Date().getDay();
5891
- }
5892
- if (typeof date === 'string') {
5893
- date = new Date(date);
5894
- }
5895
- return date.getDay();
5896
- };
5897
-
5898
-
5863
+ */
5864
+ var getWeekday = function getWeekday(date) {
5865
+ if (!date) {
5866
+ return new Date().getDay();
5867
+ }
5868
+ if (typeof date === 'string') {
5869
+ date = new Date(date);
5870
+ }
5871
+ return date.getDay();
5872
+ };
5873
+
5899
5874
  /**
5900
5875
  * @desc 获取上午/下午/晚上
5901
5876
  * @author huangbo
5902
5877
  * @date 2022年5月7日
5903
5878
  * @param {String} [time] - 时间
5904
- **/
5905
- const timeCycle = function (time) {
5906
- let hour = 0;
5907
- if (!time) {
5908
- hour = new Date().getHours();
5909
- } else if (typeof time === 'string') {
5910
- // 从时间字符串中提取小时
5911
- const match = time.match(/^(\d{1,2})/);
5912
- if (match) {
5913
- hour = parseInt(match[1], 10);
5914
- }
5915
- } else if (typeof time === 'number') {
5916
- hour = time;
5917
- }
5918
- // 判断时间段
5919
- if (hour >= 5 && hour < 12) {
5920
- return '上午';
5921
- } else if (hour >= 12 && hour < 18) {
5922
- return '下午';
5923
- } else {
5924
- return '晚上';
5925
- }
5879
+ **/
5880
+ var timeCycle = function timeCycle(time) {
5881
+ var hour = 0;
5882
+ if (!time) {
5883
+ hour = new Date().getHours();
5884
+ } else if (typeof time === 'string') {
5885
+ // 从时间字符串中提取小时
5886
+ var match = time.match(/^(\d{1,2})/);
5887
+ if (match) {
5888
+ hour = parseInt(match[1], 10);
5889
+ }
5890
+ } else if (typeof time === 'number') {
5891
+ hour = time;
5892
+ }
5893
+ // 判断时间段
5894
+ if (hour >= 5 && hour < 12) {
5895
+ return '上午';
5896
+ } else if (hour >= 12 && hour < 18) {
5897
+ return '下午';
5898
+ } else {
5899
+ return '晚上';
5900
+ }
5926
5901
  };
5927
5902
 
5928
5903
  /***/ }),