cnhis-design-vue 3.1.14 → 3.1.15-beta.10
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/es/packages/annotation-edit/src/AnnotationEdit.js +2 -1
- package/es/packages/big-table/index.d.ts +8 -11
- package/es/packages/big-table/src/BigTable.vue.d.ts +24 -19
- package/es/packages/big-table/src/BigTable.vue_vue_type_script_setup_true_lang.js +17 -11
- package/es/packages/big-table/src/bigTableProps.d.ts +4 -3
- package/es/packages/big-table/src/bigTableProps.js +1 -1
- package/es/packages/big-table/src/components/edit-form/edit-date.js +13 -4
- package/es/packages/big-table/src/components/edit-form/edit-select.js +2 -1
- package/es/packages/big-table/src/components/edit-form/edit-separate.js +18 -9
- package/es/packages/big-table/src/components/edit-form/edit-separate.vue.d.ts +3 -1
- package/es/packages/big-table/src/hooks/useAnnotation.d.ts +4 -0
- package/es/packages/big-table/src/hooks/useAnnotation.js +21 -0
- package/es/packages/big-table/src/hooks/useColumnConfigAdaptor.js +51 -36
- package/es/packages/big-table/src/hooks/useEdit.d.ts +3 -1
- package/es/packages/big-table/src/hooks/useFormat.js +8 -1
- package/es/packages/big-table/style/index.css +38 -1
- package/es/packages/bpmn-workflow/src/BpmnWorkflow.js +2 -2
- package/es/packages/bpmn-workflow/src/custom/customModeler/customBpmn/BpmnRenderer.js +8 -8
- package/es/packages/bpmn-workflow/src/custom/customModeler/customBpmn/CustomContextPadProvider.js +2 -2
- package/es/packages/bpmn-workflow/src/custom/customModeler/customBpmn/CustomPalette.js +1 -1
- package/es/packages/bpmn-workflow/src/custom/customModeler/customBpmn/CustomRenderer.js +4 -3
- package/es/packages/bpmn-workflow/src/custom/customModeler/customBpmn/CustomRules.js +2 -2
- package/es/packages/bpmn-workflow/src/custom/customModeler/index.js +1 -1
- package/es/packages/bpmn-workflow/src/custom/customOtherModule/CustomPopupMenu.js +2 -2
- package/es/packages/bpmn-workflow/src/custom/customOtherModule/zoomScroll.js +3 -3
- package/es/packages/button-print/src/utils/print.d.ts +1 -1
- package/es/packages/button-print/src/utils/print.js +1 -1
- package/es/packages/fabric-chart/index.d.ts +1 -0
- package/es/packages/fabric-chart/src/FabricChart.js +17 -17
- package/es/packages/fabric-chart/src/FabricChart.vue.d.ts +12 -10
- package/es/packages/fabric-chart/src/hooks/useCenter.js +35 -73
- package/es/packages/fabric-chart/src/hooks/useCumputedPoint.js +4 -2
- package/es/packages/fabric-chart/src/hooks/useDraw.js +1 -0
- package/es/packages/fabric-chart/src/hooks/useLeft.js +5 -4
- package/es/packages/field-set/index.d.ts +4365 -0
- package/es/packages/field-set/src/FieldSet.js +53 -54
- package/es/packages/field-set/src/FieldSet.vue.d.ts +4365 -0
- package/es/packages/field-set/style/index.css +0 -9
- package/es/packages/form-config/index.d.ts +12111 -0
- package/es/packages/form-config/index.js +10 -0
- package/es/packages/form-config/src/FormConfig.js +113 -0
- package/es/packages/form-config/src/FormConfig.vue.d.ts +12113 -0
- package/es/packages/form-config/src/components/FormConfigCreator.js +97 -0
- package/es/packages/form-config/src/components/FormConfigCreator.vue.d.ts +5094 -0
- package/es/packages/form-config/src/components/FormConfigEdit.js +81 -0
- package/es/packages/form-config/src/components/FormConfigEdit.vue.d.ts +3591 -0
- package/es/packages/form-config/src/constants/index.d.ts +28 -0
- package/es/packages/form-config/src/constants/index.js +28 -0
- package/es/packages/form-config/src/hooks/index.d.ts +2 -0
- package/es/packages/form-config/src/hooks/index.js +2 -0
- package/es/packages/form-config/src/hooks/useConfigurationField.d.ts +6 -0
- package/es/packages/form-config/src/hooks/useConfigurationField.js +103 -0
- package/es/packages/form-config/src/hooks/usePresetRenderer.d.ts +5 -0
- package/es/packages/form-config/src/hooks/usePresetRenderer.js +117 -0
- package/es/packages/form-config/src/hooks/useSortable.d.ts +11 -0
- package/es/packages/form-config/src/hooks/useSortable.js +31 -0
- package/es/packages/form-config/src/types/index.d.ts +18 -0
- package/es/packages/form-config/src/types/index.js +1 -0
- package/es/packages/form-config/style/index.css +108 -0
- package/es/packages/form-render/index.d.ts +24 -3
- package/es/packages/form-render/src/FormRender.js +25 -6
- package/es/packages/form-render/src/FormRender.vue.d.ts +24 -3
- package/es/packages/form-render/src/components/renderer/cascader.js +7 -7
- package/es/packages/form-render/src/components/renderer/combination/hooks/useDeepValidate.d.ts +5 -0
- package/es/packages/form-render/src/components/renderer/combination/hooks/useDeepValidate.js +32 -0
- package/es/packages/form-render/src/components/renderer/{combination.d.ts → combination/index.d.ts} +7 -1
- package/es/packages/form-render/src/components/renderer/combination/index.js +157 -0
- package/es/packages/form-render/src/components/renderer/complex.d.ts +2 -0
- package/es/packages/form-render/src/components/renderer/complex.js +2 -5
- package/es/packages/form-render/src/components/renderer/date.d.ts +29 -0
- package/es/packages/form-render/src/components/renderer/date.js +63 -56
- package/es/packages/form-render/src/components/renderer/formItem.js +3 -3
- package/es/packages/form-render/src/components/renderer/index.js +1 -1
- package/es/packages/form-render/src/components/renderer/radio.js +4 -1
- package/es/packages/form-render/src/components/renderer/select.d.ts +9 -0
- package/es/packages/form-render/src/components/renderer/select.js +28 -17
- package/es/packages/form-render/src/constants/index.d.ts +2 -1
- package/es/packages/form-render/src/hooks/useAnchor.d.ts +7 -6
- package/es/packages/form-render/src/hooks/useAnchor.js +1 -2
- package/es/packages/form-render/src/hooks/useAsyncQueue.d.ts +6 -1
- package/es/packages/form-render/src/hooks/useAsyncQueue.js +12 -7
- package/es/packages/form-render/src/hooks/useCommonInjection.d.ts +6 -0
- package/es/packages/form-render/src/hooks/useCommonInjection.js +19 -0
- package/es/packages/form-render/src/hooks/useFieldListAdaptor.js +9 -7
- package/es/packages/form-render/src/hooks/useFormContext.d.ts +3 -3
- package/es/packages/form-render/src/hooks/useFormContext.js +21 -3
- package/es/packages/form-render/src/hooks/useFormRenderLifeCycle.d.ts +13 -0
- package/es/packages/form-render/src/hooks/useFormRenderLifeCycle.js +10 -0
- package/es/packages/form-render/src/types/fieldItem.d.ts +33 -4
- package/es/packages/form-render/src/types/index.d.ts +30 -2
- package/es/packages/form-render/src/utils/index.d.ts +8 -5
- package/es/packages/form-render/src/utils/index.js +64 -13
- package/es/packages/form-render/style/index.css +11 -10
- package/es/packages/form-table/src/hooks/useNuiThemeOverrides.js +1 -1
- package/es/packages/index.css +158 -21
- package/es/packages/index.d.ts +3 -1
- package/es/packages/index.js +4 -1
- package/es/packages/info-header/index.d.ts +1 -3
- package/es/packages/info-header/src/HiddenContent.js +1 -1
- package/es/packages/info-header/src/HiddenContent.vue.d.ts +1 -3
- package/es/packages/info-header/src/InfoHeader.vue.d.ts +1 -3
- package/es/packages/info-header/style/index.css +1 -1
- package/es/packages/shortcut-provider/index.d.ts +2 -11
- package/es/packages/shortcut-provider/src/ShortcutProvider.js +1 -5
- package/es/packages/shortcut-provider/src/ShortcutProvider.vue.d.ts +2 -11
- package/es/packages/shortcut-provider/src/hooks/useShortcuts.d.ts +11 -8
- package/es/packages/shortcut-provider/src/hooks/useShortcuts.js +44 -28
- package/es/packages/shortcut-provider/src/types/index.d.ts +32 -4
- package/es/packages/shortcut-provider/src/utils/index.d.ts +3 -0
- package/es/packages/shortcut-provider/src/utils/index.js +15 -5
- package/es/packages/shortcut-setter/index.d.ts +32 -9
- package/es/packages/shortcut-setter/src/ShortcutSetter.vue.d.ts +32 -9
- package/es/packages/shortcut-setter/src/ShortcutSetterItem.js +8 -6
- package/es/packages/shortcut-setter/src/ShortcutSetterItem.vue.d.ts +8 -6
- package/es/src/utils/state.d.ts +29 -0
- package/es/src/utils/state.js +44 -0
- package/package.json +10 -1
- package/es/_virtual/_commonjsHelpers.js +0 -7
- package/es/_virtual/css.escape.js +0 -3
- package/es/_virtual/inherits.js +0 -3
- package/es/_virtual/inherits_browser.js +0 -3
- package/es/node_modules/@formily/path/esm/contexts.js +0 -22
- package/es/node_modules/@formily/path/esm/destructor.js +0 -124
- package/es/node_modules/@formily/path/esm/index.js +0 -579
- package/es/node_modules/@formily/path/esm/matcher.js +0 -199
- package/es/node_modules/@formily/path/esm/parser.js +0 -402
- package/es/node_modules/@formily/path/esm/shared.js +0 -73
- package/es/node_modules/@formily/path/esm/tokenizer.js +0 -287
- package/es/node_modules/@formily/path/esm/tokens.js +0 -240
- package/es/node_modules/@formily/path/esm/types.js +0 -17
- package/es/node_modules/css.escape/css.escape.js +0 -110
- package/es/node_modules/date-fns/esm/_lib/defaultOptions/index.js +0 -6
- package/es/node_modules/date-fns/esm/_lib/getTimezoneOffsetInMilliseconds/index.js +0 -18
- package/es/node_modules/date-fns/esm/_lib/getUTCISOWeek/index.js +0 -17
- package/es/node_modules/date-fns/esm/_lib/getUTCISOWeekYear/index.js +0 -27
- package/es/node_modules/date-fns/esm/_lib/getUTCWeek/index.js +0 -17
- package/es/node_modules/date-fns/esm/_lib/getUTCWeekYear/index.js +0 -38
- package/es/node_modules/date-fns/esm/_lib/requiredArgs/index.js +0 -7
- package/es/node_modules/date-fns/esm/_lib/setUTCDay/index.js +0 -27
- package/es/node_modules/date-fns/esm/_lib/setUTCISODay/index.js +0 -23
- package/es/node_modules/date-fns/esm/_lib/setUTCISOWeek/index.js +0 -15
- package/es/node_modules/date-fns/esm/_lib/setUTCWeek/index.js +0 -15
- package/es/node_modules/date-fns/esm/_lib/startOfUTCISOWeek/index.js +0 -15
- package/es/node_modules/date-fns/esm/_lib/startOfUTCISOWeekYear/index.js +0 -15
- package/es/node_modules/date-fns/esm/_lib/startOfUTCWeek/index.js +0 -25
- package/es/node_modules/date-fns/esm/_lib/startOfUTCWeekYear/index.js +0 -21
- package/es/node_modules/date-fns/esm/_lib/toInteger/index.js +0 -15
- package/es/node_modules/date-fns/esm/compareAsc/index.js +0 -52
- package/es/node_modules/date-fns/esm/constants/index.js +0 -40
- package/es/node_modules/date-fns/esm/differenceInCalendarDays/index.js +0 -49
- package/es/node_modules/date-fns/esm/differenceInCalendarMonths/index.js +0 -35
- package/es/node_modules/date-fns/esm/differenceInCalendarYears/index.js +0 -33
- package/es/node_modules/date-fns/esm/differenceInDays/index.js +0 -86
- package/es/node_modules/date-fns/esm/differenceInMonths/index.js +0 -59
- package/es/node_modules/date-fns/esm/differenceInYears/index.js +0 -43
- package/es/node_modules/date-fns/esm/endOfDay/index.js +0 -30
- package/es/node_modules/date-fns/esm/endOfMonth/index.js +0 -32
- package/es/node_modules/date-fns/esm/isLastDayOfMonth/index.js +0 -30
- package/es/node_modules/date-fns/esm/parse/_lib/Parser.js +0 -32
- package/es/node_modules/date-fns/esm/parse/_lib/Setter.js +0 -37
- package/es/node_modules/date-fns/esm/parse/_lib/constants.js +0 -48
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/AMPMMidnightParser.js +0 -55
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/AMPMParser.js +0 -55
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/DateParser.js +0 -55
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/DayOfYearParser.js +0 -52
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/DayParser.js +0 -80
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/DayPeriodParser.js +0 -56
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/EraParser.js +0 -53
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/ExtendedYearParser.js +0 -30
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/FractionOfSecondParser.js +0 -29
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/Hour0To11Parser.js +0 -48
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/Hour0to23Parser.js +0 -41
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/Hour1To24Parser.js +0 -42
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/Hour1to12Parser.js +0 -50
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/ISODayParser.js +0 -99
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/ISOTimezoneParser.js +0 -46
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/ISOTimezoneWithZParser.js +0 -46
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/ISOWeekParser.js +0 -43
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/ISOWeekYearParser.js +0 -33
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/LocalDayParser.js +0 -96
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/LocalWeekParser.js +0 -43
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/LocalWeekYearParser.js +0 -61
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/MinuteParser.js +0 -41
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/MonthParser.js +0 -80
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/QuarterParser.js +0 -73
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/SecondParser.js +0 -41
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneLocalDayParser.js +0 -96
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneMonthParser.js +0 -80
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneQuarterParser.js +0 -73
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/TimestampMillisecondsParser.js +0 -26
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/TimestampSecondsParser.js +0 -26
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/YearParser.js +0 -66
- package/es/node_modules/date-fns/esm/parse/_lib/parsers/index.js +0 -109
- package/es/node_modules/date-fns/esm/parse/_lib/utils.js +0 -133
- package/es/node_modules/date-fns/esm/startOfDay/index.js +0 -30
- package/es/node_modules/date-fns/esm/toDate/index.js +0 -55
- package/es/node_modules/diagram-js/lib/command/CommandInterceptor.js +0 -139
- package/es/node_modules/diagram-js/lib/draw/BaseRenderer.js +0 -88
- package/es/node_modules/diagram-js/lib/features/popup-menu/PopupMenu.js +0 -591
- package/es/node_modules/diagram-js/lib/features/rules/RuleProvider.js +0 -88
- package/es/node_modules/diagram-js/lib/navigation/movecanvas/MoveCanvas.js +0 -120
- package/es/node_modules/diagram-js/lib/navigation/movecanvas/index.js +0 -8
- package/es/node_modules/diagram-js/lib/navigation/zoomscroll/ZoomScroll.js +0 -227
- package/es/node_modules/diagram-js/lib/navigation/zoomscroll/ZoomUtil.js +0 -24
- package/es/node_modules/diagram-js/lib/util/ClickTrap.js +0 -23
- package/es/node_modules/diagram-js/lib/util/Cursor.js +0 -20
- package/es/node_modules/diagram-js/lib/util/Event.js +0 -22
- package/es/node_modules/diagram-js/lib/util/Math.js +0 -9
- package/es/node_modules/diagram-js/lib/util/Mouse.js +0 -30
- package/es/node_modules/diagram-js/lib/util/Platform.js +0 -5
- package/es/node_modules/diagram-js/lib/util/PositionUtil.js +0 -8
- package/es/node_modules/diagram-js/lib/util/RenderUtil.js +0 -25
- package/es/node_modules/diagram-js/lib/util/SvgTransformUtil.js +0 -48
- package/es/node_modules/ids/dist/index.esm.js +0 -164
- package/es/node_modules/inherits/inherits.js +0 -19
- package/es/node_modules/inherits/inherits_browser.js +0 -38
- package/es/node_modules/inherits-browser/dist/index.es.js +0 -3
- package/es/node_modules/min-dash/dist/index.esm.js +0 -169
- package/es/node_modules/min-dom/dist/index.esm.js +0 -588
- package/es/node_modules/tiny-svg/dist/index.esm.js +0 -525
- package/es/packages/form-render/src/components/renderer/combination.js +0 -148
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import toDate from '../../toDate/index.js';
|
|
2
|
-
import requiredArgs from '../requiredArgs/index.js';
|
|
3
|
-
import startOfUTCISOWeek from '../startOfUTCISOWeek/index.js';
|
|
4
|
-
|
|
5
|
-
function getUTCISOWeekYear(dirtyDate) {
|
|
6
|
-
requiredArgs(1, arguments);
|
|
7
|
-
var date = toDate(dirtyDate);
|
|
8
|
-
var year = date.getUTCFullYear();
|
|
9
|
-
var fourthOfJanuaryOfNextYear = new Date(0);
|
|
10
|
-
fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
|
|
11
|
-
fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
|
|
12
|
-
var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
|
|
13
|
-
var fourthOfJanuaryOfThisYear = new Date(0);
|
|
14
|
-
fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
|
|
15
|
-
fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
|
|
16
|
-
var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
|
|
17
|
-
|
|
18
|
-
if (date.getTime() >= startOfNextYear.getTime()) {
|
|
19
|
-
return year + 1;
|
|
20
|
-
} else if (date.getTime() >= startOfThisYear.getTime()) {
|
|
21
|
-
return year;
|
|
22
|
-
} else {
|
|
23
|
-
return year - 1;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { getUTCISOWeekYear as default };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import toDate from '../../toDate/index.js';
|
|
2
|
-
import startOfUTCWeek from '../startOfUTCWeek/index.js';
|
|
3
|
-
import startOfUTCWeekYear from '../startOfUTCWeekYear/index.js';
|
|
4
|
-
import requiredArgs from '../requiredArgs/index.js';
|
|
5
|
-
|
|
6
|
-
var MILLISECONDS_IN_WEEK = 604800000;
|
|
7
|
-
function getUTCWeek(dirtyDate, options) {
|
|
8
|
-
requiredArgs(1, arguments);
|
|
9
|
-
var date = toDate(dirtyDate);
|
|
10
|
-
var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime(); // Round the number of days to the nearest integer
|
|
11
|
-
// because the number of milliseconds in a week is not constant
|
|
12
|
-
// (e.g. it's different in the week of the daylight saving time clock shift)
|
|
13
|
-
|
|
14
|
-
return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { getUTCWeek as default };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import toDate from '../../toDate/index.js';
|
|
2
|
-
import requiredArgs from '../requiredArgs/index.js';
|
|
3
|
-
import startOfUTCWeek from '../startOfUTCWeek/index.js';
|
|
4
|
-
import toInteger from '../toInteger/index.js';
|
|
5
|
-
import { getDefaultOptions } from '../defaultOptions/index.js';
|
|
6
|
-
|
|
7
|
-
function getUTCWeekYear(dirtyDate, options) {
|
|
8
|
-
var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
|
|
9
|
-
|
|
10
|
-
requiredArgs(1, arguments);
|
|
11
|
-
var date = toDate(dirtyDate);
|
|
12
|
-
var year = date.getUTCFullYear();
|
|
13
|
-
var defaultOptions = getDefaultOptions();
|
|
14
|
-
var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1); // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
|
|
15
|
-
|
|
16
|
-
if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
|
|
17
|
-
throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
var firstWeekOfNextYear = new Date(0);
|
|
21
|
-
firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
|
|
22
|
-
firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
|
|
23
|
-
var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options);
|
|
24
|
-
var firstWeekOfThisYear = new Date(0);
|
|
25
|
-
firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
|
|
26
|
-
firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
|
|
27
|
-
var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options);
|
|
28
|
-
|
|
29
|
-
if (date.getTime() >= startOfNextYear.getTime()) {
|
|
30
|
-
return year + 1;
|
|
31
|
-
} else if (date.getTime() >= startOfThisYear.getTime()) {
|
|
32
|
-
return year;
|
|
33
|
-
} else {
|
|
34
|
-
return year - 1;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export { getUTCWeekYear as default };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import toDate from '../../toDate/index.js';
|
|
2
|
-
import requiredArgs from '../requiredArgs/index.js';
|
|
3
|
-
import toInteger from '../toInteger/index.js';
|
|
4
|
-
import { getDefaultOptions } from '../defaultOptions/index.js';
|
|
5
|
-
|
|
6
|
-
function setUTCDay(dirtyDate, dirtyDay, options) {
|
|
7
|
-
var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
|
|
8
|
-
|
|
9
|
-
requiredArgs(2, arguments);
|
|
10
|
-
var defaultOptions = getDefaultOptions();
|
|
11
|
-
var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
|
|
12
|
-
|
|
13
|
-
if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
|
|
14
|
-
throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
var date = toDate(dirtyDate);
|
|
18
|
-
var day = toInteger(dirtyDay);
|
|
19
|
-
var currentDay = date.getUTCDay();
|
|
20
|
-
var remainder = day % 7;
|
|
21
|
-
var dayIndex = (remainder + 7) % 7;
|
|
22
|
-
var diff = (dayIndex < weekStartsOn ? 7 : 0) + day - currentDay;
|
|
23
|
-
date.setUTCDate(date.getUTCDate() + diff);
|
|
24
|
-
return date;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { setUTCDay as default };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import toDate from '../../toDate/index.js';
|
|
2
|
-
import requiredArgs from '../requiredArgs/index.js';
|
|
3
|
-
import toInteger from '../toInteger/index.js';
|
|
4
|
-
|
|
5
|
-
function setUTCISODay(dirtyDate, dirtyDay) {
|
|
6
|
-
requiredArgs(2, arguments);
|
|
7
|
-
var day = toInteger(dirtyDay);
|
|
8
|
-
|
|
9
|
-
if (day % 7 === 0) {
|
|
10
|
-
day = day - 7;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
var weekStartsOn = 1;
|
|
14
|
-
var date = toDate(dirtyDate);
|
|
15
|
-
var currentDay = date.getUTCDay();
|
|
16
|
-
var remainder = day % 7;
|
|
17
|
-
var dayIndex = (remainder + 7) % 7;
|
|
18
|
-
var diff = (dayIndex < weekStartsOn ? 7 : 0) + day - currentDay;
|
|
19
|
-
date.setUTCDate(date.getUTCDate() + diff);
|
|
20
|
-
return date;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { setUTCISODay as default };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import toInteger from '../toInteger/index.js';
|
|
2
|
-
import toDate from '../../toDate/index.js';
|
|
3
|
-
import getUTCISOWeek from '../getUTCISOWeek/index.js';
|
|
4
|
-
import requiredArgs from '../requiredArgs/index.js';
|
|
5
|
-
|
|
6
|
-
function setUTCISOWeek(dirtyDate, dirtyISOWeek) {
|
|
7
|
-
requiredArgs(2, arguments);
|
|
8
|
-
var date = toDate(dirtyDate);
|
|
9
|
-
var isoWeek = toInteger(dirtyISOWeek);
|
|
10
|
-
var diff = getUTCISOWeek(date) - isoWeek;
|
|
11
|
-
date.setUTCDate(date.getUTCDate() - diff * 7);
|
|
12
|
-
return date;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { setUTCISOWeek as default };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import toInteger from '../toInteger/index.js';
|
|
2
|
-
import toDate from '../../toDate/index.js';
|
|
3
|
-
import getUTCWeek from '../getUTCWeek/index.js';
|
|
4
|
-
import requiredArgs from '../requiredArgs/index.js';
|
|
5
|
-
|
|
6
|
-
function setUTCWeek(dirtyDate, dirtyWeek, options) {
|
|
7
|
-
requiredArgs(2, arguments);
|
|
8
|
-
var date = toDate(dirtyDate);
|
|
9
|
-
var week = toInteger(dirtyWeek);
|
|
10
|
-
var diff = getUTCWeek(date, options) - week;
|
|
11
|
-
date.setUTCDate(date.getUTCDate() - diff * 7);
|
|
12
|
-
return date;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { setUTCWeek as default };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import toDate from '../../toDate/index.js';
|
|
2
|
-
import requiredArgs from '../requiredArgs/index.js';
|
|
3
|
-
|
|
4
|
-
function startOfUTCISOWeek(dirtyDate) {
|
|
5
|
-
requiredArgs(1, arguments);
|
|
6
|
-
var weekStartsOn = 1;
|
|
7
|
-
var date = toDate(dirtyDate);
|
|
8
|
-
var day = date.getUTCDay();
|
|
9
|
-
var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
|
|
10
|
-
date.setUTCDate(date.getUTCDate() - diff);
|
|
11
|
-
date.setUTCHours(0, 0, 0, 0);
|
|
12
|
-
return date;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { startOfUTCISOWeek as default };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import getUTCISOWeekYear from '../getUTCISOWeekYear/index.js';
|
|
2
|
-
import startOfUTCISOWeek from '../startOfUTCISOWeek/index.js';
|
|
3
|
-
import requiredArgs from '../requiredArgs/index.js';
|
|
4
|
-
|
|
5
|
-
function startOfUTCISOWeekYear(dirtyDate) {
|
|
6
|
-
requiredArgs(1, arguments);
|
|
7
|
-
var year = getUTCISOWeekYear(dirtyDate);
|
|
8
|
-
var fourthOfJanuary = new Date(0);
|
|
9
|
-
fourthOfJanuary.setUTCFullYear(year, 0, 4);
|
|
10
|
-
fourthOfJanuary.setUTCHours(0, 0, 0, 0);
|
|
11
|
-
var date = startOfUTCISOWeek(fourthOfJanuary);
|
|
12
|
-
return date;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { startOfUTCISOWeekYear as default };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import toDate from '../../toDate/index.js';
|
|
2
|
-
import requiredArgs from '../requiredArgs/index.js';
|
|
3
|
-
import toInteger from '../toInteger/index.js';
|
|
4
|
-
import { getDefaultOptions } from '../defaultOptions/index.js';
|
|
5
|
-
|
|
6
|
-
function startOfUTCWeek(dirtyDate, options) {
|
|
7
|
-
var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
|
|
8
|
-
|
|
9
|
-
requiredArgs(1, arguments);
|
|
10
|
-
var defaultOptions = getDefaultOptions();
|
|
11
|
-
var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0); // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
|
|
12
|
-
|
|
13
|
-
if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
|
|
14
|
-
throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
var date = toDate(dirtyDate);
|
|
18
|
-
var day = date.getUTCDay();
|
|
19
|
-
var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
|
|
20
|
-
date.setUTCDate(date.getUTCDate() - diff);
|
|
21
|
-
date.setUTCHours(0, 0, 0, 0);
|
|
22
|
-
return date;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { startOfUTCWeek as default };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import getUTCWeekYear from '../getUTCWeekYear/index.js';
|
|
2
|
-
import requiredArgs from '../requiredArgs/index.js';
|
|
3
|
-
import startOfUTCWeek from '../startOfUTCWeek/index.js';
|
|
4
|
-
import toInteger from '../toInteger/index.js';
|
|
5
|
-
import { getDefaultOptions } from '../defaultOptions/index.js';
|
|
6
|
-
|
|
7
|
-
function startOfUTCWeekYear(dirtyDate, options) {
|
|
8
|
-
var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
|
|
9
|
-
|
|
10
|
-
requiredArgs(1, arguments);
|
|
11
|
-
var defaultOptions = getDefaultOptions();
|
|
12
|
-
var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);
|
|
13
|
-
var year = getUTCWeekYear(dirtyDate, options);
|
|
14
|
-
var firstWeek = new Date(0);
|
|
15
|
-
firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
|
|
16
|
-
firstWeek.setUTCHours(0, 0, 0, 0);
|
|
17
|
-
var date = startOfUTCWeek(firstWeek, options);
|
|
18
|
-
return date;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export { startOfUTCWeekYear as default };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
function toInteger(dirtyNumber) {
|
|
2
|
-
if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
|
|
3
|
-
return NaN;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
var number = Number(dirtyNumber);
|
|
7
|
-
|
|
8
|
-
if (isNaN(number)) {
|
|
9
|
-
return number;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return number < 0 ? Math.ceil(number) : Math.floor(number);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { toInteger as default };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import toDate from '../toDate/index.js';
|
|
2
|
-
import requiredArgs from '../_lib/requiredArgs/index.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @name compareAsc
|
|
6
|
-
* @category Common Helpers
|
|
7
|
-
* @summary Compare the two dates and return -1, 0 or 1.
|
|
8
|
-
*
|
|
9
|
-
* @description
|
|
10
|
-
* Compare the two dates and return 1 if the first date is after the second,
|
|
11
|
-
* -1 if the first date is before the second or 0 if dates are equal.
|
|
12
|
-
*
|
|
13
|
-
* @param {Date|Number} dateLeft - the first date to compare
|
|
14
|
-
* @param {Date|Number} dateRight - the second date to compare
|
|
15
|
-
* @returns {Number} the result of the comparison
|
|
16
|
-
* @throws {TypeError} 2 arguments required
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* // Compare 11 February 1987 and 10 July 1989:
|
|
20
|
-
* const result = compareAsc(new Date(1987, 1, 11), new Date(1989, 6, 10))
|
|
21
|
-
* //=> -1
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* // Sort the array of dates:
|
|
25
|
-
* const result = [
|
|
26
|
-
* new Date(1995, 6, 2),
|
|
27
|
-
* new Date(1987, 1, 11),
|
|
28
|
-
* new Date(1989, 6, 10)
|
|
29
|
-
* ].sort(compareAsc)
|
|
30
|
-
* //=> [
|
|
31
|
-
* // Wed Feb 11 1987 00:00:00,
|
|
32
|
-
* // Mon Jul 10 1989 00:00:00,
|
|
33
|
-
* // Sun Jul 02 1995 00:00:00
|
|
34
|
-
* // ]
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
function compareAsc(dirtyDateLeft, dirtyDateRight) {
|
|
38
|
-
requiredArgs(2, arguments);
|
|
39
|
-
var dateLeft = toDate(dirtyDateLeft);
|
|
40
|
-
var dateRight = toDate(dirtyDateRight);
|
|
41
|
-
var diff = dateLeft.getTime() - dateRight.getTime();
|
|
42
|
-
|
|
43
|
-
if (diff < 0) {
|
|
44
|
-
return -1;
|
|
45
|
-
} else if (diff > 0) {
|
|
46
|
-
return 1; // Return 0 if diff is 0; return NaN if diff is NaN
|
|
47
|
-
} else {
|
|
48
|
-
return diff;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export { compareAsc as default };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Days in 1 week.
|
|
3
|
-
*
|
|
4
|
-
* @name daysInWeek
|
|
5
|
-
* @constant
|
|
6
|
-
* @type {number}
|
|
7
|
-
* @default
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Milliseconds in 1 minute
|
|
11
|
-
*
|
|
12
|
-
* @name millisecondsInMinute
|
|
13
|
-
* @constant
|
|
14
|
-
* @type {number}
|
|
15
|
-
* @default
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
var millisecondsInMinute = 60000;
|
|
19
|
-
/**
|
|
20
|
-
* Milliseconds in 1 hour
|
|
21
|
-
*
|
|
22
|
-
* @name millisecondsInHour
|
|
23
|
-
* @constant
|
|
24
|
-
* @type {number}
|
|
25
|
-
* @default
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
var millisecondsInHour = 3600000;
|
|
29
|
-
/**
|
|
30
|
-
* Milliseconds in 1 second
|
|
31
|
-
*
|
|
32
|
-
* @name millisecondsInSecond
|
|
33
|
-
* @constant
|
|
34
|
-
* @type {number}
|
|
35
|
-
* @default
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
var millisecondsInSecond = 1000;
|
|
39
|
-
|
|
40
|
-
export { millisecondsInHour, millisecondsInMinute, millisecondsInSecond };
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import getTimezoneOffsetInMilliseconds from '../_lib/getTimezoneOffsetInMilliseconds/index.js';
|
|
2
|
-
import startOfDay from '../startOfDay/index.js';
|
|
3
|
-
import requiredArgs from '../_lib/requiredArgs/index.js';
|
|
4
|
-
|
|
5
|
-
var MILLISECONDS_IN_DAY = 86400000;
|
|
6
|
-
/**
|
|
7
|
-
* @name differenceInCalendarDays
|
|
8
|
-
* @category Day Helpers
|
|
9
|
-
* @summary Get the number of calendar days between the given dates.
|
|
10
|
-
*
|
|
11
|
-
* @description
|
|
12
|
-
* Get the number of calendar days between the given dates. This means that the times are removed
|
|
13
|
-
* from the dates and then the difference in days is calculated.
|
|
14
|
-
*
|
|
15
|
-
* @param {Date|Number} dateLeft - the later date
|
|
16
|
-
* @param {Date|Number} dateRight - the earlier date
|
|
17
|
-
* @returns {Number} the number of calendar days
|
|
18
|
-
* @throws {TypeError} 2 arguments required
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* // How many calendar days are between
|
|
22
|
-
* // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
|
|
23
|
-
* const result = differenceInCalendarDays(
|
|
24
|
-
* new Date(2012, 6, 2, 0, 0),
|
|
25
|
-
* new Date(2011, 6, 2, 23, 0)
|
|
26
|
-
* )
|
|
27
|
-
* //=> 366
|
|
28
|
-
* // How many calendar days are between
|
|
29
|
-
* // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
|
|
30
|
-
* const result = differenceInCalendarDays(
|
|
31
|
-
* new Date(2011, 6, 3, 0, 1),
|
|
32
|
-
* new Date(2011, 6, 2, 23, 59)
|
|
33
|
-
* )
|
|
34
|
-
* //=> 1
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
function differenceInCalendarDays(dirtyDateLeft, dirtyDateRight) {
|
|
38
|
-
requiredArgs(2, arguments);
|
|
39
|
-
var startOfDayLeft = startOfDay(dirtyDateLeft);
|
|
40
|
-
var startOfDayRight = startOfDay(dirtyDateRight);
|
|
41
|
-
var timestampLeft = startOfDayLeft.getTime() - getTimezoneOffsetInMilliseconds(startOfDayLeft);
|
|
42
|
-
var timestampRight = startOfDayRight.getTime() - getTimezoneOffsetInMilliseconds(startOfDayRight); // Round the number of days to the nearest integer
|
|
43
|
-
// because the number of milliseconds in a day is not constant
|
|
44
|
-
// (e.g. it's different in the day of the daylight saving time clock shift)
|
|
45
|
-
|
|
46
|
-
return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export { differenceInCalendarDays as default };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import toDate from '../toDate/index.js';
|
|
2
|
-
import requiredArgs from '../_lib/requiredArgs/index.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @name differenceInCalendarMonths
|
|
6
|
-
* @category Month Helpers
|
|
7
|
-
* @summary Get the number of calendar months between the given dates.
|
|
8
|
-
*
|
|
9
|
-
* @description
|
|
10
|
-
* Get the number of calendar months between the given dates.
|
|
11
|
-
*
|
|
12
|
-
* @param {Date|Number} dateLeft - the later date
|
|
13
|
-
* @param {Date|Number} dateRight - the earlier date
|
|
14
|
-
* @returns {Number} the number of calendar months
|
|
15
|
-
* @throws {TypeError} 2 arguments required
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* // How many calendar months are between 31 January 2014 and 1 September 2014?
|
|
19
|
-
* const result = differenceInCalendarMonths(
|
|
20
|
-
* new Date(2014, 8, 1),
|
|
21
|
-
* new Date(2014, 0, 31)
|
|
22
|
-
* )
|
|
23
|
-
* //=> 8
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
function differenceInCalendarMonths(dirtyDateLeft, dirtyDateRight) {
|
|
27
|
-
requiredArgs(2, arguments);
|
|
28
|
-
var dateLeft = toDate(dirtyDateLeft);
|
|
29
|
-
var dateRight = toDate(dirtyDateRight);
|
|
30
|
-
var yearDiff = dateLeft.getFullYear() - dateRight.getFullYear();
|
|
31
|
-
var monthDiff = dateLeft.getMonth() - dateRight.getMonth();
|
|
32
|
-
return yearDiff * 12 + monthDiff;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { differenceInCalendarMonths as default };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import toDate from '../toDate/index.js';
|
|
2
|
-
import requiredArgs from '../_lib/requiredArgs/index.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @name differenceInCalendarYears
|
|
6
|
-
* @category Year Helpers
|
|
7
|
-
* @summary Get the number of calendar years between the given dates.
|
|
8
|
-
*
|
|
9
|
-
* @description
|
|
10
|
-
* Get the number of calendar years between the given dates.
|
|
11
|
-
*
|
|
12
|
-
* @param {Date|Number} dateLeft - the later date
|
|
13
|
-
* @param {Date|Number} dateRight - the earlier date
|
|
14
|
-
* @returns {Number} the number of calendar years
|
|
15
|
-
* @throws {TypeError} 2 arguments required
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* // How many calendar years are between 31 December 2013 and 11 February 2015?
|
|
19
|
-
* const result = differenceInCalendarYears(
|
|
20
|
-
* new Date(2015, 1, 11),
|
|
21
|
-
* new Date(2013, 11, 31)
|
|
22
|
-
* )
|
|
23
|
-
* //=> 2
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
function differenceInCalendarYears(dirtyDateLeft, dirtyDateRight) {
|
|
27
|
-
requiredArgs(2, arguments);
|
|
28
|
-
var dateLeft = toDate(dirtyDateLeft);
|
|
29
|
-
var dateRight = toDate(dirtyDateRight);
|
|
30
|
-
return dateLeft.getFullYear() - dateRight.getFullYear();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export { differenceInCalendarYears as default };
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import toDate from '../toDate/index.js';
|
|
2
|
-
import differenceInCalendarDays from '../differenceInCalendarDays/index.js';
|
|
3
|
-
import requiredArgs from '../_lib/requiredArgs/index.js';
|
|
4
|
-
|
|
5
|
-
// for accurate equality comparisons of UTC timestamps that end up
|
|
6
|
-
// having the same representation in local time, e.g. one hour before
|
|
7
|
-
// DST ends vs. the instant that DST ends.
|
|
8
|
-
|
|
9
|
-
function compareLocalAsc(dateLeft, dateRight) {
|
|
10
|
-
var diff = dateLeft.getFullYear() - dateRight.getFullYear() || dateLeft.getMonth() - dateRight.getMonth() || dateLeft.getDate() - dateRight.getDate() || dateLeft.getHours() - dateRight.getHours() || dateLeft.getMinutes() - dateRight.getMinutes() || dateLeft.getSeconds() - dateRight.getSeconds() || dateLeft.getMilliseconds() - dateRight.getMilliseconds();
|
|
11
|
-
|
|
12
|
-
if (diff < 0) {
|
|
13
|
-
return -1;
|
|
14
|
-
} else if (diff > 0) {
|
|
15
|
-
return 1; // Return 0 if diff is 0; return NaN if diff is NaN
|
|
16
|
-
} else {
|
|
17
|
-
return diff;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* @name differenceInDays
|
|
22
|
-
* @category Day Helpers
|
|
23
|
-
* @summary Get the number of full days between the given dates.
|
|
24
|
-
*
|
|
25
|
-
* @description
|
|
26
|
-
* Get the number of full day periods between two dates. Fractional days are
|
|
27
|
-
* truncated towards zero.
|
|
28
|
-
*
|
|
29
|
-
* One "full day" is the distance between a local time in one day to the same
|
|
30
|
-
* local time on the next or previous day. A full day can sometimes be less than
|
|
31
|
-
* or more than 24 hours if a daylight savings change happens between two dates.
|
|
32
|
-
*
|
|
33
|
-
* To ignore DST and only measure exact 24-hour periods, use this instead:
|
|
34
|
-
* `Math.floor(differenceInHours(dateLeft, dateRight)/24)|0`.
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* @param {Date|Number} dateLeft - the later date
|
|
38
|
-
* @param {Date|Number} dateRight - the earlier date
|
|
39
|
-
* @returns {Number} the number of full days according to the local timezone
|
|
40
|
-
* @throws {TypeError} 2 arguments required
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* // How many full days are between
|
|
44
|
-
* // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
|
|
45
|
-
* const result = differenceInDays(
|
|
46
|
-
* new Date(2012, 6, 2, 0, 0),
|
|
47
|
-
* new Date(2011, 6, 2, 23, 0)
|
|
48
|
-
* )
|
|
49
|
-
* //=> 365
|
|
50
|
-
* // How many full days are between
|
|
51
|
-
* // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
|
|
52
|
-
* const result = differenceInDays(
|
|
53
|
-
* new Date(2011, 6, 3, 0, 1),
|
|
54
|
-
* new Date(2011, 6, 2, 23, 59)
|
|
55
|
-
* )
|
|
56
|
-
* //=> 0
|
|
57
|
-
* // How many full days are between
|
|
58
|
-
* // 1 March 2020 0:00 and 1 June 2020 0:00 ?
|
|
59
|
-
* // Note: because local time is used, the
|
|
60
|
-
* // result will always be 92 days, even in
|
|
61
|
-
* // time zones where DST starts and the
|
|
62
|
-
* // period has only 92*24-1 hours.
|
|
63
|
-
* const result = differenceInDays(
|
|
64
|
-
* new Date(2020, 5, 1),
|
|
65
|
-
* new Date(2020, 2, 1)
|
|
66
|
-
* )
|
|
67
|
-
//=> 92
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
function differenceInDays(dirtyDateLeft, dirtyDateRight) {
|
|
72
|
-
requiredArgs(2, arguments);
|
|
73
|
-
var dateLeft = toDate(dirtyDateLeft);
|
|
74
|
-
var dateRight = toDate(dirtyDateRight);
|
|
75
|
-
var sign = compareLocalAsc(dateLeft, dateRight);
|
|
76
|
-
var difference = Math.abs(differenceInCalendarDays(dateLeft, dateRight));
|
|
77
|
-
dateLeft.setDate(dateLeft.getDate() - sign * difference); // Math.abs(diff in full days - diff in calendar days) === 1 if last calendar day is not full
|
|
78
|
-
// If so, result must be decreased by 1 in absolute value
|
|
79
|
-
|
|
80
|
-
var isLastDayNotFull = Number(compareLocalAsc(dateLeft, dateRight) === -sign);
|
|
81
|
-
var result = sign * (difference - isLastDayNotFull); // Prevent negative zero
|
|
82
|
-
|
|
83
|
-
return result === 0 ? 0 : result;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export { differenceInDays as default };
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import toDate from '../toDate/index.js';
|
|
2
|
-
import differenceInCalendarMonths from '../differenceInCalendarMonths/index.js';
|
|
3
|
-
import compareAsc from '../compareAsc/index.js';
|
|
4
|
-
import requiredArgs from '../_lib/requiredArgs/index.js';
|
|
5
|
-
import isLastDayOfMonth from '../isLastDayOfMonth/index.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @name differenceInMonths
|
|
9
|
-
* @category Month Helpers
|
|
10
|
-
* @summary Get the number of full months between the given dates.
|
|
11
|
-
*
|
|
12
|
-
* @description
|
|
13
|
-
* Get the number of full months between the given dates using trunc as a default rounding method.
|
|
14
|
-
*
|
|
15
|
-
* @param {Date|Number} dateLeft - the later date
|
|
16
|
-
* @param {Date|Number} dateRight - the earlier date
|
|
17
|
-
* @returns {Number} the number of full months
|
|
18
|
-
* @throws {TypeError} 2 arguments required
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* // How many full months are between 31 January 2014 and 1 September 2014?
|
|
22
|
-
* const result = differenceInMonths(new Date(2014, 8, 1), new Date(2014, 0, 31))
|
|
23
|
-
* //=> 7
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
function differenceInMonths(dirtyDateLeft, dirtyDateRight) {
|
|
27
|
-
requiredArgs(2, arguments);
|
|
28
|
-
var dateLeft = toDate(dirtyDateLeft);
|
|
29
|
-
var dateRight = toDate(dirtyDateRight);
|
|
30
|
-
var sign = compareAsc(dateLeft, dateRight);
|
|
31
|
-
var difference = Math.abs(differenceInCalendarMonths(dateLeft, dateRight));
|
|
32
|
-
var result; // Check for the difference of less than month
|
|
33
|
-
|
|
34
|
-
if (difference < 1) {
|
|
35
|
-
result = 0;
|
|
36
|
-
} else {
|
|
37
|
-
if (dateLeft.getMonth() === 1 && dateLeft.getDate() > 27) {
|
|
38
|
-
// This will check if the date is end of Feb and assign a higher end of month date
|
|
39
|
-
// to compare it with Jan
|
|
40
|
-
dateLeft.setDate(30);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
dateLeft.setMonth(dateLeft.getMonth() - sign * difference); // Math.abs(diff in full months - diff in calendar months) === 1 if last calendar month is not full
|
|
44
|
-
// If so, result must be decreased by 1 in absolute value
|
|
45
|
-
|
|
46
|
-
var isLastMonthNotFull = compareAsc(dateLeft, dateRight) === -sign; // Check for cases of one full calendar month
|
|
47
|
-
|
|
48
|
-
if (isLastDayOfMonth(toDate(dirtyDateLeft)) && difference === 1 && compareAsc(dirtyDateLeft, dateRight) === 1) {
|
|
49
|
-
isLastMonthNotFull = false;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
result = sign * (difference - Number(isLastMonthNotFull));
|
|
53
|
-
} // Prevent negative zero
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return result === 0 ? 0 : result;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export { differenceInMonths as default };
|