@opentiny/vue-renderless 3.1.0-alpha.0
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.
- package/action-sheet/index.js +28 -0
- package/action-sheet/vue.js +29 -0
- package/alert/index.js +23 -0
- package/alert/vue.js +37 -0
- package/autocomplete/index.js +175 -0
- package/autocomplete/vue.js +171 -0
- package/avatar/index.js +29 -0
- package/avatar/vue.js +24 -0
- package/badge/index.js +16 -0
- package/badge/vue.js +30 -0
- package/breadcrumb/vue.js +4 -0
- package/breadcrumb-item/vue.js +24 -0
- package/bulletin-board/index.js +21 -0
- package/bulletin-board/vue.js +36 -0
- package/button/index.js +19 -0
- package/button/vue.js +43 -0
- package/button-group/index.js +25 -0
- package/button-group/vue.js +51 -0
- package/calendar/index.js +279 -0
- package/calendar/vue.js +124 -0
- package/card-template/index.js +39 -0
- package/card-template/vue.js +34 -0
- package/carousel/index.js +206 -0
- package/carousel/vue.js +222 -0
- package/carousel-item/index.js +93 -0
- package/carousel-item/vue.js +57 -0
- package/cascader/index.js +511 -0
- package/cascader/vue.js +342 -0
- package/cascader-menu/index.js +41 -0
- package/cascader-menu/vue.js +36 -0
- package/cascader-node/index.js +63 -0
- package/cascader-node/vue.js +62 -0
- package/cascader-panel/index.js +359 -0
- package/cascader-panel/node.js +199 -0
- package/cascader-panel/store.js +80 -0
- package/cascader-panel/vue.js +217 -0
- package/checkbox/index.js +145 -0
- package/checkbox/vue.js +139 -0
- package/checkbox-button/index.js +102 -0
- package/checkbox-button/vue.js +150 -0
- package/checkbox-group/index.js +12 -0
- package/checkbox-group/vue.js +33 -0
- package/col/index.js +132 -0
- package/col/vue.js +34 -0
- package/collapse/index.js +45 -0
- package/collapse/vue.js +35 -0
- package/collapse-item/index.js +38 -0
- package/collapse-item/vue.js +48 -0
- package/common/array.js +120 -0
- package/common/bigInt.js +352 -0
- package/common/browser.js +69 -0
- package/common/dataset/index.js +135 -0
- package/common/date.js +352 -0
- package/common/decimal.js +203 -0
- package/common/deps/ResizeObserver.js +474 -0
- package/common/deps/after-leave.js +25 -0
- package/common/deps/clickoutside.js +61 -0
- package/common/deps/date-util.js +262 -0
- package/common/deps/date.js +308 -0
- package/common/deps/debounce.js +4 -0
- package/common/deps/dom.js +190 -0
- package/common/deps/fullscreen/apis.js +157 -0
- package/common/deps/fullscreen/screenfull.js +106 -0
- package/common/deps/letter-only.js +15 -0
- package/common/deps/memorize.js +149 -0
- package/common/deps/number-only.js +16 -0
- package/common/deps/popper.js +713 -0
- package/common/deps/popup-manager.js +179 -0
- package/common/deps/repeat-click.js +24 -0
- package/common/deps/requestAnimationFrame.js +25 -0
- package/common/deps/resize-event.js +29 -0
- package/common/deps/scroll-into-view.js +29 -0
- package/common/deps/scrollbar-width.js +25 -0
- package/common/deps/throttle.js +34 -0
- package/common/deps/touch.js +33 -0
- package/common/deps/tree-model/node.js +586 -0
- package/common/deps/tree-model/tree-store.js +377 -0
- package/common/deps/tree-model/util.js +14 -0
- package/common/deps/upload-ajax.js +71 -0
- package/common/deps/vue-emitter.js +30 -0
- package/common/deps/vue-popper.js +291 -0
- package/common/deps/vue-popup.js +211 -0
- package/common/event.js +17 -0
- package/common/index.js +288 -0
- package/common/object.js +228 -0
- package/common/runtime.js +52 -0
- package/common/string.js +446 -0
- package/common/type.js +65 -0
- package/common/validate/index.js +6 -0
- package/common/validate/messages.js +68 -0
- package/common/validate/rules/enum.js +8 -0
- package/common/validate/rules/index.js +14 -0
- package/common/validate/rules/pattern.js +16 -0
- package/common/validate/rules/range.js +62 -0
- package/common/validate/rules/required.js +13 -0
- package/common/validate/rules/type.js +110 -0
- package/common/validate/rules/whitespace.js +6 -0
- package/common/validate/schema.js +323 -0
- package/common/validate/util.js +198 -0
- package/common/validate/validations/array.js +25 -0
- package/common/validate/validations/date.js +35 -0
- package/common/validate/validations/enum.js +24 -0
- package/common/validate/validations/float.js +24 -0
- package/common/validate/validations/index.js +42 -0
- package/common/validate/validations/integer.js +24 -0
- package/common/validate/validations/method.js +23 -0
- package/common/validate/validations/number.js +27 -0
- package/common/validate/validations/pattern.js +23 -0
- package/common/validate/validations/required.js +15 -0
- package/common/validate/validations/string.js +29 -0
- package/common/validate/validations/type.js +25 -0
- package/common/xss.js +325 -0
- package/container/index.js +110 -0
- package/container/vue.js +63 -0
- package/credit-card/index.js +107 -0
- package/credit-card/vue.js +117 -0
- package/credit-card-form/index.js +143 -0
- package/credit-card-form/vue.js +150 -0
- package/crop/index.js +297 -0
- package/crop/vue.js +191 -0
- package/date-panel/index.js +584 -0
- package/date-panel/vue.js +319 -0
- package/date-picker/index.js +301 -0
- package/date-picker/vue.js +169 -0
- package/date-range/index.js +463 -0
- package/date-range/vue.js +297 -0
- package/date-table/index.js +457 -0
- package/date-table/vue.js +151 -0
- package/detail-page/index.js +135 -0
- package/detail-page/vue.js +145 -0
- package/dialog-box/index.js +268 -0
- package/dialog-box/vue.js +226 -0
- package/drop-times/index.js +23 -0
- package/drop-times/vue.js +28 -0
- package/dropdown/index.js +259 -0
- package/dropdown/vue.js +107 -0
- package/dropdown-item/index.js +155 -0
- package/dropdown-item/vue.js +124 -0
- package/dropdown-menu/index.js +148 -0
- package/dropdown-menu/vue.js +44 -0
- package/exception/index.js +13 -0
- package/exception/vue.js +25 -0
- package/fall-menu/index.js +121 -0
- package/fall-menu/vue.js +90 -0
- package/file-upload/index.js +1940 -0
- package/file-upload/vue.js +458 -0
- package/floatbar/index.js +10 -0
- package/floatbar/vue.js +17 -0
- package/form/index.js +186 -0
- package/form/vue.js +69 -0
- package/form-item/index.js +364 -0
- package/form-item/vue.js +210 -0
- package/fullscreen/index.js +138 -0
- package/fullscreen/vue.js +77 -0
- package/grid/core/index.js +3 -0
- package/grid/core/interceptor.js +38 -0
- package/grid/core/storeMap.js +19 -0
- package/grid/plugins/export.js +169 -0
- package/grid/plugins/exportExcel.js +749 -0
- package/grid/plugins/header.js +58 -0
- package/grid/plugins/resize.js +82 -0
- package/grid/static/array/arrayEach.js +12 -0
- package/grid/static/array/arrayIndexOf.js +11 -0
- package/grid/static/array/eachTree.js +32 -0
- package/grid/static/array/every.js +2 -0
- package/grid/static/array/filterTree.js +16 -0
- package/grid/static/array/find.js +3 -0
- package/grid/static/array/findTree.js +46 -0
- package/grid/static/array/helperCreateIterateHandle.js +59 -0
- package/grid/static/array/helperCreateTreeFunc.js +18 -0
- package/grid/static/array/includes.js +5 -0
- package/grid/static/array/lastArrayEach.js +6 -0
- package/grid/static/array/map.js +23 -0
- package/grid/static/array/mapTree.js +33 -0
- package/grid/static/array/slice.js +10 -0
- package/grid/static/array/sortBy.js +69 -0
- package/grid/static/array/sum.js +28 -0
- package/grid/static/array/toArray.js +7 -0
- package/grid/static/array/toTreeArray.js +24 -0
- package/grid/static/base/clear.js +44 -0
- package/grid/static/base/clone.js +18 -0
- package/grid/static/base/destructuring.js +18 -0
- package/grid/static/base/each.js +9 -0
- package/grid/static/base/eqNull.js +6 -0
- package/grid/static/base/findIndexOf.js +10 -0
- package/grid/static/base/get.js +42 -0
- package/grid/static/base/has.js +60 -0
- package/grid/static/base/hasOwnProp.js +4 -0
- package/grid/static/base/helperCreateGetObjects.js +26 -0
- package/grid/static/base/helperCreateInInObjectString.js +7 -0
- package/grid/static/base/helperCreateInTypeof.js +6 -0
- package/grid/static/base/helperCreateIndexOf.js +21 -0
- package/grid/static/base/helperCreateiterateIndexOf.js +21 -0
- package/grid/static/base/helperDefaultCompare.js +4 -0
- package/grid/static/base/helperDeleteProperty.js +8 -0
- package/grid/static/base/helperEqualCompare.js +60 -0
- package/grid/static/base/helperGetHGSKeys.js +4 -0
- package/grid/static/base/indexOf.js +3 -0
- package/grid/static/base/isArray.js +3 -0
- package/grid/static/base/isBoolean.js +4 -0
- package/grid/static/base/isDate.js +3 -0
- package/grid/static/base/isEmpty.js +8 -0
- package/grid/static/base/isEqual.js +11 -0
- package/grid/static/base/isFunction.js +4 -0
- package/grid/static/base/isNaN.js +5 -0
- package/grid/static/base/isNull.js +4 -0
- package/grid/static/base/isNumber.js +4 -0
- package/grid/static/base/isObject.js +5 -0
- package/grid/static/base/isPlainObject.js +2 -0
- package/grid/static/base/isRegExp.js +3 -0
- package/grid/static/base/isSet.js +5 -0
- package/grid/static/base/isString.js +4 -0
- package/grid/static/base/isUndefined.js +4 -0
- package/grid/static/base/keys.js +3 -0
- package/grid/static/base/lastEach.js +9 -0
- package/grid/static/base/remove.js +44 -0
- package/grid/static/base/set.js +43 -0
- package/grid/static/base/toJSONString.js +4 -0
- package/grid/static/base/toStringJSON.js +13 -0
- package/grid/static/base/uniqueId.js +5 -0
- package/grid/static/browse/browse.js +54 -0
- package/grid/static/function/property.js +7 -0
- package/grid/static/function/throttle.js +43 -0
- package/grid/static/index.js +55 -0
- package/grid/static/number/helperCreateToNumber.js +12 -0
- package/grid/static/number/toNumber.js +3 -0
- package/grid/static/object/assign.js +41 -0
- package/grid/static/object/extend.js +3 -0
- package/grid/static/object/lastObjectEach.js +8 -0
- package/grid/static/object/objectEach.js +11 -0
- package/grid/static/object/objectMap.js +20 -0
- package/grid/static/object/values.js +9 -0
- package/grid/static/static/staticDocument.js +4 -0
- package/grid/static/static/staticHGKeyRE.js +2 -0
- package/grid/static/static/staticParseInt.js +2 -0
- package/grid/static/static/staticStrUndefined.js +2 -0
- package/grid/static/static/staticWindow.js +4 -0
- package/grid/static/string/template.js +12 -0
- package/grid/static/string/toString.js +12 -0
- package/grid/utils/column.js +72 -0
- package/grid/utils/common.js +155 -0
- package/grid/utils/dom.js +213 -0
- package/grid/utils/event.js +40 -0
- package/grid/utils/index.js +5 -0
- package/image/index.js +187 -0
- package/image/vue.js +142 -0
- package/image-viewer/index.js +469 -0
- package/image-viewer/vue.js +243 -0
- package/input/index.js +319 -0
- package/input/vue.js +319 -0
- package/ip-address/index.js +370 -0
- package/ip-address/vue.js +185 -0
- package/layout/vue.js +4 -0
- package/link/index.js +10 -0
- package/link/vue.js +26 -0
- package/link-menu/index.js +146 -0
- package/link-menu/vue.js +138 -0
- package/list/index.js +13 -0
- package/list/vue.js +17 -0
- package/loading/index.js +29 -0
- package/loading/vue.js +28 -0
- package/milestone/index.js +92 -0
- package/milestone/vue.js +31 -0
- package/mini-picker/index.js +227 -0
- package/mini-picker/vue.js +142 -0
- package/modal/index.js +866 -0
- package/modal/vue.js +130 -0
- package/month-range/index.js +169 -0
- package/month-range/vue.js +104 -0
- package/month-table/index.js +232 -0
- package/month-table/vue.js +72 -0
- package/nav-menu/index.js +457 -0
- package/nav-menu/vue.js +187 -0
- package/notify/index.js +91 -0
- package/notify/vue.js +67 -0
- package/numeric/index.js +419 -0
- package/numeric/vue.js +218 -0
- package/option/index.js +79 -0
- package/option/vue.js +219 -0
- package/option-group/index.js +18 -0
- package/option-group/vue.js +37 -0
- package/package.json +179 -0
- package/pager-item/index.js +122 -0
- package/pager-item/vue.js +52 -0
- package/panel/index.js +30 -0
- package/panel/vue.js +26 -0
- package/picker/index.js +1039 -0
- package/picker/timezone.js +974 -0
- package/picker/vue.js +415 -0
- package/picker-column/index.js +261 -0
- package/picker-column/vue.js +163 -0
- package/pop-upload/index.js +324 -0
- package/pop-upload/vue.js +292 -0
- package/popeditor/index.js +884 -0
- package/popeditor/vue.js +368 -0
- package/popover/index.js +203 -0
- package/popover/vue.js +174 -0
- package/popup/index.js +139 -0
- package/popup/vue.js +129 -0
- package/progress/index.js +174 -0
- package/progress/vue.js +118 -0
- package/pull-refresh/index.js +104 -0
- package/pull-refresh/vue.js +64 -0
- package/radio/index.js +83 -0
- package/radio/vue.js +99 -0
- package/radio-button/index.js +58 -0
- package/radio-button/vue.js +70 -0
- package/radio-group/index.js +51 -0
- package/radio-group/vue.js +34 -0
- package/rate/index.js +254 -0
- package/rate/vue.js +158 -0
- package/row/index.js +19 -0
- package/row/vue.js +24 -0
- package/scroll-text/index.js +24 -0
- package/scroll-text/vue.js +31 -0
- package/scrollbar/index.js +127 -0
- package/scrollbar/vue-bar.js +49 -0
- package/scrollbar/vue.js +43 -0
- package/search/index.js +110 -0
- package/search/vue.js +110 -0
- package/select/index.js +1766 -0
- package/select/vue.js +693 -0
- package/select-dropdown/index.js +23 -0
- package/select-dropdown/vue.js +122 -0
- package/slide-bar/index.js +94 -0
- package/slide-bar/vue.js +58 -0
- package/slider/index.js +434 -0
- package/slider/vue.js +172 -0
- package/split/index.js +122 -0
- package/split/vue.js +131 -0
- package/steps/vue.js +4 -0
- package/switch/index.js +45 -0
- package/switch/vue.js +62 -0
- package/tab-bar/index.js +51 -0
- package/tab-bar/vue.js +16 -0
- package/tab-dropdown/index.js +11 -0
- package/tab-dropdown/vue.js +17 -0
- package/tab-item/index.js +37 -0
- package/tab-item/vue.js +49 -0
- package/tab-nav/index.js +247 -0
- package/tab-nav/vue.js +106 -0
- package/tabbar/index.js +32 -0
- package/tabbar/vue.js +54 -0
- package/tabbar-item/index.js +55 -0
- package/tabbar-item/vue.js +53 -0
- package/table/index.js +111 -0
- package/table/vue.js +66 -0
- package/tabs/index.js +174 -0
- package/tabs/vue.js +141 -0
- package/tag/index.js +14 -0
- package/tag/vue.js +13 -0
- package/tall-storage/index.js +161 -0
- package/tall-storage/vue-storage-box.js +25 -0
- package/tall-storage/vue.js +38 -0
- package/text-popup/index.js +75 -0
- package/text-popup/vue.js +64 -0
- package/time/index.js +121 -0
- package/time/vue.js +124 -0
- package/time-line/index.js +60 -0
- package/time-line/vue.js +49 -0
- package/time-panel/index.js +189 -0
- package/time-panel/scrollIntoView.js +23 -0
- package/time-panel/vue.js +110 -0
- package/time-range/index.js +199 -0
- package/time-range/vue.js +129 -0
- package/time-spinner/index.js +175 -0
- package/time-spinner/vue.js +122 -0
- package/toggle-menu/index.js +104 -0
- package/toggle-menu/vue.js +74 -0
- package/tooltip/index.js +171 -0
- package/tooltip/vue.js +133 -0
- package/top-box/index.js +81 -0
- package/top-box/vue.js +77 -0
- package/transfer/index.js +296 -0
- package/transfer/vue.js +138 -0
- package/transfer-panel/index.js +364 -0
- package/transfer-panel/vue.js +258 -0
- package/tree/index.js +642 -0
- package/tree/vue.js +268 -0
- package/tree-menu/index.js +124 -0
- package/tree-menu/vue.js +60 -0
- package/tree-node/index.js +271 -0
- package/tree-node/vue.js +211 -0
- package/upload/index.js +324 -0
- package/upload/vue.js +93 -0
- package/upload-dragger/index.js +50 -0
- package/upload-dragger/vue.js +27 -0
- package/upload-list/index.js +55 -0
- package/upload-list/vue.js +48 -0
- package/user-contact/index.js +13 -0
- package/user-contact/vue.js +20 -0
- package/user-head/index.js +71 -0
- package/user-head/vue.js +47 -0
- package/wizard/index.js +123 -0
- package/wizard/vue.js +45 -0
- package/year-table/index.js +40 -0
- package/year-table/vue.js +23 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import fecha from '@opentiny/vue-renderless/common/deps/date';
|
|
3
|
+
import { isNull } from '@opentiny/vue-renderless/common/type';
|
|
4
|
+
import { isLeapYear } from '@opentiny/vue-renderless/common/date';
|
|
5
|
+
import { DATEPICKER } from '@opentiny/vue-renderless/common';
|
|
6
|
+
var weeks = DATEPICKER.Weeks;
|
|
7
|
+
var months = DATEPICKER.MonhtList;
|
|
8
|
+
var defaultYMD = DATEPICKER.DateFormats.date;
|
|
9
|
+
var defaultHMS = DATEPICKER.DateFormats.time;
|
|
10
|
+
var newArray = function newArray(start, end) {
|
|
11
|
+
var res = [];
|
|
12
|
+
for (var i = start; i <= end; i++) {
|
|
13
|
+
res.push(i);
|
|
14
|
+
}
|
|
15
|
+
return res;
|
|
16
|
+
};
|
|
17
|
+
export var getI18nSettings = function getI18nSettings(t) {
|
|
18
|
+
return {
|
|
19
|
+
dayNamesShort: weeks.map(function (week) {
|
|
20
|
+
return t("ui.datepicker.weeks.".concat(week));
|
|
21
|
+
}),
|
|
22
|
+
dayNames: weeks.map(function (week) {
|
|
23
|
+
return t("ui.datepicker.weeks.".concat(week));
|
|
24
|
+
}),
|
|
25
|
+
monthNamesShort: months.map(function (month) {
|
|
26
|
+
return t("ui.datepicker.months.".concat(month));
|
|
27
|
+
}),
|
|
28
|
+
monthNames: months.map(function (month, index) {
|
|
29
|
+
return t("ui.datepicker.month".concat(index + 1));
|
|
30
|
+
}),
|
|
31
|
+
amPm: ['am', 'pm']
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export var isDate = function isDate(date) {
|
|
35
|
+
if (isNull(date)) return false;
|
|
36
|
+
if (isNaN(new Date(date).getTime())) return false;
|
|
37
|
+
if (Array.isArray(date)) return false;
|
|
38
|
+
return true;
|
|
39
|
+
};
|
|
40
|
+
export var toDate = function toDate(date) {
|
|
41
|
+
return isDate(date) ? new Date(date) : null;
|
|
42
|
+
};
|
|
43
|
+
export var isDateObject = function isDateObject(val) {
|
|
44
|
+
return val instanceof Date;
|
|
45
|
+
};
|
|
46
|
+
export var formatDate = function formatDate(date, format, t) {
|
|
47
|
+
date = toDate(date);
|
|
48
|
+
if (!date) return '';
|
|
49
|
+
return fecha.format(date, format || defaultYMD, getI18nSettings(t));
|
|
50
|
+
};
|
|
51
|
+
export var parseDate = function parseDate(string, format, t) {
|
|
52
|
+
return fecha.parse(string, format || defaultYMD, getI18nSettings(t));
|
|
53
|
+
};
|
|
54
|
+
export var getDayCountOfMonth = function getDayCountOfMonth(year, month) {
|
|
55
|
+
if (~[3, 5, 8, 10].indexOf(month)) {
|
|
56
|
+
return 30;
|
|
57
|
+
}
|
|
58
|
+
if (month === 1) {
|
|
59
|
+
return isLeapYear(year) ? 29 : 28;
|
|
60
|
+
}
|
|
61
|
+
return 31;
|
|
62
|
+
};
|
|
63
|
+
export var getDayCountOfYear = function getDayCountOfYear(year) {
|
|
64
|
+
return isLeapYear(year) ? 366 : 365;
|
|
65
|
+
};
|
|
66
|
+
export var getFirstDayOfMonth = function getFirstDayOfMonth(date) {
|
|
67
|
+
var temp = new Date(date.getTime());
|
|
68
|
+
temp.setDate(1);
|
|
69
|
+
return temp.getDay();
|
|
70
|
+
};
|
|
71
|
+
export var prevDate = function prevDate(date) {
|
|
72
|
+
var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
73
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate() - amount);
|
|
74
|
+
};
|
|
75
|
+
export var nextDate = function nextDate(date) {
|
|
76
|
+
var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
77
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate() + amount);
|
|
78
|
+
};
|
|
79
|
+
export var getStartDateOfMonth = function getStartDateOfMonth(year, month) {
|
|
80
|
+
var res = new Date(year, month, 1);
|
|
81
|
+
var day = res.getDay();
|
|
82
|
+
return day === 0 ? prevDate(res, 7) : prevDate(res, day);
|
|
83
|
+
};
|
|
84
|
+
export var getWeekNumber = function getWeekNumber(src) {
|
|
85
|
+
if (!isDate(src)) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
var date = new Date(src.getTime());
|
|
89
|
+
date.setHours(0, 0, 0, 0);
|
|
90
|
+
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
|
|
91
|
+
var week1 = new Date(date.getFullYear(), 0, 4);
|
|
92
|
+
return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000 - 3 + (week1.getDay() + 6) % 7) / 7);
|
|
93
|
+
};
|
|
94
|
+
export var getRangeHours = function getRangeHours() {
|
|
95
|
+
var ranges = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
96
|
+
var hours = [];
|
|
97
|
+
var disHours = [];
|
|
98
|
+
ranges.forEach(function (range) {
|
|
99
|
+
var value = range.map(function (date) {
|
|
100
|
+
return date.getHours();
|
|
101
|
+
});
|
|
102
|
+
disHours = disHours.concat(newArray(value[0], value[1]));
|
|
103
|
+
});
|
|
104
|
+
var isDisabled;
|
|
105
|
+
if (disHours.length) {
|
|
106
|
+
isDisabled = function isDisabled(i) {
|
|
107
|
+
return !~disHours.indexOf(i);
|
|
108
|
+
};
|
|
109
|
+
} else {
|
|
110
|
+
isDisabled = function isDisabled() {
|
|
111
|
+
return false;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
for (var i = 0; i < 24; i++) {
|
|
115
|
+
hours[i] = isDisabled(i);
|
|
116
|
+
}
|
|
117
|
+
return hours;
|
|
118
|
+
};
|
|
119
|
+
var setRangeData = function setRangeData(arr, start, end, value) {
|
|
120
|
+
for (var i = start; i < end; i++) {
|
|
121
|
+
arr[i] = value;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
export var range = function range(length) {
|
|
125
|
+
return Array.apply(null, {
|
|
126
|
+
length: length
|
|
127
|
+
}).map(function (_, n) {
|
|
128
|
+
return n;
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
export var getMonthDays = function getMonthDays(date) {
|
|
132
|
+
var temp = new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
|
133
|
+
var days = temp.getDate();
|
|
134
|
+
return range(days).map(function (_, index) {
|
|
135
|
+
return index + 1;
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
export var getPrevMonthLastDays = function getPrevMonthLastDays(date, amount) {
|
|
139
|
+
if (amount <= 0) return [];
|
|
140
|
+
var timeValue = new Date(date.getTime());
|
|
141
|
+
timeValue.setDate(0);
|
|
142
|
+
var lastDay = timeValue.getDate();
|
|
143
|
+
return range(amount).map(function (_, index) {
|
|
144
|
+
return lastDay - (amount - index - 1);
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
export var getRangeMinutes = function getRangeMinutes(ranges, hour) {
|
|
148
|
+
var sixty = 60;
|
|
149
|
+
var minutes = new Array(sixty);
|
|
150
|
+
if (ranges.length > 0) {
|
|
151
|
+
ranges.forEach(function (range) {
|
|
152
|
+
var _range = _slicedToArray(range, 2),
|
|
153
|
+
startDate = _range[0],
|
|
154
|
+
endDate = _range[1];
|
|
155
|
+
var startHour = startDate.getHours();
|
|
156
|
+
var startMinute = startDate.getMinutes();
|
|
157
|
+
var endHour = endDate.getHours();
|
|
158
|
+
var endMinute = endDate.getMinutes();
|
|
159
|
+
var equealStartHour = startHour === hour;
|
|
160
|
+
if (equealStartHour && endHour !== hour) {
|
|
161
|
+
setRangeData(minutes, startMinute, sixty, true);
|
|
162
|
+
} else if (equealStartHour && endHour === hour) {
|
|
163
|
+
setRangeData(minutes, startMinute, endMinute + 1, true);
|
|
164
|
+
} else if (!equealStartHour && endHour === hour) {
|
|
165
|
+
setRangeData(minutes, 0, endMinute + 1, true);
|
|
166
|
+
} else if (startHour < hour && endHour > hour) {
|
|
167
|
+
setRangeData(minutes, 0, sixty, true);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
} else {
|
|
171
|
+
setRangeData(minutes, 0, sixty, true);
|
|
172
|
+
}
|
|
173
|
+
return minutes;
|
|
174
|
+
};
|
|
175
|
+
export var modifyDate = function modifyDate(date, y, m, d) {
|
|
176
|
+
date = toDate(date);
|
|
177
|
+
return new Date(y, m, d, date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds());
|
|
178
|
+
};
|
|
179
|
+
export var modifyTime = function modifyTime(date, h, m, s) {
|
|
180
|
+
date = toDate(date);
|
|
181
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), h, m, s, date.getMilliseconds());
|
|
182
|
+
};
|
|
183
|
+
export var modifyWithTimeString = function modifyWithTimeString(date, time, t) {
|
|
184
|
+
if (isNull(date) || !time) {
|
|
185
|
+
return date;
|
|
186
|
+
}
|
|
187
|
+
time = parseDate(time, defaultHMS, t);
|
|
188
|
+
return modifyTime(date, time.getHours(), time.getMinutes(), time.getSeconds());
|
|
189
|
+
};
|
|
190
|
+
export var clearTime = function clearTime(date) {
|
|
191
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
192
|
+
};
|
|
193
|
+
export var clearMilliseconds = function clearMilliseconds(date) {
|
|
194
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), 0);
|
|
195
|
+
};
|
|
196
|
+
export var limitTimeRange = function limitTimeRange(date, ranges) {
|
|
197
|
+
var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultHMS;
|
|
198
|
+
if (ranges.length === 0) {
|
|
199
|
+
return date;
|
|
200
|
+
}
|
|
201
|
+
var normalizeDate = function normalizeDate(date) {
|
|
202
|
+
return fecha.parse(fecha.format(date, format), format);
|
|
203
|
+
};
|
|
204
|
+
var ndate = normalizeDate(date);
|
|
205
|
+
var nranges = ranges.map(function (range) {
|
|
206
|
+
return range.map(normalizeDate);
|
|
207
|
+
});
|
|
208
|
+
if (nranges.some(function (nrange) {
|
|
209
|
+
return ndate >= nrange[0] && ndate <= nrange[1];
|
|
210
|
+
})) {
|
|
211
|
+
return date;
|
|
212
|
+
}
|
|
213
|
+
var minDate = nranges[0][0];
|
|
214
|
+
var maxDate = minDate;
|
|
215
|
+
nranges.forEach(function (nrange) {
|
|
216
|
+
var minTempDate = minDate = new Date(Math.min(nrange[0], minDate));
|
|
217
|
+
maxDate = new Date(Math.max(nrange[1], minTempDate));
|
|
218
|
+
});
|
|
219
|
+
var ret = ndate < minDate ? minDate : maxDate;
|
|
220
|
+
return modifyDate(ret, date.getFullYear(), date.getMonth(), date.getDate());
|
|
221
|
+
};
|
|
222
|
+
export var timeWithinRange = function timeWithinRange(date, selectableRange, format) {
|
|
223
|
+
var limitedDate = limitTimeRange(date, selectableRange, format);
|
|
224
|
+
return limitedDate.getTime() === date.getTime();
|
|
225
|
+
};
|
|
226
|
+
export var changeYearMonthAndClampDate = function changeYearMonthAndClampDate(date, year, month) {
|
|
227
|
+
var monthDate = Math.min(date.getDate(), getDayCountOfMonth(year, month));
|
|
228
|
+
return modifyDate(date, year, month, monthDate);
|
|
229
|
+
};
|
|
230
|
+
export var nextMonth = function nextMonth(date) {
|
|
231
|
+
var year = date.getFullYear();
|
|
232
|
+
var month = date.getMonth();
|
|
233
|
+
var isLast = month === 11;
|
|
234
|
+
return isLast ? changeYearMonthAndClampDate(date, year + 1, 0) : changeYearMonthAndClampDate(date, year, month + 1);
|
|
235
|
+
};
|
|
236
|
+
export var prevMonth = function prevMonth(date) {
|
|
237
|
+
var year = date.getFullYear();
|
|
238
|
+
var month = date.getMonth();
|
|
239
|
+
var isFirst = month === 0;
|
|
240
|
+
return isFirst ? changeYearMonthAndClampDate(date, year - 1, 11) : changeYearMonthAndClampDate(date, year, month - 1);
|
|
241
|
+
};
|
|
242
|
+
export var nextYear = function nextYear(date) {
|
|
243
|
+
var next = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
244
|
+
var year = date.getFullYear();
|
|
245
|
+
var month = date.getMonth();
|
|
246
|
+
return changeYearMonthAndClampDate(date, year + next, month);
|
|
247
|
+
};
|
|
248
|
+
export var prevYear = function prevYear(date) {
|
|
249
|
+
var prev = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
250
|
+
var year = date.getFullYear();
|
|
251
|
+
var month = date.getMonth();
|
|
252
|
+
return changeYearMonthAndClampDate(date, year - prev, month);
|
|
253
|
+
};
|
|
254
|
+
export var extractTimeFormat = function extractTimeFormat(dateFormat) {
|
|
255
|
+
return dateFormat.replace(/\W?D{1,2}|\W?Do|\W?d{1,4}|\W?M{1,4}|\W?y{2,4}/g, '').trim();
|
|
256
|
+
};
|
|
257
|
+
export var extractDateFormat = function extractDateFormat(dateFormat) {
|
|
258
|
+
return dateFormat.replace(/\W?m{1,2}|\W?ZZ/g, '').replace(/\W?h{1,2}|\W?s{1,3}|\W?a/gi, '').trim();
|
|
259
|
+
};
|
|
260
|
+
export var validateRangeInOneMonth = function validateRangeInOneMonth(startDate, endDate) {
|
|
261
|
+
return startDate.getMonth() === endDate.getMonth() && startDate.getFullYear() === endDate.getFullYear();
|
|
262
|
+
};
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { DATEPICKER } from '@opentiny/vue-renderless/common';
|
|
2
|
+
import { isNull, isDate } from '@opentiny/vue-renderless/common/type';
|
|
3
|
+
var fecha = {};
|
|
4
|
+
var digitsReg = ['\\d\\d?', '\\d{3}', '\\d{4}'];
|
|
5
|
+
var twoDigits = digitsReg[0];
|
|
6
|
+
var threeDigits = digitsReg[1];
|
|
7
|
+
var fourDigits = digitsReg[2];
|
|
8
|
+
var word = '[^\\s]+';
|
|
9
|
+
var literal = /\[([^]*?)\]/gm;
|
|
10
|
+
var noop = function noop() {
|
|
11
|
+
return undefined;
|
|
12
|
+
};
|
|
13
|
+
var formats = {
|
|
14
|
+
shortDate: 'M/D/yy',
|
|
15
|
+
mediumDate: 'MMM d, yyyy',
|
|
16
|
+
longDate: 'MMMM d, yyyy',
|
|
17
|
+
fullDate: 'dddd, MMMM d, yyyy',
|
|
18
|
+
"default": 'ddd MMM dd yyyy HH:mm:ss',
|
|
19
|
+
shortTime: 'HH:mm',
|
|
20
|
+
mediumTime: 'HH:mm:ss',
|
|
21
|
+
longTime: 'HH:mm:ss.SSS'
|
|
22
|
+
};
|
|
23
|
+
var shorten = function shorten(arr, sLen) {
|
|
24
|
+
var newArr = [];
|
|
25
|
+
for (var i = 0, len = arr.length; i < len; i++) {
|
|
26
|
+
newArr.push(arr[i].substr(0, sLen));
|
|
27
|
+
}
|
|
28
|
+
return newArr;
|
|
29
|
+
};
|
|
30
|
+
var monthUpdate = function monthUpdate(arrName) {
|
|
31
|
+
return function (date, value, i18n) {
|
|
32
|
+
var index = i18n[arrName].indexOf(value.charAt(0).toUpperCase() + value.substr(1).toLowerCase());
|
|
33
|
+
if (~index) {
|
|
34
|
+
date.month = index;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
var pad = function pad(val, len) {
|
|
39
|
+
val = String(val);
|
|
40
|
+
len = len || 2;
|
|
41
|
+
while (val.length < len) {
|
|
42
|
+
val = '0' + val;
|
|
43
|
+
}
|
|
44
|
+
return val;
|
|
45
|
+
};
|
|
46
|
+
var regexEscape = function regexEscape(str) {
|
|
47
|
+
return str.replace(/[|\\{()[^$+*?.-]/g, '\\$&');
|
|
48
|
+
};
|
|
49
|
+
var fullTimeReg = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
|
|
50
|
+
var dayNames = DATEPICKER.fullWeeks;
|
|
51
|
+
var monthNames = DATEPICKER.fullMonths;
|
|
52
|
+
var monthNamesShort = shorten(monthNames, 3);
|
|
53
|
+
var dayNamesShort = shorten(dayNames, 3);
|
|
54
|
+
var parts = ['th', 'st', 'nd', 'rd'];
|
|
55
|
+
fecha.i18n = {
|
|
56
|
+
dayNames: dayNames,
|
|
57
|
+
monthNames: monthNames,
|
|
58
|
+
dayNamesShort: dayNamesShort,
|
|
59
|
+
monthNamesShort: monthNamesShort,
|
|
60
|
+
amPm: ['am', 'pm'],
|
|
61
|
+
doFn: function doFn(D) {
|
|
62
|
+
return D + parts[D % 10 > 3 ? 0 : (D - D % 10 !== 10) * D % 10];
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var formatFlags = {
|
|
66
|
+
D: function D(dateObj) {
|
|
67
|
+
return dateObj.getDay();
|
|
68
|
+
},
|
|
69
|
+
DD: function DD(dateObj) {
|
|
70
|
+
return pad(dateObj.getDay());
|
|
71
|
+
},
|
|
72
|
+
Do: function Do(dateObj, i18n) {
|
|
73
|
+
return i18n.doFn(dateObj.getDate());
|
|
74
|
+
},
|
|
75
|
+
d: function d(dateObj) {
|
|
76
|
+
return dateObj.getDate();
|
|
77
|
+
},
|
|
78
|
+
dd: function dd(dateObj) {
|
|
79
|
+
return pad(dateObj.getDate());
|
|
80
|
+
},
|
|
81
|
+
ddd: function ddd(dateObj, i18n) {
|
|
82
|
+
return i18n.dayNamesShort[dateObj.getDay()];
|
|
83
|
+
},
|
|
84
|
+
dddd: function dddd(dateObj, i18n) {
|
|
85
|
+
return i18n.dayNames[dateObj.getDay()];
|
|
86
|
+
},
|
|
87
|
+
M: function M(dateObj) {
|
|
88
|
+
return dateObj.getMonth() + 1;
|
|
89
|
+
},
|
|
90
|
+
MM: function MM(dateObj) {
|
|
91
|
+
return pad(dateObj.getMonth() + 1);
|
|
92
|
+
},
|
|
93
|
+
MMM: function MMM(dateObj, i18n) {
|
|
94
|
+
return i18n.monthNamesShort[dateObj.getMonth()];
|
|
95
|
+
},
|
|
96
|
+
MMMM: function MMMM(dateObj, i18n) {
|
|
97
|
+
return i18n.monthNames[dateObj.getMonth()];
|
|
98
|
+
},
|
|
99
|
+
yy: function yy(dateObj) {
|
|
100
|
+
return pad(String(dateObj.getFullYear()), 4).substr(2);
|
|
101
|
+
},
|
|
102
|
+
yyyy: function yyyy(dateObj) {
|
|
103
|
+
return pad(dateObj.getFullYear(), 4);
|
|
104
|
+
},
|
|
105
|
+
h: function h(dateObj) {
|
|
106
|
+
return dateObj.getHours() % 12 || 12;
|
|
107
|
+
},
|
|
108
|
+
hh: function hh(dateObj) {
|
|
109
|
+
return pad(dateObj.getHours() % 12 || 12);
|
|
110
|
+
},
|
|
111
|
+
H: function H(dateObj) {
|
|
112
|
+
return dateObj.getHours();
|
|
113
|
+
},
|
|
114
|
+
HH: function HH(dateObj) {
|
|
115
|
+
return pad(dateObj.getHours());
|
|
116
|
+
},
|
|
117
|
+
m: function m(dateObj) {
|
|
118
|
+
return dateObj.getMinutes();
|
|
119
|
+
},
|
|
120
|
+
mm: function mm(dateObj) {
|
|
121
|
+
return pad(dateObj.getMinutes());
|
|
122
|
+
},
|
|
123
|
+
s: function s(dateObj) {
|
|
124
|
+
return dateObj.getSeconds();
|
|
125
|
+
},
|
|
126
|
+
ss: function ss(dateObj) {
|
|
127
|
+
return pad(dateObj.getSeconds());
|
|
128
|
+
},
|
|
129
|
+
S: function S(dateObj) {
|
|
130
|
+
return Math.round(dateObj.getMilliseconds() / 100);
|
|
131
|
+
},
|
|
132
|
+
SS: function SS(dateObj) {
|
|
133
|
+
return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
|
|
134
|
+
},
|
|
135
|
+
SSS: function SSS(dateObj) {
|
|
136
|
+
return pad(dateObj.getMilliseconds(), 3);
|
|
137
|
+
},
|
|
138
|
+
a: function a(dateObj, i18n) {
|
|
139
|
+
return dateObj.getHours() < 12 ? i18n.amPm[0] : i18n.amPm[1];
|
|
140
|
+
},
|
|
141
|
+
A: function A(dateObj, i18n) {
|
|
142
|
+
return dateObj.getHours() < 12 ? i18n.amPm[0].toUpperCase() : i18n.amPm[1].toUpperCase();
|
|
143
|
+
},
|
|
144
|
+
ZZ: function ZZ(dateObj) {
|
|
145
|
+
var offset = dateObj.getTimezoneOffset();
|
|
146
|
+
return (offset > 0 ? '-' : '+') + pad(Math.floor(Math.abs(offset) / 60) * 100 + Math.abs(offset) % 60, 4);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
var parseFlags = {
|
|
150
|
+
d: [twoDigits, function (date, value) {
|
|
151
|
+
date.day = value;
|
|
152
|
+
}],
|
|
153
|
+
Do: [twoDigits + word, function (date, value) {
|
|
154
|
+
date.day = parseInt(value, 10);
|
|
155
|
+
}],
|
|
156
|
+
M: [twoDigits, function (date, value) {
|
|
157
|
+
date.month = value - 1;
|
|
158
|
+
}],
|
|
159
|
+
yy: [twoDigits, function (date, value) {
|
|
160
|
+
var now = new Date();
|
|
161
|
+
var cent = +('' + now.getFullYear()).substr(0, 2);
|
|
162
|
+
date.year = '' + (value > 68 ? cent - 1 : cent) + value;
|
|
163
|
+
}],
|
|
164
|
+
h: [twoDigits, function (date, value) {
|
|
165
|
+
date.hour = value;
|
|
166
|
+
}],
|
|
167
|
+
m: [twoDigits, function (date, value) {
|
|
168
|
+
date.minute = value;
|
|
169
|
+
}],
|
|
170
|
+
s: [twoDigits, function (date, value) {
|
|
171
|
+
date.second = value;
|
|
172
|
+
}],
|
|
173
|
+
yyyy: [fourDigits, function (date, value) {
|
|
174
|
+
date.year = value;
|
|
175
|
+
}],
|
|
176
|
+
S: ['\\d', function (date, value) {
|
|
177
|
+
date.millisecond = value * 100;
|
|
178
|
+
}],
|
|
179
|
+
SS: ['\\d{2}', function (date, value) {
|
|
180
|
+
date.millisecond = value * 10;
|
|
181
|
+
}],
|
|
182
|
+
SSS: [threeDigits, function (date, value) {
|
|
183
|
+
date.millisecond = value;
|
|
184
|
+
}],
|
|
185
|
+
D: [twoDigits, noop],
|
|
186
|
+
ddd: [word, noop],
|
|
187
|
+
MMM: [word, monthUpdate('monthNamesShort')],
|
|
188
|
+
MMMM: [word, monthUpdate('monthNames')],
|
|
189
|
+
a: [word, function (date, value, i18n) {
|
|
190
|
+
var val = value.toLowerCase();
|
|
191
|
+
if (val === i18n.amPm[0]) {
|
|
192
|
+
date.isPm = false;
|
|
193
|
+
} else if (val === i18n.amPm[1]) {
|
|
194
|
+
date.isPm = true;
|
|
195
|
+
}
|
|
196
|
+
}],
|
|
197
|
+
ZZ: ['[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z', function (date, value) {
|
|
198
|
+
var parts = (value + '').match(/([+-]|\d\d)/gi);
|
|
199
|
+
var minutes;
|
|
200
|
+
if (parts) {
|
|
201
|
+
minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
|
|
202
|
+
date.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
|
|
203
|
+
}
|
|
204
|
+
}]
|
|
205
|
+
};
|
|
206
|
+
var fmts = ['A', 'DD', 'dd', 'mm', 'hh', 'MM', 'ss', 'hh', 'H', 'HH'];
|
|
207
|
+
fecha.masks = formats;
|
|
208
|
+
parseFlags.dddd = parseFlags.ddd;
|
|
209
|
+
fmts.forEach(function (name) {
|
|
210
|
+
if (name === 'MM') {
|
|
211
|
+
parseFlags[name] = parseFlags[name.substr(0, 1)];
|
|
212
|
+
} else {
|
|
213
|
+
parseFlags[name] = parseFlags[name.substr(0, 1).toLowerCase()];
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
fecha.format = function (dateObj, mask, i18nSettings) {
|
|
217
|
+
var i18n = i18nSettings || fecha.i18n;
|
|
218
|
+
if (typeof dateObj === 'number') {
|
|
219
|
+
dateObj = new Date(dateObj);
|
|
220
|
+
}
|
|
221
|
+
if (!isDate(dateObj) || isNaN(dateObj.getTime())) {
|
|
222
|
+
throw new Error('Invalid Date in fecha.format');
|
|
223
|
+
}
|
|
224
|
+
mask = fecha.masks[mask] || mask || fecha.masks['default'];
|
|
225
|
+
var literals = [];
|
|
226
|
+
mask = mask.replace(literal, function ($0, $1) {
|
|
227
|
+
literals.push($1);
|
|
228
|
+
return '@@@';
|
|
229
|
+
});
|
|
230
|
+
mask = mask.replace(fullTimeReg, function ($0) {
|
|
231
|
+
return $0 in formatFlags ? formatFlags[$0](dateObj, i18n) : $0.slice(1, $0.length - 1);
|
|
232
|
+
});
|
|
233
|
+
return mask.replace(/@@@/g, function () {
|
|
234
|
+
return literals.shift();
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
var getNewFormat = function getNewFormat(format, parseInfo) {
|
|
238
|
+
var literals = [];
|
|
239
|
+
var newFormat = regexEscape(format).replace(fullTimeReg, function ($0) {
|
|
240
|
+
if (parseFlags[$0]) {
|
|
241
|
+
var info = parseFlags[$0];
|
|
242
|
+
parseInfo.push(info[1]);
|
|
243
|
+
return '(' + info[0] + ')';
|
|
244
|
+
}
|
|
245
|
+
return $0;
|
|
246
|
+
});
|
|
247
|
+
newFormat = newFormat.replace(/@@@/g, function () {
|
|
248
|
+
return literals.shift();
|
|
249
|
+
});
|
|
250
|
+
return newFormat;
|
|
251
|
+
};
|
|
252
|
+
var getDate = function getDate(dateInfo) {
|
|
253
|
+
var date;
|
|
254
|
+
var today = new Date();
|
|
255
|
+
if (!isNull(dateInfo.timezoneOffset)) {
|
|
256
|
+
dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
|
|
257
|
+
var year = dateInfo.year,
|
|
258
|
+
month = dateInfo.month,
|
|
259
|
+
day = dateInfo.day,
|
|
260
|
+
hour = dateInfo.hour,
|
|
261
|
+
minute = dateInfo.minute,
|
|
262
|
+
second = dateInfo.second,
|
|
263
|
+
millisecond = dateInfo.millisecond;
|
|
264
|
+
date = new Date(Date.UTC(year || today.getFullYear(), month || 0, day || 1, hour || 0, minute || 0, second || 0, millisecond || 0));
|
|
265
|
+
} else {
|
|
266
|
+
var _year = dateInfo.year,
|
|
267
|
+
_month = dateInfo.month,
|
|
268
|
+
_day = dateInfo.day,
|
|
269
|
+
_hour = dateInfo.hour,
|
|
270
|
+
_minute = dateInfo.minute,
|
|
271
|
+
_second = dateInfo.second,
|
|
272
|
+
_millisecond = dateInfo.millisecond;
|
|
273
|
+
date = new Date(_year || today.getFullYear(), _month || 0, _day || 1, _hour || 0, _minute || 0, _second || 0, _millisecond || 0);
|
|
274
|
+
}
|
|
275
|
+
return date;
|
|
276
|
+
};
|
|
277
|
+
fecha.parse = function (dateStr, format, i18nSettings) {
|
|
278
|
+
var i18n = i18nSettings || fecha.i18n;
|
|
279
|
+
if (typeof format !== 'string') {
|
|
280
|
+
throw new Error('Invalid format in fecha.parse');
|
|
281
|
+
}
|
|
282
|
+
format = fecha.masks[format] || format;
|
|
283
|
+
if (dateStr.length > 1000) {
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
var dateInfo = {};
|
|
287
|
+
var parseInfo = [];
|
|
288
|
+
var literals = [];
|
|
289
|
+
format = format.replace(literal, function ($0, $1) {
|
|
290
|
+
literals.push($1);
|
|
291
|
+
return '@@@';
|
|
292
|
+
});
|
|
293
|
+
var newFormat = getNewFormat(format, parseInfo);
|
|
294
|
+
var matches = dateStr.match(new RegExp(newFormat, 'i'));
|
|
295
|
+
if (!matches) {
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
for (var i = 1, len = matches.length; i < len; i++) {
|
|
299
|
+
parseInfo[i - 1](dateInfo, matches[i], i18n);
|
|
300
|
+
}
|
|
301
|
+
if (dateInfo.isPm === true && !isNull(dateInfo.hour) && Number(dateInfo.hour) !== 12) {
|
|
302
|
+
dateInfo.hour = Number(dateInfo.hour) + 12;
|
|
303
|
+
} else if (dateInfo.isPm === false && Number(dateInfo.hour) === 12) {
|
|
304
|
+
dateInfo.hour = 0;
|
|
305
|
+
}
|
|
306
|
+
return getDate(dateInfo);
|
|
307
|
+
};
|
|
308
|
+
export default fecha;
|