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/login.js CHANGED
@@ -82,7 +82,7 @@ module.exports =
82
82
  /******/
83
83
  /******/
84
84
  /******/ // Load entry module and return exports
85
- /******/ return __webpack_require__(__webpack_require__.s = 192);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 199);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ({
@@ -4467,20 +4467,13 @@ var getTableData = function getTableData(_ref9) {
4467
4467
 
4468
4468
  /***/ }),
4469
4469
 
4470
- /***/ 114:
4470
+ /***/ 116:
4471
4471
  /***/ (function(module, exports) {
4472
4472
 
4473
4473
  module.exports = require("eoss/lib/menu");
4474
4474
 
4475
4475
  /***/ }),
4476
4476
 
4477
- /***/ 117:
4478
- /***/ (function(module, exports) {
4479
-
4480
- module.exports = require("dompurify");
4481
-
4482
- /***/ }),
4483
-
4484
4477
  /***/ 12:
4485
4478
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4486
4479
 
@@ -4685,11 +4678,18 @@ var getRgb = function getRgb($color) {
4685
4678
  /***/ 121:
4686
4679
  /***/ (function(module, exports) {
4687
4680
 
4681
+ module.exports = require("dompurify");
4682
+
4683
+ /***/ }),
4684
+
4685
+ /***/ 125:
4686
+ /***/ (function(module, exports) {
4687
+
4688
4688
  module.exports = require("eoss/lib/qr-code");
4689
4689
 
4690
4690
  /***/ }),
4691
4691
 
4692
- /***/ 122:
4692
+ /***/ 126:
4693
4693
  /***/ (function(module, exports) {
4694
4694
 
4695
4695
  module.exports = require("eoss/lib/menu-item");
@@ -4703,35 +4703,35 @@ module.exports = require("eoss/lib/button");
4703
4703
 
4704
4704
  /***/ }),
4705
4705
 
4706
- /***/ 138:
4706
+ /***/ 142:
4707
4707
  /***/ (function(module, exports) {
4708
4708
 
4709
4709
  module.exports = require("eoss/lib/ca-login");
4710
4710
 
4711
4711
  /***/ }),
4712
4712
 
4713
- /***/ 139:
4713
+ /***/ 143:
4714
4714
  /***/ (function(module, exports) {
4715
4715
 
4716
4716
  module.exports = require("eoss/lib/phone-login");
4717
4717
 
4718
4718
  /***/ }),
4719
4719
 
4720
- /***/ 140:
4720
+ /***/ 144:
4721
4721
  /***/ (function(module, exports) {
4722
4722
 
4723
4723
  module.exports = require("eoss/lib/email-login");
4724
4724
 
4725
4725
  /***/ }),
4726
4726
 
4727
- /***/ 141:
4727
+ /***/ 145:
4728
4728
  /***/ (function(module, exports) {
4729
4729
 
4730
4730
  module.exports = require("eoss/lib/qrcode-login");
4731
4731
 
4732
4732
  /***/ }),
4733
4733
 
4734
- /***/ 142:
4734
+ /***/ 146:
4735
4735
  /***/ (function(module, exports) {
4736
4736
 
4737
4737
  module.exports = require("eoss/lib/account-login");
@@ -4745,7 +4745,7 @@ module.exports = require("eoss/lib/loading");
4745
4745
 
4746
4746
  /***/ }),
4747
4747
 
4748
- /***/ 163:
4748
+ /***/ 167:
4749
4749
  /***/ (function(module, exports) {
4750
4750
 
4751
4751
  module.exports = require("enquire.js");
@@ -4773,14 +4773,14 @@ module.exports = require("lodash/cloneDeep");
4773
4773
 
4774
4774
  /***/ }),
4775
4775
 
4776
- /***/ 192:
4776
+ /***/ 199:
4777
4777
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
4778
4778
 
4779
4779
  "use strict";
4780
4780
  // ESM COMPAT FLAG
4781
4781
  __webpack_require__.r(__webpack_exports__);
4782
4782
 
4783
- // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/login/src/login.vue?vue&type=template&id=d0760904&
4783
+ // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/login/src/login.vue?vue&type=template&id=c947c834&
4784
4784
  var render = function () {
4785
4785
  var _vm = this
4786
4786
  var _h = _vm.$createElement
@@ -5203,7 +5203,7 @@ var staticRenderFns = []
5203
5203
  render._withStripped = true
5204
5204
 
5205
5205
 
5206
- // CONCATENATED MODULE: ./packages/login/src/login.vue?vue&type=template&id=d0760904&
5206
+ // CONCATENATED MODULE: ./packages/login/src/login.vue?vue&type=template&id=c947c834&
5207
5207
 
5208
5208
  // CONCATENATED MODULE: ./packages/login/src/mixins.js
5209
5209
  /* harmony default export */ var mixins = ({
@@ -5301,7 +5301,7 @@ render._withStripped = true
5301
5301
  methods: {}
5302
5302
  });
5303
5303
  // EXTERNAL MODULE: external "dompurify"
5304
- var external_dompurify_ = __webpack_require__(117);
5304
+ var external_dompurify_ = __webpack_require__(121);
5305
5305
  var external_dompurify_default = /*#__PURE__*/__webpack_require__.n(external_dompurify_);
5306
5306
 
5307
5307
  // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/login/src/download.vue?vue&type=template&id=e2798aea&
@@ -5396,7 +5396,7 @@ var icon_ = __webpack_require__(26);
5396
5396
  var icon_default = /*#__PURE__*/__webpack_require__.n(icon_);
5397
5397
 
5398
5398
  // EXTERNAL MODULE: external "eoss/lib/qr-code"
5399
- var qr_code_ = __webpack_require__(121);
5399
+ var qr_code_ = __webpack_require__(125);
5400
5400
  var qr_code_default = /*#__PURE__*/__webpack_require__.n(qr_code_);
5401
5401
 
5402
5402
  // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/login/src/download.vue?vue&type=script&lang=js&
@@ -5503,7 +5503,7 @@ var component = Object(componentNormalizer["a" /* default */])(
5503
5503
 
5504
5504
  /* harmony default export */ var download = (component.exports);
5505
5505
  // EXTERNAL MODULE: external "eoss/lib/ca-login"
5506
- var ca_login_ = __webpack_require__(138);
5506
+ var ca_login_ = __webpack_require__(142);
5507
5507
  var ca_login_default = /*#__PURE__*/__webpack_require__.n(ca_login_);
5508
5508
 
5509
5509
  // EXTERNAL MODULE: external "eoss/lib/message-box"
@@ -5511,19 +5511,19 @@ var message_box_ = __webpack_require__(8);
5511
5511
  var message_box_default = /*#__PURE__*/__webpack_require__.n(message_box_);
5512
5512
 
5513
5513
  // EXTERNAL MODULE: external "eoss/lib/phone-login"
5514
- var phone_login_ = __webpack_require__(139);
5514
+ var phone_login_ = __webpack_require__(143);
5515
5515
  var phone_login_default = /*#__PURE__*/__webpack_require__.n(phone_login_);
5516
5516
 
5517
5517
  // EXTERNAL MODULE: external "eoss/lib/email-login"
5518
- var email_login_ = __webpack_require__(140);
5518
+ var email_login_ = __webpack_require__(144);
5519
5519
  var email_login_default = /*#__PURE__*/__webpack_require__.n(email_login_);
5520
5520
 
5521
5521
  // EXTERNAL MODULE: external "eoss/lib/qrcode-login"
5522
- var qrcode_login_ = __webpack_require__(141);
5522
+ var qrcode_login_ = __webpack_require__(145);
5523
5523
  var qrcode_login_default = /*#__PURE__*/__webpack_require__.n(qrcode_login_);
5524
5524
 
5525
5525
  // EXTERNAL MODULE: external "eoss/lib/account-login"
5526
- var account_login_ = __webpack_require__(142);
5526
+ var account_login_ = __webpack_require__(146);
5527
5527
  var account_login_default = /*#__PURE__*/__webpack_require__.n(account_login_);
5528
5528
 
5529
5529
  // EXTERNAL MODULE: ./src/utils/resize-event.js
@@ -5551,7 +5551,7 @@ if (typeof window !== 'undefined') {
5551
5551
  };
5552
5552
  window.matchMedia = window.matchMedia || matchMediaPolyfill;
5553
5553
  // eslint-disable-next-line global-require
5554
- enquire = __webpack_require__(163);
5554
+ enquire = __webpack_require__(167);
5555
5555
  }
5556
5556
 
5557
5557
  /**
@@ -5960,18 +5960,18 @@ function encryptFormData(data, secret, isEncrypt) {
5960
5960
 
5961
5961
  /* harmony default export */ var helpers = ({ encryptFormData: encryptFormData });
5962
5962
  // EXTERNAL MODULE: ./src/utils/rules.js
5963
- var rules = __webpack_require__(95);
5963
+ var rules = __webpack_require__(97);
5964
5964
 
5965
5965
  // EXTERNAL MODULE: external "eoss/lib/form"
5966
5966
  var form_ = __webpack_require__(25);
5967
5967
  var form_default = /*#__PURE__*/__webpack_require__.n(form_);
5968
5968
 
5969
5969
  // EXTERNAL MODULE: external "eoss/lib/menu"
5970
- var menu_ = __webpack_require__(114);
5970
+ var menu_ = __webpack_require__(116);
5971
5971
  var menu_default = /*#__PURE__*/__webpack_require__.n(menu_);
5972
5972
 
5973
5973
  // EXTERNAL MODULE: external "eoss/lib/menu-item"
5974
- var menu_item_ = __webpack_require__(122);
5974
+ var menu_item_ = __webpack_require__(126);
5975
5975
  var menu_item_default = /*#__PURE__*/__webpack_require__.n(menu_item_);
5976
5976
 
5977
5977
  // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/login/src/resetPassword.vue?vue&type=script&lang=js&
@@ -7101,6 +7101,7 @@ var LOGIN_TYPES = {
7101
7101
  operationCheckCode: '',
7102
7102
  // 用户名
7103
7103
  userName: '',
7104
+ loginModel: '0',
7104
7105
  // 二次效验接口地址
7105
7106
  doAssistanceQrLogin: api["t" /* doAssistanceQrLogin */],
7106
7107
  // 二次效验弹窗是否显示
@@ -8548,759 +8549,736 @@ var changeInTime = '/baseIssueRules/changeInTime';
8548
8549
  /* unused harmony export getSecond */
8549
8550
  /* unused harmony export getWeekday */
8550
8551
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return timeCycle; });
8551
- /* Modified from https://github.com/taylorhakes/fecha
8552
- *
8553
- * The MIT License (MIT)
8554
- *
8555
- * Copyright (c) 2015 Taylor Hakes
8556
- *
8557
- * Permission is hereby granted, free of charge, to any person obtaining a copy
8558
- * of this software and associated documentation files (the "Software"), to deal
8559
- * in the Software without restriction, including without limitation the rights
8560
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8561
- * copies of the Software, and to permit persons to whom the Software is
8562
- * furnished to do so, subject to the following conditions:
8563
- *
8564
- * The above copyright notice and this permission notice shall be included in all
8565
- * copies or substantial portions of the Software.
8566
- *
8567
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
8568
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
8569
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
8570
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
8571
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
8572
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
8573
- * SOFTWARE.
8574
- */
8575
-
8576
- /*eslint-disable*/
8577
- // 把 YYYY-MM-DD 改成了 yyyy-MM-dd
8578
-
8579
-
8552
+
8553
+
8580
8554
  /**
8581
8555
  * Parse or format dates
8582
8556
  * @class fecha
8583
- */
8584
- const fecha = {};
8585
- const token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
8586
- const twoDigits = '\\d\\d?';
8587
- const threeDigits = '\\d{3}';
8588
- const fourDigits = '\\d{4}';
8589
- const word = '[^\\s]+';
8590
- const literal = /\[([^]*?)\]/gm;
8591
- const noop = function () {};
8592
-
8593
- function regexEscape(str) {
8594
- return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
8595
- }
8596
-
8597
- function shorten(arr, sLen) {
8598
- const newArr = [];
8599
- for (let i = 0, len = arr.length; i < len; i++) {
8600
- newArr.push(arr[i].substr(0, sLen));
8601
- }
8602
- return newArr;
8603
- }
8604
-
8605
- function monthUpdate() {
8606
- return function (d, v) {
8607
- const index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
8608
- if (~index) {
8609
- d.month = index;
8610
- }
8611
- };
8612
- }
8613
-
8614
- function pad(val, len) {
8615
- val = String(val);
8616
- len = len || 2;
8617
- while (val.length < len) {
8618
- val = '0' + val;
8619
- }
8620
- return val;
8621
- }
8622
-
8623
- // 直接使用中文日期名称常量
8624
- const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
8625
- const monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
8626
- const monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
8627
- const dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
8628
- const amPm = ['上午', '下午'];
8629
- const DoFn = function DoFn(D) {
8630
- return D + '日';
8631
- };
8632
-
8633
- const formatFlags = {
8634
- D: function(dateObj) {
8635
- return dateObj.getDay();
8636
- },
8637
- DD: function(dateObj) {
8638
- return pad(dateObj.getDay());
8639
- },
8640
- Do: function(dateObj) {
8641
- return DoFn(dateObj.getDate());
8642
- },
8643
- d: function(dateObj) {
8644
- return dateObj.getDate();
8645
- },
8646
- dd: function(dateObj) {
8647
- return pad(dateObj.getDate());
8648
- },
8649
- ddd: function(dateObj) {
8650
- return dayNamesShort[dateObj.getDay()];
8651
- },
8652
- dddd: function(dateObj) {
8653
- return dayNames[dateObj.getDay()];
8654
- },
8655
- M: function(dateObj) {
8656
- return dateObj.getMonth() + 1;
8657
- },
8658
- MM: function(dateObj) {
8659
- return pad(dateObj.getMonth() + 1);
8660
- },
8661
- MMM: function(dateObj) {
8662
- return monthNamesShort[dateObj.getMonth()];
8663
- },
8664
- MMMM: function(dateObj) {
8665
- return monthNames[dateObj.getMonth()];
8666
- },
8667
- yy: function(dateObj) {
8668
- return pad(String(dateObj.getFullYear()), 4).substr(2);
8669
- },
8670
- yyyy: function(dateObj) {
8671
- return pad(dateObj.getFullYear(), 4);
8672
- },
8673
- h: function(dateObj) {
8674
- return dateObj.getHours() % 12 || 12;
8675
- },
8676
- hh: function(dateObj) {
8677
- return pad(dateObj.getHours() % 12 || 12);
8678
- },
8679
- H: function(dateObj) {
8680
- return dateObj.getHours();
8681
- },
8682
- HH: function(dateObj) {
8683
- return pad(dateObj.getHours());
8684
- },
8685
- m: function(dateObj) {
8686
- return dateObj.getMinutes();
8687
- },
8688
- mm: function(dateObj) {
8689
- return pad(dateObj.getMinutes());
8690
- },
8691
- s: function(dateObj) {
8692
- return dateObj.getSeconds();
8693
- },
8694
- ss: function(dateObj) {
8695
- return pad(dateObj.getSeconds());
8696
- },
8697
- S: function(dateObj) {
8698
- return Math.round(dateObj.getMilliseconds() / 100);
8699
- },
8700
- SS: function(dateObj) {
8701
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
8702
- },
8703
- SSS: function(dateObj) {
8704
- return pad(dateObj.getMilliseconds(), 3);
8705
- },
8706
- a: function(dateObj) {
8707
- return dateObj.getHours() < 12 ? '上午' : '下午';
8708
- },
8709
- A: function(dateObj) {
8710
- return dateObj.getHours() < 12 ? '上午' : '下午';
8711
- },
8712
- ZZ: function(dateObj) {
8713
- const o = dateObj.getTimezoneOffset();
8714
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
8715
- }
8716
- };
8717
-
8718
- const parseFlags = {
8719
- d: [twoDigits, function (d, v) {
8720
- d.day = v;
8721
- }],
8722
- Do: [twoDigits + word, function (d, v) {
8723
- d.day = parseInt(v, 10);
8724
- }],
8725
- M: [twoDigits, function (d, v) {
8726
- d.month = v - 1;
8727
- }],
8728
- yy: [twoDigits, function (d, v) {
8729
- const da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
8730
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
8731
- }],
8732
- h: [twoDigits, function (d, v) {
8733
- d.hour = v;
8734
- }],
8735
- m: [twoDigits, function (d, v) {
8736
- d.minute = v;
8737
- }],
8738
- s: [twoDigits, function (d, v) {
8739
- d.second = v;
8740
- }],
8741
- yyyy: [fourDigits, function (d, v) {
8742
- d.year = v;
8743
- }],
8744
- S: ['\\d', function (d, v) {
8745
- d.millisecond = v * 100;
8746
- }],
8747
- SS: ['\\d{2}', function (d, v) {
8748
- d.millisecond = v * 10;
8749
- }],
8750
- SSS: [threeDigits, function (d, v) {
8751
- d.millisecond = v;
8752
- }],
8753
- D: [twoDigits, noop],
8754
- ddd: [word, noop],
8755
- MMM: [word, monthUpdate('monthNamesShort')],
8756
- MMMM: [word, monthUpdate('monthNames')],
8757
- a: [word, function (d, v) {
8758
- const val = v.toLowerCase();
8759
- if (val === '上午') {
8760
- d.isPm = false;
8761
- } else if (val === '下午') {
8762
- d.isPm = true;
8763
- }
8764
- }],
8765
- ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
8766
- let parts = (v + '').match(/([+-]|\d\d)/gi), minutes;
8767
-
8768
- if (parts) {
8769
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
8770
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
8771
- }
8772
- }]
8773
- };
8774
- parseFlags.dd = parseFlags.d;
8775
- parseFlags.dddd = parseFlags.ddd;
8776
- parseFlags.DD = parseFlags.D;
8777
- parseFlags.mm = parseFlags.m;
8778
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
8779
- parseFlags.MM = parseFlags.M;
8780
- parseFlags.ss = parseFlags.s;
8781
- parseFlags.A = parseFlags.a;
8782
-
8783
-
8784
- // Some common format strings
8785
- fecha.masks = {
8786
- default: 'ddd MMM dd yyyy HH:mm:ss',
8787
- shortDate: 'M/D/yy',
8788
- mediumDate: 'MMM d, yyyy',
8789
- longDate: 'MMMM d, yyyy',
8790
- fullDate: 'dddd, MMMM d, yyyy',
8791
- shortTime: 'HH:mm',
8792
- mediumTime: 'HH:mm:ss',
8793
- longTime: 'HH:mm:ss.SSS'
8794
- };
8795
-
8557
+ */
8558
+ var fecha = {};
8559
+ var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
8560
+ var twoDigits = '\\d\\d?';
8561
+ var threeDigits = '\\d{3}';
8562
+ var fourDigits = '\\d{4}';
8563
+ var word = '[^\\s]+';
8564
+ var literal = /\[([^]*?)\]/gm;
8565
+ var noop = function noop() {};
8566
+
8567
+ function regexEscape(str) {
8568
+ return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
8569
+ }
8570
+
8571
+ function shorten(arr, sLen) {
8572
+ var newArr = [];
8573
+ for (var i = 0, len = arr.length; i < len; i++) {
8574
+ newArr.push(arr[i].substr(0, sLen));
8575
+ }
8576
+ return newArr;
8577
+ }
8578
+
8579
+ function monthUpdate() {
8580
+ return function (d, v) {
8581
+ var index = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'].indexOf(v.toLowerCase());
8582
+ if (~index) {
8583
+ d.month = index;
8584
+ }
8585
+ };
8586
+ }
8587
+
8588
+ function pad(val, len) {
8589
+ val = String(val);
8590
+ len = len || 2;
8591
+ while (val.length < len) {
8592
+ val = '0' + val;
8593
+ }
8594
+ return val;
8595
+ }
8596
+
8597
+ // 直接使用中文日期名称常量
8598
+ var dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
8599
+ var monthNames = ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'];
8600
+ var monthNamesShort = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
8601
+ var dayNamesShort = ['日', '一', '二', '三', '四', '五', '六'];
8602
+ var amPm = ['上午', '下午'];
8603
+ var DoFn = function DoFn(D) {
8604
+ return D + '日';
8605
+ };
8606
+
8607
+ var formatFlags = {
8608
+ D: function D(dateObj) {
8609
+ return dateObj.getDay();
8610
+ },
8611
+ DD: function DD(dateObj) {
8612
+ return pad(dateObj.getDay());
8613
+ },
8614
+ Do: function Do(dateObj) {
8615
+ return DoFn(dateObj.getDate());
8616
+ },
8617
+ d: function d(dateObj) {
8618
+ return dateObj.getDate();
8619
+ },
8620
+ dd: function dd(dateObj) {
8621
+ return pad(dateObj.getDate());
8622
+ },
8623
+ ddd: function ddd(dateObj) {
8624
+ return dayNamesShort[dateObj.getDay()];
8625
+ },
8626
+ dddd: function dddd(dateObj) {
8627
+ return dayNames[dateObj.getDay()];
8628
+ },
8629
+ M: function M(dateObj) {
8630
+ return dateObj.getMonth() + 1;
8631
+ },
8632
+ MM: function MM(dateObj) {
8633
+ return pad(dateObj.getMonth() + 1);
8634
+ },
8635
+ MMM: function MMM(dateObj) {
8636
+ return monthNamesShort[dateObj.getMonth()];
8637
+ },
8638
+ MMMM: function MMMM(dateObj) {
8639
+ return monthNames[dateObj.getMonth()];
8640
+ },
8641
+ yy: function yy(dateObj) {
8642
+ return pad(String(dateObj.getFullYear()), 4).substr(2);
8643
+ },
8644
+ yyyy: function yyyy(dateObj) {
8645
+ return pad(dateObj.getFullYear(), 4);
8646
+ },
8647
+ h: function h(dateObj) {
8648
+ return dateObj.getHours() % 12 || 12;
8649
+ },
8650
+ hh: function hh(dateObj) {
8651
+ return pad(dateObj.getHours() % 12 || 12);
8652
+ },
8653
+ H: function H(dateObj) {
8654
+ return dateObj.getHours();
8655
+ },
8656
+ HH: function HH(dateObj) {
8657
+ return pad(dateObj.getHours());
8658
+ },
8659
+ m: function m(dateObj) {
8660
+ return dateObj.getMinutes();
8661
+ },
8662
+ mm: function mm(dateObj) {
8663
+ return pad(dateObj.getMinutes());
8664
+ },
8665
+ s: function s(dateObj) {
8666
+ return dateObj.getSeconds();
8667
+ },
8668
+ ss: function ss(dateObj) {
8669
+ return pad(dateObj.getSeconds());
8670
+ },
8671
+ S: function S(dateObj) {
8672
+ return Math.round(dateObj.getMilliseconds() / 100);
8673
+ },
8674
+ SS: function SS(dateObj) {
8675
+ return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
8676
+ },
8677
+ SSS: function SSS(dateObj) {
8678
+ return pad(dateObj.getMilliseconds(), 3);
8679
+ },
8680
+ a: function a(dateObj) {
8681
+ return dateObj.getHours() < 12 ? '上午' : '下午';
8682
+ },
8683
+ A: function A(dateObj) {
8684
+ return dateObj.getHours() < 12 ? '上午' : '下午';
8685
+ },
8686
+ ZZ: function ZZ(dateObj) {
8687
+ var o = dateObj.getTimezoneOffset();
8688
+ return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
8689
+ }
8690
+ };
8691
+
8692
+ var parseFlags = {
8693
+ d: [twoDigits, function (d, v) {
8694
+ d.day = v;
8695
+ }],
8696
+ Do: [twoDigits + word, function (d, v) {
8697
+ d.day = parseInt(v, 10);
8698
+ }],
8699
+ M: [twoDigits, function (d, v) {
8700
+ d.month = v - 1;
8701
+ }],
8702
+ yy: [twoDigits, function (d, v) {
8703
+ var da = new Date(),
8704
+ cent = +('' + da.getFullYear()).substr(0, 2);
8705
+ d.year = '' + (v > 68 ? cent - 1 : cent) + v;
8706
+ }],
8707
+ h: [twoDigits, function (d, v) {
8708
+ d.hour = v;
8709
+ }],
8710
+ m: [twoDigits, function (d, v) {
8711
+ d.minute = v;
8712
+ }],
8713
+ s: [twoDigits, function (d, v) {
8714
+ d.second = v;
8715
+ }],
8716
+ yyyy: [fourDigits, function (d, v) {
8717
+ d.year = v;
8718
+ }],
8719
+ S: ['\\d', function (d, v) {
8720
+ d.millisecond = v * 100;
8721
+ }],
8722
+ SS: ['\\d{2}', function (d, v) {
8723
+ d.millisecond = v * 10;
8724
+ }],
8725
+ SSS: [threeDigits, function (d, v) {
8726
+ d.millisecond = v;
8727
+ }],
8728
+ D: [twoDigits, noop],
8729
+ ddd: [word, noop],
8730
+ MMM: [word, monthUpdate('monthNamesShort')],
8731
+ MMMM: [word, monthUpdate('monthNames')],
8732
+ a: [word, function (d, v) {
8733
+ var val = v.toLowerCase();
8734
+ if (val === '上午') {
8735
+ d.isPm = false;
8736
+ } else if (val === '下午') {
8737
+ d.isPm = true;
8738
+ }
8739
+ }],
8740
+ ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (d, v) {
8741
+ var parts = (v + '').match(/([+-]|\d\d)/gi),
8742
+ minutes = void 0;
8743
+
8744
+ if (parts) {
8745
+ minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
8746
+ d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
8747
+ }
8748
+ }]
8749
+ };
8750
+ parseFlags.dd = parseFlags.d;
8751
+ parseFlags.dddd = parseFlags.ddd;
8752
+ parseFlags.DD = parseFlags.D;
8753
+ parseFlags.mm = parseFlags.m;
8754
+ parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
8755
+ parseFlags.MM = parseFlags.M;
8756
+ parseFlags.ss = parseFlags.s;
8757
+ parseFlags.A = parseFlags.a;
8758
+
8759
+ // Some common format strings
8760
+ fecha.masks = {
8761
+ default: 'ddd MMM dd yyyy HH:mm:ss',
8762
+ shortDate: 'M/D/yy',
8763
+ mediumDate: 'MMM d, yyyy',
8764
+ longDate: 'MMMM d, yyyy',
8765
+ fullDate: 'dddd, MMMM d, yyyy',
8766
+ shortTime: 'HH:mm',
8767
+ mediumTime: 'HH:mm:ss',
8768
+ longTime: 'HH:mm:ss.SSS'
8769
+ };
8770
+
8796
8771
  /***
8797
8772
  * Format a date
8798
8773
  * @method format
8799
8774
  * @param {Date|number} dateObj
8800
8775
  * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
8801
- */
8802
- fecha.format = function (dateObj, mask) {
8803
- if (typeof dateObj === 'number') {
8804
- dateObj = new Date(dateObj);
8805
- }
8806
-
8807
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
8808
- throw new Error('Invalid Date in fecha.format');
8809
- }
8810
-
8811
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
8812
-
8813
- const literals = [];
8814
-
8815
- // Make literals inactive by replacing them with ??
8816
- mask = mask.replace(literal, function($0, $1) {
8817
- literals.push($1);
8818
- return '@@@';
8819
- });
8820
- // Apply formatting rules
8821
- mask = mask.replace(token, function ($0) {
8822
- return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
8823
- });
8824
- // Inline literal values back into the formatted value
8825
- return mask.replace(/@@@/g, function() {
8826
- return literals.shift();
8827
- });
8828
- };
8829
-
8776
+ */
8777
+ fecha.format = function (dateObj, mask) {
8778
+ if (typeof dateObj === 'number') {
8779
+ dateObj = new Date(dateObj);
8780
+ }
8781
+
8782
+ if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
8783
+ throw new Error('Invalid Date in fecha.format');
8784
+ }
8785
+
8786
+ mask = fecha.masks[mask] || mask || fecha.masks['default'];
8787
+
8788
+ var literals = [];
8789
+
8790
+ // Make literals inactive by replacing them with ??
8791
+ mask = mask.replace(literal, function ($0, $1) {
8792
+ literals.push($1);
8793
+ return '@@@';
8794
+ });
8795
+ // Apply formatting rules
8796
+ mask = mask.replace(token, function ($0) {
8797
+ return $0 in formatFlags ? formatFlags[$0](dateObj) : $0.slice(1, $0.length - 1);
8798
+ });
8799
+ // Inline literal values back into the formatted value
8800
+ return mask.replace(/@@@/g, function () {
8801
+ return literals.shift();
8802
+ });
8803
+ };
8804
+
8830
8805
  /**
8831
8806
  * Parse a date string into an object, changes - into /
8832
8807
  * @method parse
8833
8808
  * @param {string} dateStr Date string
8834
8809
  * @param {string} format Date parse format
8835
8810
  * @returns {Date|boolean}
8836
- */
8837
- fecha.parse = function (dateStr, format) {
8838
- if (typeof format !== 'string') {
8839
- throw new Error('Invalid format in fecha.parse');
8840
- }
8841
-
8842
- format = fecha.masks[format] || format;
8843
-
8844
- // Avoid regular expression denial of service, fail early for really long strings
8845
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
8846
- if (dateStr.length > 1000) {
8847
- return null;
8848
- }
8849
-
8850
- const dateInfo = {};
8851
- const parseInfo = [];
8852
- const literals = [];
8853
- format = format.replace(literal, function($0, $1) {
8854
- literals.push($1);
8855
- return '@@@';
8856
- });
8857
- let newFormat = regexEscape(format).replace(token, function ($0) {
8858
- if (parseFlags[$0]) {
8859
- const info = parseFlags[$0];
8860
- parseInfo.push(info[1]);
8861
- return '(' + info[0] + ')';
8862
- }
8863
-
8864
- return $0;
8865
- });
8866
- newFormat = newFormat.replace(/@@@/g, function() {
8867
- return literals.shift();
8868
- });
8869
- const matches = dateStr.match(new RegExp(newFormat, 'i'));
8870
- if (!matches) {
8871
- return null;
8872
- }
8873
-
8874
- for (let i = 1; i < matches.length; i++) {
8875
- parseInfo[i - 1](dateInfo, matches[i]);
8876
- }
8877
-
8878
- const today = new Date();
8879
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
8880
- dateInfo.hour = +dateInfo.hour + 12;
8881
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
8882
- dateInfo.hour = 0;
8883
- }
8884
-
8885
- let date;
8886
- if (dateInfo.timezoneOffset != null) {
8887
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
8888
- date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
8889
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
8890
- } else {
8891
- date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
8892
- dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
8893
- }
8894
- return date;
8895
- };
8896
-
8897
- // 导出fecha对象
8898
-
8899
-
8900
- // 以下是从date-util.js合并的函数
8901
- const newArray = function(start, end) {
8902
- let result = [];
8903
- for (let i = start; i <= end; i++) {
8904
- result.push(i);
8905
- }
8906
- return result;
8907
- };
8908
-
8909
- const getSettings = () => {
8910
- return {
8911
- dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
8912
- dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
8913
- monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
8914
- monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
8915
- amPm: ['上午', '下午']
8916
- };
8917
- };
8918
-
8919
- const toDate = function(date) {
8920
- return isDate(date) ? new Date(date) : null;
8921
- };
8922
-
8923
- const isDate = function(date) {
8924
- if (date === null || date === undefined) return false;
8925
- if (isNaN(new Date(date).getTime())) return false;
8926
- if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
8927
- return true;
8928
- };
8929
-
8930
- const isDateObject = function(val) {
8931
- return val instanceof Date;
8932
- };
8933
-
8934
- const formatDate = function (date, format = 'yyyy-MM-dd') {
8935
- // 处理多种输入类型
8936
- if (!date) return '';
8937
-
8938
- // 如果是时间戳,转成日期对象
8939
- if (typeof date === 'number') {
8940
- date = new Date(date);
8941
- }
8942
- // 如果是字符串,转成日期对象
8943
- if (typeof date === 'string') {
8944
- date = new Date(date);
8945
- }
8946
-
8947
- // 调用toDate进一步验证和转换
8948
- date = toDate(date);
8949
- if (!date) return '';
8950
-
8951
- // 兼容大写和小写的格式标记
8952
- // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
8953
- const lowercaseFormat = format
8954
- .replace(/YYYY/g, 'yyyy')
8955
- .replace(/D/g, 'd')
8956
-
8957
- // 使用fecha库进行格式化,支持中文配置
8958
- const str = fecha.format(date, lowercaseFormat, getSettings());
8959
- return str;
8960
- };
8961
-
8962
- const parseDate = function(string, format) {
8963
- return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
8964
- };
8965
-
8966
- const getDayCountOfMonth = function(year, month) {
8967
- if (month === 3 || month === 5 || month === 8 || month === 10) {
8968
- return 30;
8969
- }
8970
-
8971
- if (month === 1) {
8972
- if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
8973
- return 29;
8974
- } else {
8975
- return 28;
8976
- }
8977
- }
8978
-
8979
- return 31;
8980
- };
8981
-
8982
- const getDayCountOfYear = function(year) {
8983
- const isLeapYear = year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0);
8984
- return isLeapYear ? 366 : 365;
8985
- };
8986
-
8987
- const getFirstDayOfMonth = function(date) {
8988
- const temp = new Date(date.getTime());
8989
- temp.setDate(1);
8990
- return temp.getDay();
8991
- };
8992
-
8993
- // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
8994
- // {prev, next} Date should work for Daylight Saving Time
8995
- // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
8996
- const prevDate = function(date, amount = 1) {
8997
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
8998
- };
8999
-
9000
- const nextDate = function(date, amount = 1) {
9001
- return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
9002
- };
9003
-
9004
- const getStartDateOfMonth = function(year, month) {
9005
- const result = new Date(year, month, 1);
9006
- const day = result.getDay();
9007
-
9008
- if (day === 0) {
9009
- return prevDate(result, 7);
9010
- } else {
9011
- return prevDate(result, day);
9012
- }
9013
- };
9014
-
9015
- const getWeekNumber = function(date) {
9016
- // 支持多种输入类型
9017
- if (!date||!isDate(date)) {
9018
- date = new Date();
9019
- }
9020
- if (typeof date === 'string') {
9021
- date = new Date(date);
9022
- }
9023
-
9024
- // 验证日期有效性
9025
- if (!isDate(date)) return null;
9026
-
9027
- const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
9028
- // 设置为最近的星期四:当前日期 + 4 - 当前星期数
9029
- // 将星期日的星期数设为7
9030
- d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
9031
- // 获取当年的第一天
9032
- const yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
9033
- // 计算到最近的星期四的完整周数
9034
- const weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
9035
- // 返回周数
9036
- return weekNo;
9037
- };
9038
-
9039
- const getRangeHours = function(ranges) {
9040
- const hours = [];
9041
- let disabledHours = [];
9042
-
9043
- (ranges || []).forEach(range => {
9044
- const value = range.map(date => date.getHours());
9045
-
9046
- disabledHours = disabledHours.concat(newArray(value[0], value[1]));
9047
- });
9048
-
9049
- if (disabledHours.length) {
9050
- for (let i = 0; i < 24; i++) {
9051
- hours[i] = disabledHours.indexOf(i) === -1;
9052
- }
9053
- } else {
9054
- for (let i = 0; i < 24; i++) {
9055
- hours[i] = false;
9056
- }
9057
- }
9058
-
9059
- return hours;
9060
- };
9061
-
9062
- const getPrevMonthLastDays = (date, amount) => {
9063
- if (amount <= 0) return [];
9064
- const temp = new Date(date.getTime());
9065
- temp.setDate(0);
9066
- const lastDay = temp.getDate();
9067
- return range(amount).map((_, index) => lastDay - (amount - index - 1));
9068
- };
9069
-
9070
- const getMonthDays = (date) => {
9071
- const temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
9072
- const days = temp.getDate();
9073
- return range(days).map((_, index) => index + 1);
9074
- };
9075
-
9076
- function setRangeData(arr, start, end, value) {
9077
- for (let i = start; i < end; i++) {
9078
- arr[i] = value;
9079
- }
9080
- }
9081
-
9082
- const getRangeMinutes = function(ranges, hour) {
9083
- const minutes = new Array(60);
9084
-
9085
- if (ranges.length > 0) {
9086
- ranges.forEach(range => {
9087
- const start = range[0];
9088
- const end = range[1];
9089
- const startHour = start.getHours();
9090
- const startMinute = start.getMinutes();
9091
- const endHour = end.getHours();
9092
- const endMinute = end.getMinutes();
9093
- if (startHour === hour && endHour !== hour) {
9094
- setRangeData(minutes, startMinute, 60, true);
9095
- } else if (startHour === hour && endHour === hour) {
9096
- setRangeData(minutes, startMinute, endMinute + 1, true);
9097
- } else if (startHour !== hour && endHour === hour) {
9098
- setRangeData(minutes, 0, endMinute + 1, true);
9099
- } else if (startHour < hour && endHour > hour) {
9100
- setRangeData(minutes, 0, 60, true);
9101
- }
9102
- });
9103
- } else {
9104
- setRangeData(minutes, 0, 60, true);
9105
- }
9106
- return minutes;
9107
- };
9108
-
9109
- const range = function(n) {
9110
- // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
9111
- return Array.apply(null, {length: n}).map((_, n) => n);
9112
- };
9113
-
9114
- const modifyDate = function(date, y, m, d) {
9115
- return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
9116
- };
9117
-
9118
- const modifyTime = function(date, h, m, s) {
9119
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
9120
- };
9121
-
9122
- const modifyWithTimeString = (date, time) => {
9123
- if (date == null || !time) {
9124
- return date;
9125
- }
9126
- time = parseDate(time, 'HH:mm:ss');
9127
- return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
9128
- };
9129
-
9130
- const clearTime = function(date) {
9131
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
9132
- };
9133
-
9134
- const clearMilliseconds = function(date) {
9135
- return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
9136
- };
9137
-
9138
- const limitTimeRange = function(date, ranges, format = 'HH:mm:ss') {
9139
- // TODO: refactory a more elegant solution
9140
- if (ranges.length === 0) return date;
9141
- const normalizeDate = date => fecha.parse(fecha.format(date, format), format);
9142
- const ndate = normalizeDate(date);
9143
- const nranges = ranges.map(range => range.map(normalizeDate));
9144
- if (nranges.some(nrange => ndate >= nrange[0] && ndate <= nrange[1])) return date;
9145
-
9146
- let minDate = nranges[0][0];
9147
- let maxDate = nranges[0][0];
9148
-
9149
- nranges.forEach(nrange => {
9150
- minDate = new Date(Math.min(nrange[0], minDate));
9151
- maxDate = new Date(Math.max(nrange[1], minDate));
9152
- });
9153
-
9154
- const ret = ndate < minDate ? minDate : maxDate;
9155
- // preserve Year/Month/Date
9156
- return modifyDate(
9157
- ret,
9158
- date.getFullYear(),
9159
- date.getMonth(),
9160
- date.getDate()
9161
- );
9162
- };
9163
-
9164
- const timeWithinRange = function(date, selectableRange, format) {
9165
- const limitedDate = limitTimeRange(date, selectableRange, format);
9166
- return limitedDate.getTime() === date.getTime();
9167
- };
9168
-
9169
- const changeYearMonthAndClampDate = function(date, year, month) {
9170
- // clamp date to the number of days in `year`, `month`
9171
- // eg: (2010-1-31, 2010, 2) => 2010-2-28
9172
- const monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
9173
- return modifyDate(date, year, month, monthDate);
9174
- };
9175
-
9176
- const prevMonth = function(date) {
9177
- const year = date.getFullYear();
9178
- const month = date.getMonth();
9179
- return month === 0
9180
- ? changeYearMonthAndClampDate(date, year - 1, 11)
9181
- : changeYearMonthAndClampDate(date, year, month - 1);
9182
- };
9183
-
9184
- const nextMonth = function(date) {
9185
- const year = date.getFullYear();
9186
- const month = date.getMonth();
9187
- return month === 11
9188
- ? changeYearMonthAndClampDate(date, year + 1, 0)
9189
- : changeYearMonthAndClampDate(date, year, month + 1);
9190
- };
9191
-
9192
- const prevYear = function(date, amount = 1) {
9193
- const year = date.getFullYear();
9194
- const month = date.getMonth();
9195
- return changeYearMonthAndClampDate(date, year - amount, month);
9196
- };
9197
-
9198
- const nextYear = function(date, amount = 1) {
9199
- const year = date.getFullYear();
9200
- const month = date.getMonth();
9201
- return changeYearMonthAndClampDate(date, year + amount, month);
9202
- };
9203
-
9204
- const extractDateFormat = function(format) {
9205
- return format
9206
- .replace(/\W?m{1,2}|\W?ZZ/g, '')
9207
- .replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '')
9208
- .trim();
9209
- };
9210
-
9211
- const extractTimeFormat = function(format) {
9212
- return format
9213
- .replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '')
9214
- .trim();
9215
- };
9216
-
9217
- const validateRangeInOneMonth = function(start, end) {
9218
- return (start.getMonth() === end.getMonth()) && (start.getFullYear() === end.getFullYear());
9219
- };
9220
-
8811
+ */
8812
+ fecha.parse = function (dateStr, format) {
8813
+ if (typeof format !== 'string') {
8814
+ throw new Error('Invalid format in fecha.parse');
8815
+ }
8816
+
8817
+ format = fecha.masks[format] || format;
8818
+
8819
+ // Avoid regular expression denial of service, fail early for really long strings
8820
+ // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
8821
+ if (dateStr.length > 1000) {
8822
+ return null;
8823
+ }
8824
+
8825
+ var dateInfo = {};
8826
+ var parseInfo = [];
8827
+ var literals = [];
8828
+ format = format.replace(literal, function ($0, $1) {
8829
+ literals.push($1);
8830
+ return '@@@';
8831
+ });
8832
+ var newFormat = regexEscape(format).replace(token, function ($0) {
8833
+ if (parseFlags[$0]) {
8834
+ var info = parseFlags[$0];
8835
+ parseInfo.push(info[1]);
8836
+ return '(' + info[0] + ')';
8837
+ }
8838
+
8839
+ return $0;
8840
+ });
8841
+ newFormat = newFormat.replace(/@@@/g, function () {
8842
+ return literals.shift();
8843
+ });
8844
+ var matches = dateStr.match(new RegExp(newFormat, 'i'));
8845
+ if (!matches) {
8846
+ return null;
8847
+ }
8848
+
8849
+ for (var i = 1; i < matches.length; i++) {
8850
+ parseInfo[i - 1](dateInfo, matches[i]);
8851
+ }
8852
+
8853
+ var today = new Date();
8854
+ if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
8855
+ dateInfo.hour = +dateInfo.hour + 12;
8856
+ } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
8857
+ dateInfo.hour = 0;
8858
+ }
8859
+
8860
+ var date = void 0;
8861
+ if (dateInfo.timezoneOffset != null) {
8862
+ dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
8863
+ 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));
8864
+ } else {
8865
+ 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);
8866
+ }
8867
+ return date;
8868
+ };
8869
+
8870
+ // 导出fecha对象
8871
+
8872
+
8873
+ // 以下是从date-util.js合并的函数
8874
+ var newArray = function newArray(start, end) {
8875
+ var result = [];
8876
+ for (var i = start; i <= end; i++) {
8877
+ result.push(i);
8878
+ }
8879
+ return result;
8880
+ };
8881
+
8882
+ var getSettings = function getSettings() {
8883
+ return {
8884
+ dayNamesShort: ['日', '一', '二', '三', '四', '五', '六'],
8885
+ dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
8886
+ monthNamesShort: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
8887
+ monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
8888
+ amPm: ['上午', '下午']
8889
+ };
8890
+ };
8891
+
8892
+ var toDate = function toDate(date) {
8893
+ return isDate(date) ? new Date(date) : null;
8894
+ };
8895
+
8896
+ var isDate = function isDate(date) {
8897
+ if (date === null || date === undefined) return false;
8898
+ if (isNaN(new Date(date).getTime())) return false;
8899
+ if (Array.isArray(date)) return false; // deal with `new Date([ new Date() ]) -> new Date()`
8900
+ return true;
8901
+ };
8902
+
8903
+ var isDateObject = function isDateObject(val) {
8904
+ return val instanceof Date;
8905
+ };
8906
+
8907
+ var formatDate = function formatDate(date) {
8908
+ var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'yyyy-MM-dd';
8909
+
8910
+ // 处理多种输入类型
8911
+ if (!date) return '';
8912
+
8913
+ // 如果是时间戳,转成日期对象
8914
+ if (typeof date === 'number') {
8915
+ date = new Date(date);
8916
+ }
8917
+ // 如果是字符串,转成日期对象
8918
+ if (typeof date === 'string') {
8919
+ date = new Date(date);
8920
+ }
8921
+
8922
+ // 调用toDate进一步验证和转换
8923
+ date = toDate(date);
8924
+ if (!date) return '';
8925
+
8926
+ // 兼容大写和小写的格式标记
8927
+ // 将大写的YYYY/MM/DD/HH/mm/ss转换为小写的yyyy/mm/dd/hh/mm/ss
8928
+ var lowercaseFormat = format.replace(/YYYY/g, 'yyyy').replace(/D/g, 'd');
8929
+
8930
+ // 使用fecha库进行格式化,支持中文配置
8931
+ var str = fecha.format(date, lowercaseFormat, getSettings());
8932
+ return str;
8933
+ };
8934
+
8935
+ var parseDate = function parseDate(string, format) {
8936
+ return fecha.parse(string, format || 'yyyy-MM-dd', getSettings());
8937
+ };
8938
+
8939
+ var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
8940
+ if (month === 3 || month === 5 || month === 8 || month === 10) {
8941
+ return 30;
8942
+ }
8943
+
8944
+ if (month === 1) {
8945
+ if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
8946
+ return 29;
8947
+ } else {
8948
+ return 28;
8949
+ }
8950
+ }
8951
+
8952
+ return 31;
8953
+ };
8954
+
8955
+ var getDayCountOfYear = function getDayCountOfYear(year) {
8956
+ var isLeapYear = year % 400 === 0 || year % 100 !== 0 && year % 4 === 0;
8957
+ return isLeapYear ? 366 : 365;
8958
+ };
8959
+
8960
+ var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
8961
+ var temp = new Date(date.getTime());
8962
+ temp.setDate(1);
8963
+ return temp.getDay();
8964
+ };
8965
+
8966
+ // see: https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript
8967
+ // {prev, next} Date should work for Daylight Saving Time
8968
+ // Adding 24 * 60 * 60 * 1000 does not work in the above scenario
8969
+ var prevDate = function prevDate(date) {
8970
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
8971
+
8972
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
8973
+ };
8974
+
8975
+ var nextDate = function nextDate(date) {
8976
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
8977
+
8978
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
8979
+ };
8980
+
8981
+ var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
8982
+ var result = new Date(year, month, 1);
8983
+ var day = result.getDay();
8984
+
8985
+ if (day === 0) {
8986
+ return prevDate(result, 7);
8987
+ } else {
8988
+ return prevDate(result, day);
8989
+ }
8990
+ };
8991
+
8992
+ var getWeekNumber = function getWeekNumber(date) {
8993
+ // 支持多种输入类型
8994
+ if (!date || !isDate(date)) {
8995
+ date = new Date();
8996
+ }
8997
+ if (typeof date === 'string') {
8998
+ date = new Date(date);
8999
+ }
9000
+
9001
+ // 验证日期有效性
9002
+ if (!isDate(date)) return null;
9003
+
9004
+ var d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
9005
+ // 设置为最近的星期四:当前日期 + 4 - 当前星期数
9006
+ // 将星期日的星期数设为7
9007
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
9008
+ // 获取当年的第一天
9009
+ var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
9010
+ // 计算到最近的星期四的完整周数
9011
+ var weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
9012
+ // 返回周数
9013
+ return weekNo;
9014
+ };
9015
+
9016
+ var getRangeHours = function getRangeHours(ranges) {
9017
+ var hours = [];
9018
+ var disabledHours = [];
9019
+
9020
+ (ranges || []).forEach(function (range) {
9021
+ var value = range.map(function (date) {
9022
+ return date.getHours();
9023
+ });
9024
+
9025
+ disabledHours = disabledHours.concat(newArray(value[0], value[1]));
9026
+ });
9027
+
9028
+ if (disabledHours.length) {
9029
+ for (var i = 0; i < 24; i++) {
9030
+ hours[i] = disabledHours.indexOf(i) === -1;
9031
+ }
9032
+ } else {
9033
+ for (var _i = 0; _i < 24; _i++) {
9034
+ hours[_i] = false;
9035
+ }
9036
+ }
9037
+
9038
+ return hours;
9039
+ };
9040
+
9041
+ var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
9042
+ if (amount <= 0) return [];
9043
+ var temp = new Date(date.getTime());
9044
+ temp.setDate(0);
9045
+ var lastDay = temp.getDate();
9046
+ return range(amount).map(function (_, index) {
9047
+ return lastDay - (amount - index - 1);
9048
+ });
9049
+ };
9050
+
9051
+ var getMonthDays = function getMonthDays(date) {
9052
+ var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
9053
+ var days = temp.getDate();
9054
+ return range(days).map(function (_, index) {
9055
+ return index + 1;
9056
+ });
9057
+ };
9058
+
9059
+ function setRangeData(arr, start, end, value) {
9060
+ for (var i = start; i < end; i++) {
9061
+ arr[i] = value;
9062
+ }
9063
+ }
9064
+
9065
+ var getRangeMinutes = function getRangeMinutes(ranges, hour) {
9066
+ var minutes = new Array(60);
9067
+
9068
+ if (ranges.length > 0) {
9069
+ ranges.forEach(function (range) {
9070
+ var start = range[0];
9071
+ var end = range[1];
9072
+ var startHour = start.getHours();
9073
+ var startMinute = start.getMinutes();
9074
+ var endHour = end.getHours();
9075
+ var endMinute = end.getMinutes();
9076
+ if (startHour === hour && endHour !== hour) {
9077
+ setRangeData(minutes, startMinute, 60, true);
9078
+ } else if (startHour === hour && endHour === hour) {
9079
+ setRangeData(minutes, startMinute, endMinute + 1, true);
9080
+ } else if (startHour !== hour && endHour === hour) {
9081
+ setRangeData(minutes, 0, endMinute + 1, true);
9082
+ } else if (startHour < hour && endHour > hour) {
9083
+ setRangeData(minutes, 0, 60, true);
9084
+ }
9085
+ });
9086
+ } else {
9087
+ setRangeData(minutes, 0, 60, true);
9088
+ }
9089
+ return minutes;
9090
+ };
9091
+
9092
+ var range = function range(n) {
9093
+ // see https://stackoverflow.com/questions/3746725/create-a-javascript-array-containing-1-n
9094
+ return Array.apply(null, { length: n }).map(function (_, n) {
9095
+ return n;
9096
+ });
9097
+ };
9098
+
9099
+ var modifyDate = function modifyDate(date, y, m, d) {
9100
+ return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
9101
+ };
9102
+
9103
+ var modifyTime = function modifyTime(date, h, m, s) {
9104
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
9105
+ };
9106
+
9107
+ var modifyWithTimeString = function modifyWithTimeString(date, time) {
9108
+ if (date == null || !time) {
9109
+ return date;
9110
+ }
9111
+ time = parseDate(time, 'HH:mm:ss');
9112
+ return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
9113
+ };
9114
+
9115
+ var clearTime = function clearTime(date) {
9116
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
9117
+ };
9118
+
9119
+ var clearMilliseconds = function clearMilliseconds(date) {
9120
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
9121
+ };
9122
+
9123
+ var limitTimeRange = function limitTimeRange(date, ranges) {
9124
+ var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'HH:mm:ss';
9125
+
9126
+ // TODO: refactory a more elegant solution
9127
+ if (ranges.length === 0) return date;
9128
+ var normalizeDate = function normalizeDate(date) {
9129
+ return fecha.parse(fecha.format(date, format), format);
9130
+ };
9131
+ var ndate = normalizeDate(date);
9132
+ var nranges = ranges.map(function (range) {
9133
+ return range.map(normalizeDate);
9134
+ });
9135
+ if (nranges.some(function (nrange) {
9136
+ return ndate >= nrange[0] && ndate <= nrange[1];
9137
+ })) return date;
9138
+
9139
+ var minDate = nranges[0][0];
9140
+ var maxDate = nranges[0][0];
9141
+
9142
+ nranges.forEach(function (nrange) {
9143
+ minDate = new Date(Math.min(nrange[0], minDate));
9144
+ maxDate = new Date(Math.max(nrange[1], minDate));
9145
+ });
9146
+
9147
+ var ret = ndate < minDate ? minDate : maxDate;
9148
+ // preserve Year/Month/Date
9149
+ return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
9150
+ };
9151
+
9152
+ var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
9153
+ var limitedDate = limitTimeRange(date, selectableRange, format);
9154
+ return limitedDate.getTime() === date.getTime();
9155
+ };
9156
+
9157
+ var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
9158
+ // clamp date to the number of days in `year`, `month`
9159
+ // eg: (2010-1-31, 2010, 2) => 2010-2-28
9160
+ var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
9161
+ return modifyDate(date, year, month, monthDate);
9162
+ };
9163
+
9164
+ var prevMonth = function prevMonth(date) {
9165
+ var year = date.getFullYear();
9166
+ var month = date.getMonth();
9167
+ return month === 0 ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
9168
+ };
9169
+
9170
+ var nextMonth = function nextMonth(date) {
9171
+ var year = date.getFullYear();
9172
+ var month = date.getMonth();
9173
+ return month === 11 ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
9174
+ };
9175
+
9176
+ var prevYear = function prevYear(date) {
9177
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
9178
+
9179
+ var year = date.getFullYear();
9180
+ var month = date.getMonth();
9181
+ return changeYearMonthAndClampDate(date, year - amount, month);
9182
+ };
9183
+
9184
+ var nextYear = function nextYear(date) {
9185
+ var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
9186
+
9187
+ var year = date.getFullYear();
9188
+ var month = date.getMonth();
9189
+ return changeYearMonthAndClampDate(date, year + amount, month);
9190
+ };
9191
+
9192
+ var extractDateFormat = function extractDateFormat(format) {
9193
+ return format.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
9194
+ };
9195
+
9196
+ var extractTimeFormat = function extractTimeFormat(format) {
9197
+ return format.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
9198
+ };
9199
+
9200
+ var validateRangeInOneMonth = function validateRangeInOneMonth(start, end) {
9201
+ return start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear();
9202
+ };
9203
+
9221
9204
  /**
9222
9205
  * 计算两个日期之间的工作日数量(不包括周末和节假日)
9223
9206
  * @param {string} start_date - 开始日期字符串,格式为 "YYYY-MM-DD"
9224
9207
  * @param {string} end_date - 结束日期字符串,格式为 "YYYY-MM-DD"
9225
9208
  * @param {Array<string>} holidays - 假期日期字符串数组,格式为 "YYYY-MM-DD"
9226
9209
  * @returns {number} 工作日数量
9227
- */
9228
- const calculateNetworkDays = function (start_date, end_date, holidays = []) {
9229
- if (typeof start_date !== 'string' || typeof end_date !== 'string') {
9230
- throw new Error(
9231
- "Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'."
9232
- );
9233
- }
9234
-
9235
- const startDateObj = new Date(start_date);
9236
- const endDateObj = new Date(end_date);
9237
-
9238
- if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
9239
- throw new Error(
9240
- "Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'."
9241
- );
9242
- }
9243
-
9244
- if (startDateObj > endDateObj) {
9245
- throw new Error('Start date should be earlier than or equal to end date.');
9246
- }
9247
-
9248
- let workdays = 0;
9249
-
9250
- // Iterate through each day in the date range
9251
- for (
9252
- let currentDate = new Date(startDateObj);
9253
- currentDate <= endDateObj;
9254
- currentDate.setDate(currentDate.getDate() + 1)
9255
- ) {
9256
- // Check if the current day is a weekend (Saturday or Sunday)
9257
- const isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
9258
-
9259
- // Check if the current day is a holiday
9260
- const isHoliday = holidays.some((holiday) => {
9261
- const holidayDate = new Date(holiday);
9262
- return currentDate.toDateString() === holidayDate.toDateString();
9263
- });
9264
-
9265
- // If it's a workday (not a weekend or holiday), increment the workdays count
9266
- if (!isWeekend && !isHoliday) {
9267
- workdays++;
9268
- }
9269
- }
9270
-
9271
- return workdays;
9272
- };
9273
-
9210
+ */
9211
+ var calculateNetworkDays = function calculateNetworkDays(start_date, end_date) {
9212
+ var holidays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
9213
+
9214
+ if (typeof start_date !== 'string' || typeof end_date !== 'string') {
9215
+ throw new Error("Invalid input. Please provide valid date strings in the format 'YYYY-MM-DD'.");
9216
+ }
9217
+
9218
+ var startDateObj = new Date(start_date);
9219
+ var endDateObj = new Date(end_date);
9220
+
9221
+ if (isNaN(startDateObj.getTime()) || isNaN(endDateObj.getTime())) {
9222
+ throw new Error("Invalid date format. Please provide valid date strings in the format 'YYYY-MM-DD'.");
9223
+ }
9224
+
9225
+ if (startDateObj > endDateObj) {
9226
+ throw new Error('Start date should be earlier than or equal to end date.');
9227
+ }
9228
+
9229
+ var workdays = 0;
9230
+
9231
+ // Iterate through each day in the date range
9232
+
9233
+ var _loop = function _loop(currentDate) {
9234
+ // Check if the current day is a weekend (Saturday or Sunday)
9235
+ var isWeekend = currentDate.getDay() === 0 || currentDate.getDay() === 6;
9236
+
9237
+ // Check if the current day is a holiday
9238
+ var isHoliday = holidays.some(function (holiday) {
9239
+ var holidayDate = new Date(holiday);
9240
+ return currentDate.toDateString() === holidayDate.toDateString();
9241
+ });
9242
+
9243
+ // If it's a workday (not a weekend or holiday), increment the workdays count
9244
+ if (!isWeekend && !isHoliday) {
9245
+ workdays++;
9246
+ }
9247
+ };
9248
+
9249
+ for (var currentDate = new Date(startDateObj); currentDate <= endDateObj; currentDate.setDate(currentDate.getDate() + 1)) {
9250
+ _loop(currentDate);
9251
+ }
9252
+
9253
+ return workdays;
9254
+ };
9255
+
9274
9256
  /**
9275
9257
  * 日期加减天数
9276
9258
  * @param {string} start_date - 起始日期字符串,格式为 "YYYY-MM-DD"
9277
9259
  * @param {number} days - 要加上或减去的天数,正数表示加,负数表示减
9278
9260
  * @returns {string} 结果日期,格式为 "YYYY-MM-DD"
9279
- */
9280
- const dateAddDays = function (start_date, days) {
9281
- if (typeof start_date !== 'string' || !Number.isInteger(days)) {
9282
- throw new Error(
9283
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD' and a valid integer for the number of days."
9284
- );
9285
- }
9286
-
9287
- const startDateObj = new Date(start_date);
9288
- if (isNaN(startDateObj.getTime())) {
9289
- throw new Error(
9290
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
9291
- );
9292
- }
9293
-
9294
- const resultDateObj = new Date(startDateObj);
9295
- resultDateObj.setDate(resultDateObj.getDate() + days);
9296
-
9297
- const resultYear = resultDateObj.getFullYear();
9298
- const resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
9299
- const resultDay = String(resultDateObj.getDate()).padStart(2, '0');
9300
-
9301
- return `${resultYear}-${resultMonth}-${resultDay}`;
9302
- };
9303
-
9261
+ */
9262
+ var dateAddDays = function dateAddDays(start_date, days) {
9263
+ if (typeof start_date !== 'string' || !Number.isInteger(days)) {
9264
+ 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.");
9265
+ }
9266
+
9267
+ var startDateObj = new Date(start_date);
9268
+ if (isNaN(startDateObj.getTime())) {
9269
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
9270
+ }
9271
+
9272
+ var resultDateObj = new Date(startDateObj);
9273
+ resultDateObj.setDate(resultDateObj.getDate() + days);
9274
+
9275
+ var resultYear = resultDateObj.getFullYear();
9276
+ var resultMonth = String(resultDateObj.getMonth() + 1).padStart(2, '0');
9277
+ var resultDay = String(resultDateObj.getDate()).padStart(2, '0');
9278
+
9279
+ return resultYear + '-' + resultMonth + '-' + resultDay;
9280
+ };
9281
+
9304
9282
  /**
9305
9283
  * 计算两个日期之间的差值
9306
9284
  * @date 2023年12月14日
@@ -9308,182 +9286,180 @@ const dateAddDays = function (start_date, days) {
9308
9286
  * @param {String} end_date - 结束日期字符串
9309
9287
  * @param {String} unit - 单位:year/month/day
9310
9288
  * @returns {Number} 差值
9311
- */
9312
- const dateDiff = function (start_date, end_date, unit = 'day') {
9313
- // Assuming date strings are in "YYYY-MM-DD" format
9314
- var startDate = new Date(start_date);
9315
- var endDate = new Date(end_date);
9316
-
9317
- // If the date is invalid, return 0
9318
- if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
9319
- return 0;
9320
- }
9321
-
9322
- if (unit === 'year') {
9323
- return endDate.getFullYear() - startDate.getFullYear();
9324
- } else if (unit === 'month') {
9325
- return (
9326
- (endDate.getFullYear() - startDate.getFullYear()) * 12 +
9327
- (endDate.getMonth() - startDate.getMonth())
9328
- );
9329
- } else {
9330
- // Default to day
9331
- var timeDifference = endDate - startDate;
9332
- // Calculate days (86400000 milliseconds per day)
9333
- return Math.floor(timeDifference / 86400000);
9334
- }
9335
- };
9336
-
9289
+ */
9290
+ var dateDiff = function dateDiff(start_date, end_date) {
9291
+ var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'day';
9292
+
9293
+ // Assuming date strings are in "YYYY-MM-DD" format
9294
+ var startDate = new Date(start_date);
9295
+ var endDate = new Date(end_date);
9296
+
9297
+ // If the date is invalid, return 0
9298
+ if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
9299
+ return 0;
9300
+ }
9301
+
9302
+ if (unit === 'year') {
9303
+ return endDate.getFullYear() - startDate.getFullYear();
9304
+ } else if (unit === 'month') {
9305
+ return (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
9306
+ } else {
9307
+ // Default to day
9308
+ var timeDifference = endDate - startDate;
9309
+ // Calculate days (86400000 milliseconds per day)
9310
+ return Math.floor(timeDifference / 86400000);
9311
+ }
9312
+ };
9313
+
9337
9314
  /**
9338
9315
  * 获取月份中的日期
9339
9316
  * @param {string} date - 日期字符串,格式为 "YYYY-MM-DD"
9340
9317
  * @returns {number} 月份中的日期(1-31)
9341
- */
9342
- const dayOfMonth = function (date) {
9343
- if (typeof date !== 'string') {
9344
- throw new Error(
9345
- "Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'."
9346
- );
9347
- }
9348
-
9349
- const dateObj = new Date(date);
9350
- if (isNaN(dateObj.getTime())) {
9351
- throw new Error(
9352
- "Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'."
9353
- );
9354
- }
9355
-
9356
- return dateObj.getDate();
9357
- };
9358
-
9318
+ */
9319
+ var dayOfMonth = function dayOfMonth(date) {
9320
+ if (typeof date !== 'string') {
9321
+ throw new Error("Invalid input. Please provide a valid date string in the format 'YYYY-MM-DD'.");
9322
+ }
9323
+
9324
+ var dateObj = new Date(date);
9325
+ if (isNaN(dateObj.getTime())) {
9326
+ throw new Error("Invalid date format. Please provide a valid date string in the format 'YYYY-MM-DD'.");
9327
+ }
9328
+
9329
+ return dateObj.getDate();
9330
+ };
9331
+
9359
9332
  /**
9360
9333
  * 获取当前日期
9361
9334
  * @date 2022年5月7日
9362
9335
  * @param {string} format - 日期格式,默认为'YYYY-MM-DD'
9363
9336
  * @returns {string} 当前日期的格式化字符串
9364
- */
9365
- const getCurrentDate = function (format = 'YYYY-MM-DD') {
9366
- return formatDate(new Date(), format);
9367
- };
9368
-
9337
+ */
9338
+ var getCurrentDate = function getCurrentDate() {
9339
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD';
9340
+
9341
+ return formatDate(new Date(), format);
9342
+ };
9343
+
9369
9344
  /**
9370
9345
  * 获取当前日期时间
9371
9346
  * @date 2022年5月7日
9372
9347
  * @param {string} format - 日期时间格式,默认为'YYYY-MM-DD HH:mm:ss'
9373
9348
  * @returns {string} 当前日期时间的格式化字符串
9374
- */
9375
- const getCurrentDateTime = function (format = 'YYYY-MM-DD HH:mm:ss') {
9376
- return formatDate(new Date(), format);
9377
- };
9378
-
9349
+ */
9350
+ var getCurrentDateTime = function getCurrentDateTime() {
9351
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'YYYY-MM-DD HH:mm:ss';
9352
+
9353
+ return formatDate(new Date(), format);
9354
+ };
9355
+
9379
9356
  /**
9380
9357
  * 获取小时
9381
9358
  * @date 2022年5月7日
9382
9359
  * @param {Date|string} [date] - 日期对象或日期字符串
9383
9360
  * @returns {number} 小时数(0-23)
9384
- */
9385
- const getHour = function (date) {
9386
- if (!date) {
9387
- return new Date().getHours();
9388
- }
9389
- if (typeof date === 'string') {
9390
- date = new Date(date);
9391
- }
9392
- return date.getHours();
9393
- };
9394
-
9361
+ */
9362
+ var getHour = function getHour(date) {
9363
+ if (!date) {
9364
+ return new Date().getHours();
9365
+ }
9366
+ if (typeof date === 'string') {
9367
+ date = new Date(date);
9368
+ }
9369
+ return date.getHours();
9370
+ };
9371
+
9395
9372
  /**
9396
9373
  * 获取分钟
9397
9374
  * @date 2022年5月7日
9398
9375
  * @param {Date|string} [date] - 日期对象或日期字符串
9399
9376
  * @returns {number} 分钟数(0-59)
9400
- */
9401
- const getMinute = function (date) {
9402
- if (!date) {
9403
- return new Date().getMinutes();
9404
- }
9405
- if (typeof date === 'string') {
9406
- date = new Date(date);
9407
- }
9408
- return date.getMinutes();
9409
- };
9410
-
9377
+ */
9378
+ var getMinute = function getMinute(date) {
9379
+ if (!date) {
9380
+ return new Date().getMinutes();
9381
+ }
9382
+ if (typeof date === 'string') {
9383
+ date = new Date(date);
9384
+ }
9385
+ return date.getMinutes();
9386
+ };
9387
+
9411
9388
  /**
9412
9389
  * 获取月份
9413
9390
  * @date 2022年5月7日
9414
9391
  * @param {Date|string} [date] - 日期对象或日期字符串
9415
9392
  * @returns {number} 月份数(1-12)
9416
- */
9417
- const getMonth = function (date) {
9418
- if (!date) {
9419
- return new Date().getMonth() + 1;
9420
- }
9421
- if (typeof date === 'string') {
9422
- date = new Date(date);
9423
- }
9424
- return date.getMonth() + 1;
9425
- };
9426
-
9393
+ */
9394
+ var getMonth = function getMonth(date) {
9395
+ if (!date) {
9396
+ return new Date().getMonth() + 1;
9397
+ }
9398
+ if (typeof date === 'string') {
9399
+ date = new Date(date);
9400
+ }
9401
+ return date.getMonth() + 1;
9402
+ };
9403
+
9427
9404
  /**
9428
9405
  * 获取秒
9429
9406
  * @date 2022年5月7日
9430
9407
  * @param {Date|string} [date] - 日期对象或日期字符串
9431
9408
  * @returns {number} 秒数(0-59)
9432
- */
9433
- const getSecond = function (date) {
9434
- if (!date) {
9435
- return new Date().getSeconds();
9436
- }
9437
- if (typeof date === 'string') {
9438
- date = new Date(date);
9439
- }
9440
- return date.getSeconds();
9441
- };
9442
-
9409
+ */
9410
+ var getSecond = function getSecond(date) {
9411
+ if (!date) {
9412
+ return new Date().getSeconds();
9413
+ }
9414
+ if (typeof date === 'string') {
9415
+ date = new Date(date);
9416
+ }
9417
+ return date.getSeconds();
9418
+ };
9419
+
9443
9420
  /**
9444
9421
  * 获取星期几
9445
9422
  * @date 2022年5月7日
9446
9423
  * @param {Date|string} [date] - 日期对象或日期字符串
9447
9424
  * @returns {number} 星期几(0-6,0表示星期日)
9448
- */
9449
- const getWeekday = function (date) {
9450
- if (!date) {
9451
- return new Date().getDay();
9452
- }
9453
- if (typeof date === 'string') {
9454
- date = new Date(date);
9455
- }
9456
- return date.getDay();
9457
- };
9458
-
9459
-
9425
+ */
9426
+ var getWeekday = function getWeekday(date) {
9427
+ if (!date) {
9428
+ return new Date().getDay();
9429
+ }
9430
+ if (typeof date === 'string') {
9431
+ date = new Date(date);
9432
+ }
9433
+ return date.getDay();
9434
+ };
9435
+
9460
9436
  /**
9461
9437
  * @desc 获取上午/下午/晚上
9462
9438
  * @author huangbo
9463
9439
  * @date 2022年5月7日
9464
9440
  * @param {String} [time] - 时间
9465
- **/
9466
- const timeCycle = function (time) {
9467
- let hour = 0;
9468
- if (!time) {
9469
- hour = new Date().getHours();
9470
- } else if (typeof time === 'string') {
9471
- // 从时间字符串中提取小时
9472
- const match = time.match(/^(\d{1,2})/);
9473
- if (match) {
9474
- hour = parseInt(match[1], 10);
9475
- }
9476
- } else if (typeof time === 'number') {
9477
- hour = time;
9478
- }
9479
- // 判断时间段
9480
- if (hour >= 5 && hour < 12) {
9481
- return '上午';
9482
- } else if (hour >= 12 && hour < 18) {
9483
- return '下午';
9484
- } else {
9485
- return '晚上';
9486
- }
9441
+ **/
9442
+ var timeCycle = function timeCycle(time) {
9443
+ var hour = 0;
9444
+ if (!time) {
9445
+ hour = new Date().getHours();
9446
+ } else if (typeof time === 'string') {
9447
+ // 从时间字符串中提取小时
9448
+ var match = time.match(/^(\d{1,2})/);
9449
+ if (match) {
9450
+ hour = parseInt(match[1], 10);
9451
+ }
9452
+ } else if (typeof time === 'number') {
9453
+ hour = time;
9454
+ }
9455
+ // 判断时间段
9456
+ if (hour >= 5 && hour < 12) {
9457
+ return '上午';
9458
+ } else if (hour >= 12 && hour < 18) {
9459
+ return '下午';
9460
+ } else {
9461
+ return '晚上';
9462
+ }
9487
9463
  };
9488
9464
 
9489
9465
  /***/ }),
@@ -9502,7 +9478,7 @@ module.exports = require("eoss/lib/message");
9502
9478
 
9503
9479
  /***/ }),
9504
9480
 
9505
- /***/ 95:
9481
+ /***/ 97:
9506
9482
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
9507
9483
 
9508
9484
  "use strict";