cnhis-design-vue 3.1.11-beta.8 → 3.1.12-beta.1
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/README.md +22 -22
- package/es/node_modules/date-fns/esm/_lib/defaultOptions/index.js +6 -0
- package/es/node_modules/date-fns/esm/_lib/getUTCISOWeek/index.js +17 -0
- package/es/node_modules/date-fns/esm/_lib/getUTCISOWeekYear/index.js +27 -0
- package/es/node_modules/date-fns/esm/_lib/getUTCWeek/index.js +17 -0
- package/es/node_modules/date-fns/esm/_lib/getUTCWeekYear/index.js +38 -0
- package/es/node_modules/date-fns/esm/_lib/setUTCDay/index.js +27 -0
- package/es/node_modules/date-fns/esm/_lib/setUTCISODay/index.js +23 -0
- package/es/node_modules/date-fns/esm/_lib/setUTCISOWeek/index.js +15 -0
- package/es/node_modules/date-fns/esm/_lib/setUTCWeek/index.js +15 -0
- package/es/node_modules/date-fns/esm/_lib/startOfUTCISOWeek/index.js +15 -0
- package/es/node_modules/date-fns/esm/_lib/startOfUTCISOWeekYear/index.js +15 -0
- package/es/node_modules/date-fns/esm/_lib/startOfUTCWeek/index.js +25 -0
- package/es/node_modules/date-fns/esm/_lib/startOfUTCWeekYear/index.js +21 -0
- package/es/node_modules/date-fns/esm/_lib/toInteger/index.js +15 -0
- package/es/node_modules/date-fns/esm/compareAsc/index.js +0 -4
- package/es/node_modules/date-fns/esm/constants/index.js +40 -0
- package/es/node_modules/date-fns/esm/differenceInCalendarDays/index.js +0 -4
- package/es/node_modules/date-fns/esm/differenceInCalendarMonths/index.js +1 -5
- package/es/node_modules/date-fns/esm/differenceInDays/index.js +0 -4
- package/es/node_modules/date-fns/esm/differenceInMonths/index.js +0 -4
- package/es/node_modules/date-fns/esm/endOfDay/index.js +0 -4
- package/es/node_modules/date-fns/esm/endOfMonth/index.js +0 -4
- package/es/node_modules/date-fns/esm/isLastDayOfMonth/index.js +1 -5
- package/es/node_modules/date-fns/esm/parse/_lib/Parser.js +32 -0
- package/es/node_modules/date-fns/esm/parse/_lib/Setter.js +37 -0
- package/es/node_modules/date-fns/esm/parse/_lib/constants.js +48 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/AMPMMidnightParser.js +55 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/AMPMParser.js +55 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/DateParser.js +55 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/DayOfYearParser.js +52 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/DayParser.js +80 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/DayPeriodParser.js +56 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/EraParser.js +53 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/ExtendedYearParser.js +30 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/FractionOfSecondParser.js +29 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/Hour0To11Parser.js +48 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/Hour0to23Parser.js +41 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/Hour1To24Parser.js +42 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/Hour1to12Parser.js +50 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/ISODayParser.js +99 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/ISOTimezoneParser.js +46 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/ISOTimezoneWithZParser.js +46 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/ISOWeekParser.js +43 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/ISOWeekYearParser.js +33 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/LocalDayParser.js +96 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/LocalWeekParser.js +43 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/LocalWeekYearParser.js +61 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/MinuteParser.js +41 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/MonthParser.js +80 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/QuarterParser.js +73 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/SecondParser.js +41 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneLocalDayParser.js +96 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneMonthParser.js +80 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneQuarterParser.js +73 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/TimestampMillisecondsParser.js +26 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/TimestampSecondsParser.js +26 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/YearParser.js +66 -0
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/index.js +109 -0
- package/es/node_modules/date-fns/esm/parse/_lib/utils.js +133 -0
- package/es/node_modules/date-fns/esm/startOfDay/index.js +0 -4
- package/es/node_modules/date-fns/esm/toDate/index.js +1 -1
- package/es/packages/big-table/index.d.ts +31 -10
- package/es/packages/big-table/src/BigTable.vue.d.ts +38 -32
- package/es/packages/big-table/src/BigTable.vue_vue_type_script_setup_true_lang.js +28 -7
- package/es/packages/big-table/src/bigTableState.d.ts +2 -6
- package/es/packages/big-table/src/bigTableState.js +9 -1
- package/es/packages/big-table/src/components/edit-form/edit-separate.js +4 -0
- package/es/packages/big-table/src/components/edit-form/edit-separate.vue.d.ts +1247 -0
- package/es/packages/big-table/src/components/edit-form/edit-separate.vue_vue_type_script_setup_true_lang.js +69 -0
- package/es/packages/big-table/src/components/separate.js +4 -0
- package/es/packages/big-table/src/components/separate.vue.d.ts +43 -0
- package/es/packages/big-table/src/components/separate.vue_vue_type_script_setup_true_lang.js +24 -0
- package/es/packages/big-table/src/constants/index.d.ts +3 -0
- package/es/packages/big-table/src/constants/index.js +3 -0
- package/es/packages/big-table/src/hooks/useEdit.d.ts +1243 -0
- package/es/packages/big-table/src/hooks/useEdit.js +25 -7
- package/es/packages/big-table/src/hooks/useSeparateRow.d.ts +30 -0
- package/es/packages/big-table/src/hooks/useSeparateRow.js +157 -0
- package/es/packages/big-table/src/utils.d.ts +1 -0
- package/es/packages/big-table/src/utils.js +5 -7
- package/es/packages/big-table/style/index.css +1 -1
- package/es/packages/bpmn-workflow/index.d.ts +1 -1
- package/es/packages/bpmn-workflow/src/custom/customModeler/customBpmn/BpmnRenderer.d.ts +52 -52
- package/es/packages/bpmn-workflow/src/custom/customModeler/customBpmn/BpmnRenderer.js +1 -8
- package/es/packages/bpmn-workflow/src/custom/customModeler/customBpmn/CustomPalette.js +1 -11
- package/es/packages/bpmn-workflow/src/custom/customModeler/customBpmn/CustomRenderer.js +1 -9
- package/es/packages/bpmn-workflow/src/custom/customModeler/customBpmn/index.js +1 -8
- package/es/packages/bpmn-workflow/src/custom/customTranslate/zh.d.ts +176 -176
- package/es/packages/bpmn-workflow/style/index.css +1 -1
- package/es/packages/button-print/src/utils/print.es.min.js +1467 -1015
- package/es/packages/chunk-upload/src/chunk-upload-new.vue.d.ts +2 -9
- package/es/packages/chunk-upload/src/chunk-upload-new.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/packages/chunk-upload/src/vod-chunk-upload/vod-chunk-upload.vue.d.ts +2 -9
- package/es/packages/chunk-upload/src/vod-chunk-upload/vod-chunk-upload.vue_vue_type_script_setup_true_lang.js +1 -10
- package/es/packages/drag-layout/src/DragFormRightItem.vue_vue_type_script_setup_true_lang.js +6 -6
- package/es/packages/drag-layout/src/DragLayout.vue.d.ts +0 -1
- package/es/packages/drag-layout/src/DragLayout.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/packages/drag-layout/style/index.css +4 -4
- package/es/packages/editor/src/Editor.js +1 -1
- package/es/packages/field-set/index.d.ts +2 -2
- package/es/packages/field-set/src/FieldSet.vue.d.ts +2 -2
- package/es/packages/field-set/src/NewFieldSet.vue.d.ts +1 -1
- package/es/packages/field-set/src/OldFieldSet.vue.d.ts +1 -1
- package/es/packages/form-render/index.d.ts +13 -5
- package/es/packages/form-render/index.js +1 -1
- package/es/packages/form-render/src/FormRender.vue.d.ts +13 -5
- package/es/packages/form-render/src/FormRender.vue_vue_type_script_setup_true_lang.js +20 -29
- package/es/packages/form-render/src/components/renderer/cascader.js +2 -0
- package/es/packages/form-render/src/components/renderer/checkbox.d.ts +1 -1
- package/es/packages/form-render/src/components/renderer/combination.d.ts +8 -118
- package/es/packages/form-render/src/components/renderer/combination.js +6 -12
- package/es/packages/form-render/src/components/renderer/linebar.js +2 -2
- package/es/packages/form-render/src/components/renderer/radio.d.ts +1 -1
- package/es/packages/form-render/src/components/renderer/select.js +3 -3
- package/es/packages/form-render/src/constants/index.d.ts +1 -0
- package/es/packages/form-render/src/constants/index.js +3 -2
- package/es/packages/form-render/src/hooks/index.d.ts +1 -1
- package/es/packages/form-render/src/hooks/index.js +1 -1
- package/es/packages/form-render/src/hooks/useAnchor.d.ts +1 -2
- package/es/packages/form-render/src/hooks/useAnchor.js +14 -10
- package/es/packages/form-render/src/hooks/useAsyncQueue.js +2 -2
- package/es/packages/form-render/src/hooks/useBusinessBinding.js +3 -1
- package/es/packages/form-render/src/hooks/useChangeContext.js +3 -1
- package/es/packages/form-render/src/hooks/useCommonLog.js +1 -1
- package/es/packages/form-render/src/hooks/{useFieldList2Schema.d.ts → useFieldListAdaptor.d.ts} +2 -2
- package/es/packages/form-render/src/hooks/{useFieldList2Schema.js → useFieldListAdaptor.js} +12 -8
- package/es/packages/form-render/src/hooks/useFieldVisitor.d.ts +1 -1
- package/es/packages/form-render/src/hooks/useFormContext.d.ts +1 -0
- package/es/packages/form-render/src/hooks/useFormContext.js +12 -3
- package/es/packages/form-render/src/hooks/useFormItemDeps.d.ts +2 -1
- package/es/packages/form-render/src/hooks/useFormRequest.d.ts +2 -1
- package/es/packages/form-render/src/types/index.d.ts +1 -1
- package/es/packages/form-render/src/utils/index.d.ts +1 -0
- package/es/packages/form-render/src/utils/index.js +8 -1
- package/es/packages/form-table/index.d.ts +27 -27
- package/es/packages/form-table/src/FormTable.vue.d.ts +27 -27
- package/es/packages/form-table/src/components/index.d.ts +26 -26
- package/es/packages/form-table/src/components/table-age.vue.d.ts +2 -2
- package/es/packages/form-table/src/components/table-date-picker.vue.d.ts +2 -2
- package/es/packages/form-table/src/components/table-digital.vue.d.ts +2 -2
- package/es/packages/form-table/src/components/table-input-password.vue.d.ts +2 -2
- package/es/packages/form-table/src/components/table-input.vue.d.ts +2 -2
- package/es/packages/form-table/src/components/table-month-picker.vue.d.ts +2 -2
- package/es/packages/form-table/src/components/table-search-more.vue.d.ts +2 -2
- package/es/packages/form-table/src/components/table-search.vue.d.ts +2 -2
- package/es/packages/form-table/src/components/table-search.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/packages/form-table/src/components/table-select-multiple.vue.d.ts +2 -2
- package/es/packages/form-table/src/components/table-select.vue.d.ts +2 -2
- package/es/packages/form-table/src/components/table-textarea.vue.d.ts +2 -2
- package/es/packages/form-table/src/components/table-time-picker.vue.d.ts +2 -2
- package/es/packages/form-table/src/components/table-tree-select.vue.d.ts +2 -2
- package/es/packages/form-table/src/components/table-tree-select.vue_vue_type_script_setup_true_lang.js +9 -7
- package/es/packages/form-table/src/configs/index.js +1 -8
- package/es/packages/form-table/src/hooks/useBoundDate.js +4 -1
- package/es/packages/form-table/src/hooks/useFormCommon.js +6 -1
- package/es/packages/form-table/src/hooks/useFormEvent.d.ts +1 -1
- package/es/packages/form-table/src/hooks/useFormEvent.js +1 -5
- package/es/packages/form-table/src/hooks/useSearch.js +29 -92
- package/es/packages/index.css +16 -16
- package/es/packages/index.js +1 -1
- package/es/packages/info-header/src/InfoHeader.vue_vue_type_script_setup_true_lang.js +4 -1
- package/es/packages/info-header/style/index.css +8 -8
- package/es/packages/scale-view/index.d.ts +1 -1
- package/es/packages/scale-view/src/ScaleView.vue.d.ts +1 -1
- package/es/packages/scale-view/src/ScaleView.vue_vue_type_script_setup_true_lang.js +11 -9
- package/es/packages/scale-view/src/components/EvaluateCountdown.vue_vue_type_script_setup_true_lang.js +1 -8
- package/es/packages/scale-view/src/components/EvaluatePage.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/packages/scale-view/src/components/formitem/address.d.ts +3988 -3988
- package/es/packages/scale-view/src/components/formitem/r-upload.js +1 -1
- package/es/packages/scale-view/src/components/formitem/text-over-tooltip/TextOverTooltip.vue.d.ts +1 -1
- package/es/packages/scale-view/src/hooks/scaleview-computed.js +7 -12
- package/es/packages/scale-view/src/hooks/scaleview-init.js +1 -6
- package/es/packages/scale-view/src/hooks/scaleview-state.js +1 -8
- package/es/packages/scale-view/src/hooks/scaleview-submit.js +2 -5
- package/es/packages/scale-view/src/hooks/scaleview-validate.js +6 -1
- package/es/packages/scale-view/src/hooks/use-component.js +50 -50
- package/es/packages/scale-view/src/utils/judge-types.js +1 -6
- package/es/packages/select-label/src/LabelFormContent.vue.d.ts +3 -0
- package/es/packages/select-label/src/SelectLabel.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/packages/time-line/style/index.css +2 -2
- package/es/src/components/player-vod/video-modal.js +1 -1
- package/es/src/core/create.js +1 -1
- package/es/src/utils/anime.js +1 -1
- package/global.d.ts +8 -8
- package/package.json +153 -131
- package/.versionrc.json +0 -32
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Parser } from '../Parser.js';
|
|
2
|
+
import { numericPatterns } from '../constants.js';
|
|
3
|
+
import { parseNDigits, parseNumericPattern } from '../utils.js';
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
class SecondParser extends Parser {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
|
|
10
|
+
_defineProperty(this, "priority", 50);
|
|
11
|
+
|
|
12
|
+
_defineProperty(this, "incompatibleTokens", ['t', 'T']);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
parse(dateString, token, match) {
|
|
16
|
+
switch (token) {
|
|
17
|
+
case 's':
|
|
18
|
+
return parseNumericPattern(numericPatterns.second, dateString);
|
|
19
|
+
|
|
20
|
+
case 'so':
|
|
21
|
+
return match.ordinalNumber(dateString, {
|
|
22
|
+
unit: 'second'
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
default:
|
|
26
|
+
return parseNDigits(token.length, dateString);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
validate(_date, value) {
|
|
31
|
+
return value >= 0 && value <= 59;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
set(date, _flags, value) {
|
|
35
|
+
date.setUTCSeconds(value, 0);
|
|
36
|
+
return date;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { SecondParser };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Parser } from '../Parser.js';
|
|
2
|
+
import { mapValue, parseNDigits } from '../utils.js';
|
|
3
|
+
import setUTCDay from '../../../_lib/setUTCDay/index.js';
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
|
|
7
|
+
class StandAloneLocalDayParser extends Parser {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
|
|
11
|
+
_defineProperty(this, "priority", 90);
|
|
12
|
+
|
|
13
|
+
_defineProperty(this, "incompatibleTokens", ['y', 'R', 'u', 'q', 'Q', 'M', 'L', 'I', 'd', 'D', 'E', 'i', 'e', 't', 'T']);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
parse(dateString, token, match, options) {
|
|
17
|
+
var valueCallback = function (value) {
|
|
18
|
+
var wholeWeekDays = Math.floor((value - 1) / 7) * 7;
|
|
19
|
+
return (value + options.weekStartsOn + 6) % 7 + wholeWeekDays;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
switch (token) {
|
|
23
|
+
// 3
|
|
24
|
+
case 'c':
|
|
25
|
+
case 'cc':
|
|
26
|
+
// 03
|
|
27
|
+
return mapValue(parseNDigits(token.length, dateString), valueCallback);
|
|
28
|
+
// 3rd
|
|
29
|
+
|
|
30
|
+
case 'co':
|
|
31
|
+
return mapValue(match.ordinalNumber(dateString, {
|
|
32
|
+
unit: 'day'
|
|
33
|
+
}), valueCallback);
|
|
34
|
+
// Tue
|
|
35
|
+
|
|
36
|
+
case 'ccc':
|
|
37
|
+
return match.day(dateString, {
|
|
38
|
+
width: 'abbreviated',
|
|
39
|
+
context: 'standalone'
|
|
40
|
+
}) || match.day(dateString, {
|
|
41
|
+
width: 'short',
|
|
42
|
+
context: 'standalone'
|
|
43
|
+
}) || match.day(dateString, {
|
|
44
|
+
width: 'narrow',
|
|
45
|
+
context: 'standalone'
|
|
46
|
+
});
|
|
47
|
+
// T
|
|
48
|
+
|
|
49
|
+
case 'ccccc':
|
|
50
|
+
return match.day(dateString, {
|
|
51
|
+
width: 'narrow',
|
|
52
|
+
context: 'standalone'
|
|
53
|
+
});
|
|
54
|
+
// Tu
|
|
55
|
+
|
|
56
|
+
case 'cccccc':
|
|
57
|
+
return match.day(dateString, {
|
|
58
|
+
width: 'short',
|
|
59
|
+
context: 'standalone'
|
|
60
|
+
}) || match.day(dateString, {
|
|
61
|
+
width: 'narrow',
|
|
62
|
+
context: 'standalone'
|
|
63
|
+
});
|
|
64
|
+
// Tuesday
|
|
65
|
+
|
|
66
|
+
case 'cccc':
|
|
67
|
+
default:
|
|
68
|
+
return match.day(dateString, {
|
|
69
|
+
width: 'wide',
|
|
70
|
+
context: 'standalone'
|
|
71
|
+
}) || match.day(dateString, {
|
|
72
|
+
width: 'abbreviated',
|
|
73
|
+
context: 'standalone'
|
|
74
|
+
}) || match.day(dateString, {
|
|
75
|
+
width: 'short',
|
|
76
|
+
context: 'standalone'
|
|
77
|
+
}) || match.day(dateString, {
|
|
78
|
+
width: 'narrow',
|
|
79
|
+
context: 'standalone'
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
validate(_date, value) {
|
|
85
|
+
return value >= 0 && value <= 6;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
set(date, _flags, value, options) {
|
|
89
|
+
date = setUTCDay(date, value, options);
|
|
90
|
+
date.setUTCHours(0, 0, 0, 0);
|
|
91
|
+
return date;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { StandAloneLocalDayParser };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Parser } from '../Parser.js';
|
|
2
|
+
import { numericPatterns } from '../constants.js';
|
|
3
|
+
import { mapValue, parseNDigits, parseNumericPattern } from '../utils.js';
|
|
4
|
+
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
class StandAloneMonthParser extends Parser {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
|
|
10
|
+
_defineProperty(this, "priority", 110);
|
|
11
|
+
|
|
12
|
+
_defineProperty(this, "incompatibleTokens", ['Y', 'R', 'q', 'Q', 'M', 'w', 'I', 'D', 'i', 'e', 'c', 't', 'T']);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
parse(dateString, token, match) {
|
|
16
|
+
var valueCallback = function (value) {
|
|
17
|
+
return value - 1;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
switch (token) {
|
|
21
|
+
// 1, 2, ..., 12
|
|
22
|
+
case 'L':
|
|
23
|
+
return mapValue(parseNumericPattern(numericPatterns.month, dateString), valueCallback);
|
|
24
|
+
// 01, 02, ..., 12
|
|
25
|
+
|
|
26
|
+
case 'LL':
|
|
27
|
+
return mapValue(parseNDigits(2, dateString), valueCallback);
|
|
28
|
+
// 1st, 2nd, ..., 12th
|
|
29
|
+
|
|
30
|
+
case 'Lo':
|
|
31
|
+
return mapValue(match.ordinalNumber(dateString, {
|
|
32
|
+
unit: 'month'
|
|
33
|
+
}), valueCallback);
|
|
34
|
+
// Jan, Feb, ..., Dec
|
|
35
|
+
|
|
36
|
+
case 'LLL':
|
|
37
|
+
return match.month(dateString, {
|
|
38
|
+
width: 'abbreviated',
|
|
39
|
+
context: 'standalone'
|
|
40
|
+
}) || match.month(dateString, {
|
|
41
|
+
width: 'narrow',
|
|
42
|
+
context: 'standalone'
|
|
43
|
+
});
|
|
44
|
+
// J, F, ..., D
|
|
45
|
+
|
|
46
|
+
case 'LLLLL':
|
|
47
|
+
return match.month(dateString, {
|
|
48
|
+
width: 'narrow',
|
|
49
|
+
context: 'standalone'
|
|
50
|
+
});
|
|
51
|
+
// January, February, ..., December
|
|
52
|
+
|
|
53
|
+
case 'LLLL':
|
|
54
|
+
default:
|
|
55
|
+
return match.month(dateString, {
|
|
56
|
+
width: 'wide',
|
|
57
|
+
context: 'standalone'
|
|
58
|
+
}) || match.month(dateString, {
|
|
59
|
+
width: 'abbreviated',
|
|
60
|
+
context: 'standalone'
|
|
61
|
+
}) || match.month(dateString, {
|
|
62
|
+
width: 'narrow',
|
|
63
|
+
context: 'standalone'
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
validate(_date, value) {
|
|
69
|
+
return value >= 0 && value <= 11;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
set(date, _flags, value) {
|
|
73
|
+
date.setUTCMonth(value, 1);
|
|
74
|
+
date.setUTCHours(0, 0, 0, 0);
|
|
75
|
+
return date;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { StandAloneMonthParser };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Parser } from '../Parser.js';
|
|
2
|
+
import { parseNDigits } from '../utils.js';
|
|
3
|
+
|
|
4
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
class StandAloneQuarterParser extends Parser {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
|
|
9
|
+
_defineProperty(this, "priority", 120);
|
|
10
|
+
|
|
11
|
+
_defineProperty(this, "incompatibleTokens", ['Y', 'R', 'Q', 'M', 'L', 'w', 'I', 'd', 'D', 'i', 'e', 'c', 't', 'T']);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
parse(dateString, token, match) {
|
|
15
|
+
switch (token) {
|
|
16
|
+
// 1, 2, 3, 4
|
|
17
|
+
case 'q':
|
|
18
|
+
case 'qq':
|
|
19
|
+
// 01, 02, 03, 04
|
|
20
|
+
return parseNDigits(token.length, dateString);
|
|
21
|
+
// 1st, 2nd, 3rd, 4th
|
|
22
|
+
|
|
23
|
+
case 'qo':
|
|
24
|
+
return match.ordinalNumber(dateString, {
|
|
25
|
+
unit: 'quarter'
|
|
26
|
+
});
|
|
27
|
+
// Q1, Q2, Q3, Q4
|
|
28
|
+
|
|
29
|
+
case 'qqq':
|
|
30
|
+
return match.quarter(dateString, {
|
|
31
|
+
width: 'abbreviated',
|
|
32
|
+
context: 'standalone'
|
|
33
|
+
}) || match.quarter(dateString, {
|
|
34
|
+
width: 'narrow',
|
|
35
|
+
context: 'standalone'
|
|
36
|
+
});
|
|
37
|
+
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
|
|
38
|
+
|
|
39
|
+
case 'qqqqq':
|
|
40
|
+
return match.quarter(dateString, {
|
|
41
|
+
width: 'narrow',
|
|
42
|
+
context: 'standalone'
|
|
43
|
+
});
|
|
44
|
+
// 1st quarter, 2nd quarter, ...
|
|
45
|
+
|
|
46
|
+
case 'qqqq':
|
|
47
|
+
default:
|
|
48
|
+
return match.quarter(dateString, {
|
|
49
|
+
width: 'wide',
|
|
50
|
+
context: 'standalone'
|
|
51
|
+
}) || match.quarter(dateString, {
|
|
52
|
+
width: 'abbreviated',
|
|
53
|
+
context: 'standalone'
|
|
54
|
+
}) || match.quarter(dateString, {
|
|
55
|
+
width: 'narrow',
|
|
56
|
+
context: 'standalone'
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
validate(_date, value) {
|
|
62
|
+
return value >= 1 && value <= 4;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
set(date, _flags, value) {
|
|
66
|
+
date.setUTCMonth((value - 1) * 3, 1);
|
|
67
|
+
date.setUTCHours(0, 0, 0, 0);
|
|
68
|
+
return date;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { StandAloneQuarterParser };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Parser } from '../Parser.js';
|
|
2
|
+
import { parseAnyDigitsSigned } from '../utils.js';
|
|
3
|
+
|
|
4
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
class TimestampMillisecondsParser extends Parser {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
|
|
9
|
+
_defineProperty(this, "priority", 20);
|
|
10
|
+
|
|
11
|
+
_defineProperty(this, "incompatibleTokens", '*');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
parse(dateString) {
|
|
15
|
+
return parseAnyDigitsSigned(dateString);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
set(_date, _flags, value) {
|
|
19
|
+
return [new Date(value), {
|
|
20
|
+
timestampIsSet: true
|
|
21
|
+
}];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { TimestampMillisecondsParser };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Parser } from '../Parser.js';
|
|
2
|
+
import { parseAnyDigitsSigned } from '../utils.js';
|
|
3
|
+
|
|
4
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
class TimestampSecondsParser extends Parser {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
|
|
9
|
+
_defineProperty(this, "priority", 40);
|
|
10
|
+
|
|
11
|
+
_defineProperty(this, "incompatibleTokens", '*');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
parse(dateString) {
|
|
15
|
+
return parseAnyDigitsSigned(dateString);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
set(_date, _flags, value) {
|
|
19
|
+
return [new Date(value * 1000), {
|
|
20
|
+
timestampIsSet: true
|
|
21
|
+
}];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { TimestampSecondsParser };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Parser } from '../Parser.js';
|
|
2
|
+
import { mapValue, parseNDigits, normalizeTwoDigitYear } from '../utils.js';
|
|
3
|
+
|
|
4
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
// From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns
|
|
6
|
+
// | Year | y | yy | yyy | yyyy | yyyyy |
|
|
7
|
+
// |----------|-------|----|-------|-------|-------|
|
|
8
|
+
// | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
|
|
9
|
+
// | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
|
|
10
|
+
// | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
|
|
11
|
+
// | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
|
|
12
|
+
// | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
|
|
13
|
+
class YearParser extends Parser {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
|
|
17
|
+
_defineProperty(this, "priority", 130);
|
|
18
|
+
|
|
19
|
+
_defineProperty(this, "incompatibleTokens", ['Y', 'R', 'u', 'w', 'I', 'i', 'e', 'c', 't', 'T']);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
parse(dateString, token, match) {
|
|
23
|
+
var valueCallback = function (year) {
|
|
24
|
+
return {
|
|
25
|
+
year: year,
|
|
26
|
+
isTwoDigitYear: token === 'yy'
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
switch (token) {
|
|
31
|
+
case 'y':
|
|
32
|
+
return mapValue(parseNDigits(4, dateString), valueCallback);
|
|
33
|
+
|
|
34
|
+
case 'yo':
|
|
35
|
+
return mapValue(match.ordinalNumber(dateString, {
|
|
36
|
+
unit: 'year'
|
|
37
|
+
}), valueCallback);
|
|
38
|
+
|
|
39
|
+
default:
|
|
40
|
+
return mapValue(parseNDigits(token.length, dateString), valueCallback);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
validate(_date, value) {
|
|
45
|
+
return value.isTwoDigitYear || value.year > 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
set(date, flags, value) {
|
|
49
|
+
var currentYear = date.getUTCFullYear();
|
|
50
|
+
|
|
51
|
+
if (value.isTwoDigitYear) {
|
|
52
|
+
var normalizedTwoDigitYear = normalizeTwoDigitYear(value.year, currentYear);
|
|
53
|
+
date.setUTCFullYear(normalizedTwoDigitYear, 0, 1);
|
|
54
|
+
date.setUTCHours(0, 0, 0, 0);
|
|
55
|
+
return date;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
var year = !('era' in flags) || flags.era === 1 ? value.year : 1 - value.year;
|
|
59
|
+
date.setUTCFullYear(year, 0, 1);
|
|
60
|
+
date.setUTCHours(0, 0, 0, 0);
|
|
61
|
+
return date;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { YearParser };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { EraParser } from './EraParser.js';
|
|
2
|
+
import { YearParser } from './YearParser.js';
|
|
3
|
+
import { LocalWeekYearParser } from './LocalWeekYearParser.js';
|
|
4
|
+
import { ISOWeekYearParser } from './ISOWeekYearParser.js';
|
|
5
|
+
import { ExtendedYearParser } from './ExtendedYearParser.js';
|
|
6
|
+
import { QuarterParser } from './QuarterParser.js';
|
|
7
|
+
import { StandAloneQuarterParser } from './StandAloneQuarterParser.js';
|
|
8
|
+
import { MonthParser } from './MonthParser.js';
|
|
9
|
+
import { StandAloneMonthParser } from './StandAloneMonthParser.js';
|
|
10
|
+
import { LocalWeekParser } from './LocalWeekParser.js';
|
|
11
|
+
import { ISOWeekParser } from './ISOWeekParser.js';
|
|
12
|
+
import { DateParser } from './DateParser.js';
|
|
13
|
+
import { DayOfYearParser } from './DayOfYearParser.js';
|
|
14
|
+
import { DayParser } from './DayParser.js';
|
|
15
|
+
import { LocalDayParser } from './LocalDayParser.js';
|
|
16
|
+
import { StandAloneLocalDayParser } from './StandAloneLocalDayParser.js';
|
|
17
|
+
import { ISODayParser } from './ISODayParser.js';
|
|
18
|
+
import { AMPMParser } from './AMPMParser.js';
|
|
19
|
+
import { AMPMMidnightParser } from './AMPMMidnightParser.js';
|
|
20
|
+
import { DayPeriodParser } from './DayPeriodParser.js';
|
|
21
|
+
import { Hour1to12Parser } from './Hour1to12Parser.js';
|
|
22
|
+
import { Hour0to23Parser } from './Hour0to23Parser.js';
|
|
23
|
+
import { Hour0To11Parser } from './Hour0To11Parser.js';
|
|
24
|
+
import { Hour1To24Parser } from './Hour1To24Parser.js';
|
|
25
|
+
import { MinuteParser } from './MinuteParser.js';
|
|
26
|
+
import { SecondParser } from './SecondParser.js';
|
|
27
|
+
import { FractionOfSecondParser } from './FractionOfSecondParser.js';
|
|
28
|
+
import { ISOTimezoneWithZParser } from './ISOTimezoneWithZParser.js';
|
|
29
|
+
import { ISOTimezoneParser } from './ISOTimezoneParser.js';
|
|
30
|
+
import { TimestampSecondsParser } from './TimestampSecondsParser.js';
|
|
31
|
+
import { TimestampMillisecondsParser } from './TimestampMillisecondsParser.js';
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* | | Unit | | Unit |
|
|
35
|
+
* |-----|--------------------------------|-----|--------------------------------|
|
|
36
|
+
* | a | AM, PM | A* | Milliseconds in day |
|
|
37
|
+
* | b | AM, PM, noon, midnight | B | Flexible day period |
|
|
38
|
+
* | c | Stand-alone local day of week | C* | Localized hour w/ day period |
|
|
39
|
+
* | d | Day of month | D | Day of year |
|
|
40
|
+
* | e | Local day of week | E | Day of week |
|
|
41
|
+
* | f | | F* | Day of week in month |
|
|
42
|
+
* | g* | Modified Julian day | G | Era |
|
|
43
|
+
* | h | Hour [1-12] | H | Hour [0-23] |
|
|
44
|
+
* | i! | ISO day of week | I! | ISO week of year |
|
|
45
|
+
* | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
|
|
46
|
+
* | k | Hour [1-24] | K | Hour [0-11] |
|
|
47
|
+
* | l* | (deprecated) | L | Stand-alone month |
|
|
48
|
+
* | m | Minute | M | Month |
|
|
49
|
+
* | n | | N | |
|
|
50
|
+
* | o! | Ordinal number modifier | O* | Timezone (GMT) |
|
|
51
|
+
* | p | | P | |
|
|
52
|
+
* | q | Stand-alone quarter | Q | Quarter |
|
|
53
|
+
* | r* | Related Gregorian year | R! | ISO week-numbering year |
|
|
54
|
+
* | s | Second | S | Fraction of second |
|
|
55
|
+
* | t! | Seconds timestamp | T! | Milliseconds timestamp |
|
|
56
|
+
* | u | Extended year | U* | Cyclic year |
|
|
57
|
+
* | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
|
|
58
|
+
* | w | Local week of year | W* | Week of month |
|
|
59
|
+
* | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
|
|
60
|
+
* | y | Year (abs) | Y | Local week-numbering year |
|
|
61
|
+
* | z* | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
|
|
62
|
+
*
|
|
63
|
+
* Letters marked by * are not implemented but reserved by Unicode standard.
|
|
64
|
+
*
|
|
65
|
+
* Letters marked by ! are non-standard, but implemented by date-fns:
|
|
66
|
+
* - `o` modifies the previous token to turn it into an ordinal (see `parse` docs)
|
|
67
|
+
* - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
|
|
68
|
+
* i.e. 7 for Sunday, 1 for Monday, etc.
|
|
69
|
+
* - `I` is ISO week of year, as opposed to `w` which is local week of year.
|
|
70
|
+
* - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
|
|
71
|
+
* `R` is supposed to be used in conjunction with `I` and `i`
|
|
72
|
+
* for universal ISO week-numbering date, whereas
|
|
73
|
+
* `Y` is supposed to be used in conjunction with `w` and `e`
|
|
74
|
+
* for week-numbering date specific to the locale.
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
({
|
|
78
|
+
G: new EraParser(),
|
|
79
|
+
y: new YearParser(),
|
|
80
|
+
Y: new LocalWeekYearParser(),
|
|
81
|
+
R: new ISOWeekYearParser(),
|
|
82
|
+
u: new ExtendedYearParser(),
|
|
83
|
+
Q: new QuarterParser(),
|
|
84
|
+
q: new StandAloneQuarterParser(),
|
|
85
|
+
M: new MonthParser(),
|
|
86
|
+
L: new StandAloneMonthParser(),
|
|
87
|
+
w: new LocalWeekParser(),
|
|
88
|
+
I: new ISOWeekParser(),
|
|
89
|
+
d: new DateParser(),
|
|
90
|
+
D: new DayOfYearParser(),
|
|
91
|
+
E: new DayParser(),
|
|
92
|
+
e: new LocalDayParser(),
|
|
93
|
+
c: new StandAloneLocalDayParser(),
|
|
94
|
+
i: new ISODayParser(),
|
|
95
|
+
a: new AMPMParser(),
|
|
96
|
+
b: new AMPMMidnightParser(),
|
|
97
|
+
B: new DayPeriodParser(),
|
|
98
|
+
h: new Hour1to12Parser(),
|
|
99
|
+
H: new Hour0to23Parser(),
|
|
100
|
+
K: new Hour0To11Parser(),
|
|
101
|
+
k: new Hour1To24Parser(),
|
|
102
|
+
m: new MinuteParser(),
|
|
103
|
+
s: new SecondParser(),
|
|
104
|
+
S: new FractionOfSecondParser(),
|
|
105
|
+
X: new ISOTimezoneWithZParser(),
|
|
106
|
+
x: new ISOTimezoneParser(),
|
|
107
|
+
t: new TimestampSecondsParser(),
|
|
108
|
+
T: new TimestampMillisecondsParser()
|
|
109
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { millisecondsInHour, millisecondsInMinute, millisecondsInSecond } from '../../constants/index.js';
|
|
2
|
+
import { numericPatterns } from './constants.js';
|
|
3
|
+
|
|
4
|
+
function mapValue(parseFnResult, mapFn) {
|
|
5
|
+
if (!parseFnResult) {
|
|
6
|
+
return parseFnResult;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
value: mapFn(parseFnResult.value),
|
|
11
|
+
rest: parseFnResult.rest
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function parseNumericPattern(pattern, dateString) {
|
|
15
|
+
var matchResult = dateString.match(pattern);
|
|
16
|
+
|
|
17
|
+
if (!matchResult) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
value: parseInt(matchResult[0], 10),
|
|
23
|
+
rest: dateString.slice(matchResult[0].length)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function parseTimezonePattern(pattern, dateString) {
|
|
27
|
+
var matchResult = dateString.match(pattern);
|
|
28
|
+
|
|
29
|
+
if (!matchResult) {
|
|
30
|
+
return null;
|
|
31
|
+
} // Input is 'Z'
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
if (matchResult[0] === 'Z') {
|
|
35
|
+
return {
|
|
36
|
+
value: 0,
|
|
37
|
+
rest: dateString.slice(1)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
var sign = matchResult[1] === '+' ? 1 : -1;
|
|
42
|
+
var hours = matchResult[2] ? parseInt(matchResult[2], 10) : 0;
|
|
43
|
+
var minutes = matchResult[3] ? parseInt(matchResult[3], 10) : 0;
|
|
44
|
+
var seconds = matchResult[5] ? parseInt(matchResult[5], 10) : 0;
|
|
45
|
+
return {
|
|
46
|
+
value: sign * (hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * millisecondsInSecond),
|
|
47
|
+
rest: dateString.slice(matchResult[0].length)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function parseAnyDigitsSigned(dateString) {
|
|
51
|
+
return parseNumericPattern(numericPatterns.anyDigitsSigned, dateString);
|
|
52
|
+
}
|
|
53
|
+
function parseNDigits(n, dateString) {
|
|
54
|
+
switch (n) {
|
|
55
|
+
case 1:
|
|
56
|
+
return parseNumericPattern(numericPatterns.singleDigit, dateString);
|
|
57
|
+
|
|
58
|
+
case 2:
|
|
59
|
+
return parseNumericPattern(numericPatterns.twoDigits, dateString);
|
|
60
|
+
|
|
61
|
+
case 3:
|
|
62
|
+
return parseNumericPattern(numericPatterns.threeDigits, dateString);
|
|
63
|
+
|
|
64
|
+
case 4:
|
|
65
|
+
return parseNumericPattern(numericPatterns.fourDigits, dateString);
|
|
66
|
+
|
|
67
|
+
default:
|
|
68
|
+
return parseNumericPattern(new RegExp('^\\d{1,' + n + '}'), dateString);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function parseNDigitsSigned(n, dateString) {
|
|
72
|
+
switch (n) {
|
|
73
|
+
case 1:
|
|
74
|
+
return parseNumericPattern(numericPatterns.singleDigitSigned, dateString);
|
|
75
|
+
|
|
76
|
+
case 2:
|
|
77
|
+
return parseNumericPattern(numericPatterns.twoDigitsSigned, dateString);
|
|
78
|
+
|
|
79
|
+
case 3:
|
|
80
|
+
return parseNumericPattern(numericPatterns.threeDigitsSigned, dateString);
|
|
81
|
+
|
|
82
|
+
case 4:
|
|
83
|
+
return parseNumericPattern(numericPatterns.fourDigitsSigned, dateString);
|
|
84
|
+
|
|
85
|
+
default:
|
|
86
|
+
return parseNumericPattern(new RegExp('^-?\\d{1,' + n + '}'), dateString);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function dayPeriodEnumToHours(dayPeriod) {
|
|
90
|
+
switch (dayPeriod) {
|
|
91
|
+
case 'morning':
|
|
92
|
+
return 4;
|
|
93
|
+
|
|
94
|
+
case 'evening':
|
|
95
|
+
return 17;
|
|
96
|
+
|
|
97
|
+
case 'pm':
|
|
98
|
+
case 'noon':
|
|
99
|
+
case 'afternoon':
|
|
100
|
+
return 12;
|
|
101
|
+
|
|
102
|
+
case 'am':
|
|
103
|
+
case 'midnight':
|
|
104
|
+
case 'night':
|
|
105
|
+
default:
|
|
106
|
+
return 0;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function normalizeTwoDigitYear(twoDigitYear, currentYear) {
|
|
110
|
+
var isCommonEra = currentYear > 0; // Absolute number of the current year:
|
|
111
|
+
// 1 -> 1 AC
|
|
112
|
+
// 0 -> 1 BC
|
|
113
|
+
// -1 -> 2 BC
|
|
114
|
+
|
|
115
|
+
var absCurrentYear = isCommonEra ? currentYear : 1 - currentYear;
|
|
116
|
+
var result;
|
|
117
|
+
|
|
118
|
+
if (absCurrentYear <= 50) {
|
|
119
|
+
result = twoDigitYear || 100;
|
|
120
|
+
} else {
|
|
121
|
+
var rangeEnd = absCurrentYear + 50;
|
|
122
|
+
var rangeEndCentury = Math.floor(rangeEnd / 100) * 100;
|
|
123
|
+
var isPreviousCentury = twoDigitYear >= rangeEnd % 100;
|
|
124
|
+
result = twoDigitYear + rangeEndCentury - (isPreviousCentury ? 100 : 0);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return isCommonEra ? result : 1 - result;
|
|
128
|
+
}
|
|
129
|
+
function isLeapYearIndex(year) {
|
|
130
|
+
return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export { dayPeriodEnumToHours, isLeapYearIndex, mapValue, normalizeTwoDigitYear, parseAnyDigitsSigned, parseNDigits, parseNDigitsSigned, parseNumericPattern, parseTimezonePattern };
|
|
@@ -10,10 +10,6 @@ import requiredArgs from '../_lib/requiredArgs/index.js';
|
|
|
10
10
|
* Return the start of a day for the given date.
|
|
11
11
|
* The result will be in the local timezone.
|
|
12
12
|
*
|
|
13
|
-
* ### v2.0.0 breaking changes:
|
|
14
|
-
*
|
|
15
|
-
* - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
|
|
16
|
-
*
|
|
17
13
|
* @param {Date|Number} date - the original date
|
|
18
14
|
* @returns {Date} the start of a day
|
|
19
15
|
* @throws {TypeError} 1 argument required
|
|
@@ -43,7 +43,7 @@ function toDate(argument) {
|
|
|
43
43
|
} else {
|
|
44
44
|
if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
|
|
45
45
|
// eslint-disable-next-line no-console
|
|
46
|
-
console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://
|
|
46
|
+
console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"); // eslint-disable-next-line no-console
|
|
47
47
|
|
|
48
48
|
console.warn(new Error().stack);
|
|
49
49
|
}
|