@opengeoweb/shared 9.28.1 → 9.29.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/index.esm.js +512 -491
- package/package.json +2 -2
- package/src/index.d.ts +7 -7
- package/src/lib/components/AlertBanner/AlertBanner.d.ts +16 -16
- package/src/lib/components/AlertBanner/AlertBanner.spec.d.ts +1 -1
- package/src/lib/components/AlertBanner/AlertBanner.stories.d.ts +13 -13
- package/src/lib/components/AlertBanner/index.d.ts +1 -1
- package/src/lib/components/AlertIcon/AlertIcon.d.ts +8 -8
- package/src/lib/components/AlertIcon/index.d.ts +1 -1
- package/src/lib/components/AppHeader/AppHeader.d.ts +10 -10
- package/src/lib/components/AppHeader/AppHeader.spec.d.ts +1 -1
- package/src/lib/components/AppHeader/AppHeader.stories.d.ts +25 -25
- package/src/lib/components/AppHeader/index.d.ts +1 -1
- package/src/lib/components/AppLayout/AppLayout.d.ts +7 -7
- package/src/lib/components/AppLayout/AppLayout.spec.d.ts +1 -1
- package/src/lib/components/AppLayout/AppLayout.stories.d.ts +7 -7
- package/src/lib/components/AppLayout/index.d.ts +1 -1
- package/src/lib/components/Avatar/Avatar.d.ts +7 -7
- package/src/lib/components/Avatar/Avatar.stories.d.ts +25 -25
- package/src/lib/components/Avatar/index.d.ts +1 -1
- package/src/lib/components/CanvasComponent/CanvasComponent.d.ts +71 -71
- package/src/lib/components/CanvasComponent/CanvasComponent.spec.d.ts +1 -1
- package/src/lib/components/CanvasComponent/CanvasComponent.stories.d.ts +7 -7
- package/src/lib/components/CanvasComponent/index.d.ts +1 -1
- package/src/lib/components/ConfirmationDialog/ConfirmationDialog.d.ts +22 -22
- package/src/lib/components/ConfirmationDialog/ConfirmationDialog.spec.d.ts +1 -1
- package/src/lib/components/ConfirmationDialog/ConfirmationDialog.stories.d.ts +15 -15
- package/src/lib/components/ConfirmationDialog/ConfirmationService.d.ts +18 -18
- package/src/lib/components/ConfirmationDialog/ConfirmationService.spec.d.ts +1 -1
- package/src/lib/components/ConfirmationDialog/index.d.ts +2 -2
- package/src/lib/components/CustomAccordion/CustomAccordion.d.ts +13 -12
- package/src/lib/components/CustomAccordion/CustomAccordion.spec.d.ts +1 -1
- package/src/lib/components/CustomAccordion/CustomAccordion.stories.d.ts +13 -13
- package/src/lib/components/CustomAccordion/index.d.ts +1 -1
- package/src/lib/components/CustomDialog/CustomDialog.d.ts +10 -10
- package/src/lib/components/CustomDialog/CustomDialog.spec.d.ts +1 -1
- package/src/lib/components/CustomDialog/CustomDialog.stories.d.ts +13 -13
- package/src/lib/components/CustomDialog/index.d.ts +1 -1
- package/src/lib/components/CustomIconButton/CustomIconButton.d.ts +13 -13
- package/src/lib/components/CustomIconButton/CustomIconButton.spec.d.ts +1 -1
- package/src/lib/components/CustomIconButton/CustomIconButton.stories.d.ts +25 -25
- package/src/lib/components/CustomIconButton/index.d.ts +1 -1
- package/src/lib/components/CustomSlider/CustomSlider.d.ts +14 -14
- package/src/lib/components/CustomSlider/CustomSlider.spec.d.ts +1 -1
- package/src/lib/components/CustomSlider/CustomSlider.stories.d.ts +13 -13
- package/src/lib/components/CustomSlider/index.d.ts +1 -1
- package/src/lib/components/CustomToggleButton/CustomToggleButton.d.ts +8 -8
- package/src/lib/components/CustomToggleButton/CustomToggleButton.spec.d.ts +1 -1
- package/src/lib/components/CustomToggleButton/CustomToggleButton.stories.d.ts +13 -13
- package/src/lib/components/CustomToggleButton/index.d.ts +1 -1
- package/src/lib/components/CustomTooltip/CustomTooltip.d.ts +8 -8
- package/src/lib/components/CustomTooltip/CustomTooltip.spec.d.ts +1 -1
- package/src/lib/components/CustomTooltip/index.d.ts +1 -1
- package/src/lib/components/DraggableResizable/Draggable.d.ts +15 -15
- package/src/lib/components/DraggableResizable/Draggable.spec.d.ts +1 -1
- package/src/lib/components/DraggableResizable/Resizable.d.ts +10 -10
- package/src/lib/components/DraggableResizable/Resizable.spec.d.ts +1 -1
- package/src/lib/components/DraggableResizable/index.d.ts +3 -3
- package/src/lib/components/DraggableResizable/types.d.ts +27 -27
- package/src/lib/components/ErrorBoundary/ErrorBoundary.d.ts +31 -31
- package/src/lib/components/ErrorBoundary/ErrorBoundary.spec.d.ts +1 -1
- package/src/lib/components/ErrorBoundary/ErrorBoundary.stories.d.ts +10 -10
- package/src/lib/components/ErrorBoundary/index.d.ts +1 -1
- package/src/lib/components/Filter/Filter.d.ts +13 -13
- package/src/lib/components/Filter/Filter.spec.d.ts +1 -1
- package/src/lib/components/Filter/Filter.stories.d.ts +25 -25
- package/src/lib/components/Filter/FilterChip.d.ts +13 -13
- package/src/lib/components/Filter/FilterChip.spec.d.ts +1 -1
- package/src/lib/components/Filter/FilterList.d.ts +15 -15
- package/src/lib/components/Filter/FilterList.spec.d.ts +1 -1
- package/src/lib/components/Filter/FilterListItem.d.ts +17 -17
- package/src/lib/components/Filter/FilterListItem.spec.d.ts +1 -1
- package/src/lib/components/Filter/FilterListItem.stories.d.ts +7 -7
- package/src/lib/components/Filter/SearchField.d.ts +8 -8
- package/src/lib/components/Filter/SearchField.spec.d.ts +1 -1
- package/src/lib/components/Filter/index.d.ts +8 -8
- package/src/lib/components/LastUpdateTime/LastUpdateTime.d.ts +10 -10
- package/src/lib/components/LastUpdateTime/LastUpdateTime.spec.d.ts +1 -1
- package/src/lib/components/LastUpdateTime/LastUpdateTime.stories.d.ts +13 -13
- package/src/lib/components/LastUpdateTime/index.d.ts +1 -1
- package/src/lib/components/Providers/Providers.d.ts +14 -14
- package/src/lib/components/Providers/index.d.ts +1 -1
- package/src/lib/components/SearchField/SearchField.d.ts +9 -9
- package/src/lib/components/SearchField/SearchField.spec.d.ts +1 -1
- package/src/lib/components/SearchField/SearchFieldButtonContainer.d.ts +9 -9
- package/src/lib/components/SearchField/SearchFieldButtonContainer.spec.d.ts +1 -1
- package/src/lib/components/SearchField/index.d.ts +2 -2
- package/src/lib/components/SearchHighlight/SearchHighlight.d.ts +7 -7
- package/src/lib/components/SearchHighlight/SearchHighlight.spec.d.ts +1 -1
- package/src/lib/components/SearchHighlight/SearchHighlight.stories.d.ts +13 -13
- package/src/lib/components/SearchHighlight/index.d.ts +1 -1
- package/src/lib/components/StatusTag/StatusTag.d.ts +9 -9
- package/src/lib/components/StatusTag/StatusTag.spec.d.ts +1 -1
- package/src/lib/components/StatusTag/StatusTag.stories.d.ts +25 -25
- package/src/lib/components/StatusTag/index.d.ts +1 -1
- package/src/lib/components/SwitchButton/SwitchButton.d.ts +8 -8
- package/src/lib/components/SwitchButton/SwitchButton.spec.d.ts +1 -1
- package/src/lib/components/SwitchButton/index.d.ts +1 -1
- package/src/lib/components/ToggleMenu/ToggleMenu.d.ts +30 -30
- package/src/lib/components/ToggleMenu/ToggleMenu.spec.d.ts +1 -1
- package/src/lib/components/ToggleMenu/ToggleMenu.stories.d.ts +13 -13
- package/src/lib/components/ToggleMenu/index.d.ts +1 -1
- package/src/lib/components/ToolContainer/ToolContainer.d.ts +5 -5
- package/src/lib/components/ToolContainer/ToolContainer.spec.d.ts +1 -1
- package/src/lib/components/ToolContainer/ToolContainer.stories.d.ts +28 -28
- package/src/lib/components/ToolContainer/ToolContainerDraggable.d.ts +37 -37
- package/src/lib/components/ToolContainer/ToolContainerDraggable.spec.d.ts +1 -1
- package/src/lib/components/ToolContainer/ToolContainerDraggable.stories.d.ts +7 -7
- package/src/lib/components/ToolContainer/ToolContainerSnapShots.stories.d.ts +13 -13
- package/src/lib/components/ToolContainer/ToolFooter.d.ts +3 -3
- package/src/lib/components/ToolContainer/ToolFooter.spec.d.ts +1 -1
- package/src/lib/components/ToolContainer/ToolHeader.d.ts +4 -4
- package/src/lib/components/ToolContainer/ToolHeader.spec.d.ts +1 -1
- package/src/lib/components/ToolContainer/ToolHeader.stories.d.ts +23 -23
- package/src/lib/components/ToolContainer/index.d.ts +7 -7
- package/src/lib/components/ToolContainer/types.d.ts +20 -20
- package/src/lib/components/ToolContainer/useHandleSizeFromOutsideComponent.d.ts +15 -15
- package/src/lib/components/ToolContainer/useHandleSizeFromOutsideComponent.spec.d.ts +1 -1
- package/src/lib/components/TooltipSelect/TooltipSelect.d.ts +20 -20
- package/src/lib/components/TooltipSelect/TooltipSelect.spec.d.ts +1 -1
- package/src/lib/components/TooltipSelect/TooltipSelect.stories.d.ts +13 -13
- package/src/lib/components/TooltipSelect/index.d.ts +1 -1
- package/src/lib/components/UserMenu/CheatSheet/CheatSheet.d.ts +3 -3
- package/src/lib/components/UserMenu/CheatSheet/CheatSheet.spec.d.ts +1 -1
- package/src/lib/components/UserMenu/CheatSheet/CheatSheet.stories.d.ts +31 -31
- package/src/lib/components/UserMenu/CheatSheet/ShortcutList.d.ts +6 -6
- package/src/lib/components/UserMenu/CheatSheet/ShortcutList.spec.d.ts +1 -1
- package/src/lib/components/UserMenu/CheatSheet/ShortcutSegment.d.ts +7 -7
- package/src/lib/components/UserMenu/CheatSheet/ShortcutSegment.spec.d.ts +1 -1
- package/src/lib/components/UserMenu/UserMenu.d.ts +11 -11
- package/src/lib/components/UserMenu/UserMenu.spec.d.ts +1 -1
- package/src/lib/components/UserMenu/UserMenu.stories.d.ts +15 -15
- package/src/lib/components/UserMenu/UserMenuItemCheatSheet.d.ts +3 -3
- package/src/lib/components/UserMenu/UserMenuItemCheatSheet.spec.d.ts +1 -1
- package/src/lib/components/UserMenu/UserMenuItemTheme.d.ts +3 -3
- package/src/lib/components/UserMenu/UserMenuItemTheme.spec.d.ts +1 -1
- package/src/lib/components/UserMenu/UserMenuSentryRecording.d.ts +7 -7
- package/src/lib/components/UserMenu/index.d.ts +6 -6
- package/src/lib/components/UserMenu/useUserMenu.d.ts +7 -7
- package/src/lib/components/UserMenu/useUserMenu.spec.d.ts +1 -1
- package/src/lib/components/UserMenu/utils.d.ts +1 -1
- package/src/lib/components/WithEggs/WithEggs.d.ts +7 -7
- package/src/lib/components/WithEggs/WithEggs.spec.d.ts +1 -1
- package/src/lib/components/WithEggs/index.d.ts +1 -1
- package/src/lib/components/components.stories.d.ts +5 -5
- package/src/lib/components/index.d.ts +26 -26
- package/src/lib/hooks/index.d.ts +6 -6
- package/src/lib/hooks/useDebounce/useDebounce.d.ts +1 -1
- package/src/lib/hooks/useDebounce/useDebounce.spec.d.ts +1 -1
- package/src/lib/hooks/useIsMounted/useIsMounted.d.ts +4 -4
- package/src/lib/hooks/useIsMounted/useIsMounted.spec.d.ts +1 -1
- package/src/lib/hooks/useMakeSureContainerStaysInsideWindow/useMakeSureContainerStaysInsideWindow.d.ts +4 -4
- package/src/lib/hooks/useMakeSureContainerStaysInsideWindow/useMakeSureContainerStaysInsideWindow.spec.d.ts +1 -1
- package/src/lib/hooks/usePoller/usePoller.d.ts +3 -3
- package/src/lib/hooks/usePoller/usePoller.spec.d.ts +1 -1
- package/src/lib/hooks/usePoller/usePoller.stories.d.ts +6 -6
- package/src/lib/hooks/usePreventBrowserClose/usePreventBrowserClose.d.ts +2 -2
- package/src/lib/hooks/usePreventBrowserClose/usePreventBrowserClose.spec.d.ts +1 -1
- package/src/lib/hooks/usePreventBrowserClose/usePreventBrowserClose.stories.d.ts +6 -6
- package/src/lib/hooks/usePrevious/usePrevious.d.ts +1 -1
- package/src/lib/hooks/usePrevious/usePrevious.spec.d.ts +1 -1
- package/src/lib/hooks/usePrevious/usePrevious.stories.d.ts +6 -6
- package/src/lib/types/index.d.ts +1 -1
- package/src/lib/types/types.d.ts +107 -108
- package/src/lib/utils/axiosErrorUtils/axiosErrorUtils.d.ts +8 -8
- package/src/lib/utils/axiosErrorUtils/axiosErrorUtils.spec.d.ts +1 -1
- package/src/lib/utils/axiosErrorUtils/index.d.ts +1 -1
- package/src/lib/utils/dateUtils/dateFormats.d.ts +7 -7
- package/src/lib/utils/dateUtils/dateUtils.d.ts +343 -343
- package/src/lib/utils/dateUtils/dateUtils.spec.d.ts +1 -1
- package/src/lib/utils/dateUtils/index.d.ts +2 -2
- package/src/lib/utils/i18n.d.ts +7 -7
- package/src/lib/utils/index.d.ts +5 -5
- package/src/lib/utils/mapProjections.d.ts +75 -75
- package/src/lib/utils/reduxTestUtils/createMockStoreWithEggs.d.ts +20 -20
- package/src/lib/utils/reduxTestUtils/createMockStoreWithEggs.spec.d.ts +1 -1
- package/src/lib/utils/reduxTestUtils/index.d.ts +1 -1
- package/src/lib/utils/renderCounter.d.ts +21 -21
- package/src/lib/utils/renderCounter.spec.d.ts +1 -1
|
@@ -1,343 +1,343 @@
|
|
|
1
|
-
import { parseISO, isEqual, Duration, startOfDay, isWithinInterval, getDayOfYear, getDay, getMonth, getYear, getWeek, NearestMinutes } from 'date-fns';
|
|
2
|
-
export interface DateValues {
|
|
3
|
-
year?: number;
|
|
4
|
-
month?: number;
|
|
5
|
-
date?: number;
|
|
6
|
-
hours?: number;
|
|
7
|
-
minutes?: number;
|
|
8
|
-
seconds?: number;
|
|
9
|
-
milliseconds?: number;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Parsing date strings with geoweb dateUtils:
|
|
13
|
-
*
|
|
14
|
-
* An ISO String *with timezone* can safely be parsed directly to a date:
|
|
15
|
-
*
|
|
16
|
-
* date = new Date('2022-10-10T15:30:00Z')
|
|
17
|
-
* date = new Date('2022-10-10T15:30:00+00:00')
|
|
18
|
-
* date = new Date('2022-10-10T15:30:00+02:00')
|
|
19
|
-
*
|
|
20
|
-
* or using the dateUtils isoStringToDate function *with utc=false*
|
|
21
|
-
*
|
|
22
|
-
* date = isoStringToDate('2022-10-10T15:30:00Z', false)
|
|
23
|
-
*
|
|
24
|
-
* An ISO String *without a timezone* can be parsed with isoStringToDate
|
|
25
|
-
*
|
|
26
|
-
* date = isoStringToDate('2022-10-10T15:30:00')
|
|
27
|
-
*
|
|
28
|
-
* *Do not parse ISO without timezone using `new Date()` unless you correct for the local timezone*
|
|
29
|
-
*
|
|
30
|
-
* To parse an arbitrary date string with timezone use:
|
|
31
|
-
*
|
|
32
|
-
* date = stringToDate('2022.11.10, 11:15 +01:00', 'yyyy.MM.dd, HH:mm xxx', false)
|
|
33
|
-
*
|
|
34
|
-
* To parse an arbitrary date string without timezone use:
|
|
35
|
-
*
|
|
36
|
-
* date = stringToDate('2022.11.10, 11:15', 'yyyy.MM.dd, HH:mm')
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* To safely convert dates to utc strings use:
|
|
40
|
-
*
|
|
41
|
-
* date.toISOString()
|
|
42
|
-
*
|
|
43
|
-
* To get parts of UTC time use
|
|
44
|
-
*
|
|
45
|
-
* date.getUTCHours()
|
|
46
|
-
* date.getUTCMins()
|
|
47
|
-
*
|
|
48
|
-
* To parse an arbitrary date string to a UTC string use:
|
|
49
|
-
*
|
|
50
|
-
* dateToString(new Date('2022-10-10T15:30:00Z'), 'HH:ss dd MMM yyyy')
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
|
-
/**
|
|
54
|
-
* Parse an ISO string to a date
|
|
55
|
-
*
|
|
56
|
-
* Expects the following props:
|
|
57
|
-
* @param {string} input - string containing date
|
|
58
|
-
*
|
|
59
|
-
* @returns {Date} Date
|
|
60
|
-
* @example
|
|
61
|
-
* ``` isoStringToDate("2022-5-10T20:32:00+00:00") ```
|
|
62
|
-
* ``` isoStringToDate("2022-5-10T20:32:00:00Z", false) ```
|
|
63
|
-
*/
|
|
64
|
-
export declare const isoStringToDate: (input: string, utc?: boolean) => Date | undefined;
|
|
65
|
-
export declare const isValidIsoDateString: (input: string) => boolean;
|
|
66
|
-
/**
|
|
67
|
-
* Parse a string to a date
|
|
68
|
-
*
|
|
69
|
-
* ***NOTE: String will be parsed in local time if utc is set to false***
|
|
70
|
-
*
|
|
71
|
-
* Expects the following props:
|
|
72
|
-
* @param {string} input - string containing date
|
|
73
|
-
* @param {string} strFormat - format of the string, see: https://date-fns.org/v2.29.3/docs/parse
|
|
74
|
-
* @param {boolean} utc [ default = true ] - boolean indicating whether to parse as UTC
|
|
75
|
-
* @param {Date} referenceDate [ default = new Date() ] - defines values missing from the parsed dateString
|
|
76
|
-
*
|
|
77
|
-
* @returns {Date} Date
|
|
78
|
-
* @example
|
|
79
|
-
* ``` stringToDate("2022 5 10 20:32", 'yyyy M d HH:mm')) ```
|
|
80
|
-
*/
|
|
81
|
-
export declare const stringToDate: (input: string | undefined, strFormat: string, utc?: boolean, referenceDate?: Date | number) => Date | undefined;
|
|
82
|
-
export declare const dateToIsoString: (input: Date | undefined) => string | undefined;
|
|
83
|
-
/**
|
|
84
|
-
* Use this if you initialise a date without a timezone to set it to utc correctly
|
|
85
|
-
* eg.
|
|
86
|
-
* new Date(2022, 10, 12, 15, 30)
|
|
87
|
-
* should be:
|
|
88
|
-
* setUTCDate(new Date(2022, 10, 12, 15, 30))
|
|
89
|
-
*
|
|
90
|
-
* Expects the following props:
|
|
91
|
-
* @param {Date} inDate - date to be set to UTC
|
|
92
|
-
*
|
|
93
|
-
* @returns {Date} - Date in UTC
|
|
94
|
-
* @example
|
|
95
|
-
* ``` setUTCDate(new Date(2022, 10, 12, 15, 30)) ```
|
|
96
|
-
*/
|
|
97
|
-
export declare const setUTCDate: (inDate: Date | undefined) => Date | undefined;
|
|
98
|
-
/**
|
|
99
|
-
* Format a date to a string
|
|
100
|
-
*
|
|
101
|
-
* Expects the following props:
|
|
102
|
-
* @param {Date} inDate - date to be formatted
|
|
103
|
-
* @param {string} strFormat - [default: "yyyy-MM-dd'T'HH:mm:ss'Z'"] format of string
|
|
104
|
-
* @param {boolean} utc - [default: true] true to return in utc otherwise return in local timezone
|
|
105
|
-
*
|
|
106
|
-
* @returns {string} - formatted date string
|
|
107
|
-
* @example
|
|
108
|
-
* ``` dateToString(new Date(2022, 10, 12, 15, 30), 'dd MMM yyyy') ```
|
|
109
|
-
*/
|
|
110
|
-
export declare const dateToString: (inDate: Date | undefined, strFormat?: string, utc?: boolean) => string | undefined;
|
|
111
|
-
/**
|
|
112
|
-
* Find out if a date is between two other dates.
|
|
113
|
-
*
|
|
114
|
-
* Inclusivity parameter matches that used in momentjs where '[' indicates inclusion and '(' indicates exclusion.
|
|
115
|
-
*
|
|
116
|
-
* Expects the following props:
|
|
117
|
-
* @param {Date} date - date to be tested
|
|
118
|
-
* @param {Date} from - first date
|
|
119
|
-
* @param {Date} to - last date
|
|
120
|
-
* @param {string} inclusivity - [default: '()'] Must be one of : '()', '[]', '(]', '[)'
|
|
121
|
-
*
|
|
122
|
-
* @returns {boolen} - true if date is between, otherwise false
|
|
123
|
-
*
|
|
124
|
-
*/
|
|
125
|
-
export declare const isBetween: (date: Date, from: Date, to: Date, inclusivity?: string) => boolean;
|
|
126
|
-
/**
|
|
127
|
-
* Creates a new Date object with the specified date and time, or the current date and time if no arguments are provided.
|
|
128
|
-
*
|
|
129
|
-
* @param yearOrIsoString The year for the new Date object, or an ISO-formatted string representing the date and time.
|
|
130
|
-
* @param month The month for the new Date object (0-11).
|
|
131
|
-
* @param day The day for the new Date object (1-31).
|
|
132
|
-
* @param hours The hour for the new Date object (0-23).
|
|
133
|
-
* @param minutes The minute for the new Date object (0-59).
|
|
134
|
-
* @param seconds The second for the new Date object (0-59).
|
|
135
|
-
* @param milliseconds The millisecond for the new Date object (0-999).
|
|
136
|
-
* @returns A new Date object with the specified date and time, or the current date and time if no arguments are provided.
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* createDate(2022, 11, 13);
|
|
140
|
-
* // => 2022-12-13T00:00:00.000Z
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
* createDate('2022-12-13T00:00:00.000Z');
|
|
144
|
-
* // => 2022-12-13T00:00:00.000Z
|
|
145
|
-
*/
|
|
146
|
-
export declare const createDate: (yearOrIsoString?: number | string, month?: number, day?: number, hours?: number, minutes?: number, seconds?: number, milliseconds?: number) => Date;
|
|
147
|
-
/**
|
|
148
|
-
*
|
|
149
|
-
* @param date
|
|
150
|
-
* @param duration
|
|
151
|
-
* @returns {Date} the new Date
|
|
152
|
-
*/
|
|
153
|
-
export declare const add: (date: Date | number, duration: Duration) => Date;
|
|
154
|
-
/**
|
|
155
|
-
*
|
|
156
|
-
* @param date
|
|
157
|
-
* @param duration
|
|
158
|
-
* @returns {Date} the new Date
|
|
159
|
-
*/
|
|
160
|
-
export declare const sub: (date: Date | number, duration: Duration) => Date;
|
|
161
|
-
/**
|
|
162
|
-
* Finds the number of years between to dates
|
|
163
|
-
*
|
|
164
|
-
* @param dateLeft - the later date
|
|
165
|
-
* @param dateRight - the earlier date
|
|
166
|
-
* @returns {number} the number of minutes
|
|
167
|
-
*/
|
|
168
|
-
export declare const differenceInYears: (dateLeft: Date | number, dateRight: Date | number) => number;
|
|
169
|
-
/**
|
|
170
|
-
* Finds the number of months between to dates
|
|
171
|
-
*
|
|
172
|
-
* @param dateLeft - the later date
|
|
173
|
-
* @param dateRight - the earlier date
|
|
174
|
-
* @returns {number} the number of minutes
|
|
175
|
-
*/
|
|
176
|
-
export declare const differenceInMonths: (dateLeft: Date | number | string, dateRight: Date | number | string) => number;
|
|
177
|
-
/**
|
|
178
|
-
* Finds the number of days between to dates
|
|
179
|
-
*
|
|
180
|
-
* @param dateLeft - the later date
|
|
181
|
-
* @param dateRight - the earlier date
|
|
182
|
-
* @returns {number} the number of minutes
|
|
183
|
-
*/
|
|
184
|
-
export declare const differenceInDays: (dateLeft: Date | number | string, dateRight: Date | number | string) => number;
|
|
185
|
-
/**
|
|
186
|
-
* Finds the number of minuts between to dates
|
|
187
|
-
*
|
|
188
|
-
* @param dateLeft - the later date
|
|
189
|
-
* @param dateRight - the earlier date
|
|
190
|
-
* @returns {number} the number of minutes
|
|
191
|
-
*/
|
|
192
|
-
export declare const differenceInMinutes: (dateLeft: Date | number, dateRight: Date | number) => number;
|
|
193
|
-
/**
|
|
194
|
-
* Finds the number of hours between to dates
|
|
195
|
-
*
|
|
196
|
-
* @param dateLeft - the later date
|
|
197
|
-
* @param dateRight - the earlier date
|
|
198
|
-
* @returns {number} the number of hours
|
|
199
|
-
*/
|
|
200
|
-
export declare const differenceInHours: (dateLeft: Date | number, dateRight: Date | number, roundingMethod?: 'ceil' | 'floor' | 'round' | 'trunc') => number;
|
|
201
|
-
/**
|
|
202
|
-
* Finds the number of seconds between to dates
|
|
203
|
-
*
|
|
204
|
-
* @param dateLeft - the later date
|
|
205
|
-
* @param dateRight - the earlier date
|
|
206
|
-
* @returns {number} the number of minutes
|
|
207
|
-
*/
|
|
208
|
-
export declare const differenceInSeconds: (dateLeft: Date | number, dateRight: Date | number) => number;
|
|
209
|
-
/**
|
|
210
|
-
*
|
|
211
|
-
* @param date - the date to be rounded
|
|
212
|
-
* @param options - the options for rounding
|
|
213
|
-
* @returns the new date
|
|
214
|
-
*/
|
|
215
|
-
export declare const roundToNearestMinutes: (date: Date | number, options: {
|
|
216
|
-
nearestTo: NearestMinutes;
|
|
217
|
-
}) => Date;
|
|
218
|
-
/**
|
|
219
|
-
*
|
|
220
|
-
* @param date - the date that should be before the other one to return true
|
|
221
|
-
* @param dateToCompare -the date to compare with
|
|
222
|
-
*
|
|
223
|
-
* @returns the first date is before the second date
|
|
224
|
-
*/
|
|
225
|
-
export declare const isBefore: (date: Date | number, dateToCompare: Date | number) => boolean;
|
|
226
|
-
/**
|
|
227
|
-
*
|
|
228
|
-
* @param date - the date that should be after the other one to return true
|
|
229
|
-
* @param dateToCompare -the date to compare with
|
|
230
|
-
*
|
|
231
|
-
* @returns the first date is after the second date
|
|
232
|
-
*/
|
|
233
|
-
export declare const isAfter: (date: Date | number, dateToCompare: Date | number) => boolean;
|
|
234
|
-
/**
|
|
235
|
-
* Gracefully parsing string to a date, setting tz to UTC even if it's missing or input is invalid
|
|
236
|
-
* Note: use getUtcFromString() to convert a string to a date with stricter returns
|
|
237
|
-
* @param dateStr - string containing date
|
|
238
|
-
* @returns {Date} - Date in UTC, or current date when something invalid is passed.
|
|
239
|
-
*/
|
|
240
|
-
export declare const utc: (dateStr?: string | undefined) => Date;
|
|
241
|
-
/**
|
|
242
|
-
* Parsing string to a date. Stricter check, will return undefined when dateString is invalid.
|
|
243
|
-
* @param dateStr - string containing date
|
|
244
|
-
* @returns {Date} - Date in UTC, undefined when not valid
|
|
245
|
-
*/
|
|
246
|
-
export declare const getUtcFromString: (dateStr: string | undefined | null) => Date | undefined;
|
|
247
|
-
/**
|
|
248
|
-
* Check if a date object is valid
|
|
249
|
-
* @param {Date | number} date - date to be checked
|
|
250
|
-
* @returns {boolean} - True if valid
|
|
251
|
-
*/
|
|
252
|
-
export declare const isValid: (date: Date | number) => boolean;
|
|
253
|
-
/**
|
|
254
|
-
* Get the seconds timestamp of the given date
|
|
255
|
-
* @param {Date} date - the given date
|
|
256
|
-
* @returns the timestamp
|
|
257
|
-
*/
|
|
258
|
-
export declare const unix: (date: Date | number) => number;
|
|
259
|
-
/**
|
|
260
|
-
* Return the Date object for a given timestamp
|
|
261
|
-
* @param {number} unixTime - timestamp
|
|
262
|
-
* @returns the timestamp
|
|
263
|
-
*/
|
|
264
|
-
export declare const fromUnix: (unixTime: number) => Date;
|
|
265
|
-
export declare const parseCustomDateString: (dateStr: string) => Date;
|
|
266
|
-
/**
|
|
267
|
-
* Returns Date in UTC
|
|
268
|
-
* @returns {Date} - Date in UTC
|
|
269
|
-
*/
|
|
270
|
-
export declare const getNowUtc: () => Date;
|
|
271
|
-
/**
|
|
272
|
-
* Returns current time as string
|
|
273
|
-
* @param {string} strFormat - [default: "yyyy-MM-dd'T'HH:mm:ss'Z'"] format of string
|
|
274
|
-
* @param {boolean} utc - [default: true] true to return in utc otherwise return in local timezone
|
|
275
|
-
*
|
|
276
|
-
* @returns {string} - formatted date string
|
|
277
|
-
*/
|
|
278
|
-
export declare const getCurrentTimeAsString: (strFormat?: string, utc?: boolean) => string;
|
|
279
|
-
/**
|
|
280
|
-
* Set date values to a given date (by default it is assumed you are passing the new values in UTC).
|
|
281
|
-
* Note that months start at 0!
|
|
282
|
-
* @param date - the dater to be changed
|
|
283
|
-
* @param values - an object with options
|
|
284
|
-
* @param useLocalTimeZone - boolean true if you are passing the values in local timezone
|
|
285
|
-
* @returns the new date with options set
|
|
286
|
-
*/
|
|
287
|
-
export declare const set: (date: Date, values: DateValues, useLocalTimeZone?: boolean) => Date;
|
|
288
|
-
/**
|
|
289
|
-
* Get hours of a passed date in UTC (or local timezone if passed false)
|
|
290
|
-
* @param date - the date of which to extract hours
|
|
291
|
-
* @param utc - boolean true - whether to get UTC hours
|
|
292
|
-
* @returns the hour number
|
|
293
|
-
*/
|
|
294
|
-
export declare const getHours: (date: Date, utc?: boolean) => number;
|
|
295
|
-
/**
|
|
296
|
-
* Return the start of hour for the given date. The result will be in UTC.
|
|
297
|
-
* @param date - the date of which to retrieve the start of the hour
|
|
298
|
-
* @returns the new date
|
|
299
|
-
*/
|
|
300
|
-
export declare const startOfHourUTC: (date: Date) => Date;
|
|
301
|
-
/**
|
|
302
|
-
* Return the start of a day for the given date. The result will be in UTC.
|
|
303
|
-
* @param date - the date of which to retrieve the start of day
|
|
304
|
-
* @returns the new date
|
|
305
|
-
*/
|
|
306
|
-
export declare const startOfDayUTC: (date: Date) => Date;
|
|
307
|
-
/**
|
|
308
|
-
* Return the start of a week for the given date. The result will be in UTC.
|
|
309
|
-
* @param date - the date of which to retrieve the start of the week
|
|
310
|
-
* @returns the new date
|
|
311
|
-
*/
|
|
312
|
-
export declare const startOfWeekUTC: (date: Date) => Date;
|
|
313
|
-
/**
|
|
314
|
-
* Return the start of a month for the given date. The result will be in UTC.
|
|
315
|
-
* @param date - the date of which to retrieve the start of the month
|
|
316
|
-
* @returns the new date
|
|
317
|
-
*/
|
|
318
|
-
export declare const startOfMonthUTC: (date: Date) => Date;
|
|
319
|
-
/**
|
|
320
|
-
* Return the start of a year for the given date. The result will be in UTC.
|
|
321
|
-
* @param date - the date of which to retrieve the start of the year
|
|
322
|
-
* @returns the new date
|
|
323
|
-
*/
|
|
324
|
-
export declare const startOfYearUTC: (date: Date) => Date;
|
|
325
|
-
/**
|
|
326
|
-
* Parse custom time format of NOW+current time | current date in UTC. The result will be in UTC.
|
|
327
|
-
* @param timeValue - string value
|
|
328
|
-
* @returns Time in UTC format
|
|
329
|
-
*/
|
|
330
|
-
export declare const convertNOWFormatToUTC: (timeValue: string) => string;
|
|
331
|
-
/**
|
|
332
|
-
* Parse custom time format of NOW+-hours and minutes || TODAY+-hours and minutes into UTC. The result will be in UTC.
|
|
333
|
-
* @param timeValue - string value
|
|
334
|
-
* @returns Time in UTC format
|
|
335
|
-
*/
|
|
336
|
-
export declare const convertNOWandTODAYFormatsToUTC: (timeValue: string) => string;
|
|
337
|
-
/**
|
|
338
|
-
* Compares two dates if values are the same
|
|
339
|
-
* @param {Date} date - first date
|
|
340
|
-
* @param {Date} date - second date
|
|
341
|
-
* @returns {boolean} - True if dates are equal
|
|
342
|
-
*/
|
|
343
|
-
export { isEqual, startOfDay, parseISO, isWithinInterval, getDayOfYear, getDay, getMonth, getYear, getWeek, };
|
|
1
|
+
import { parseISO, isEqual, Duration, startOfDay, isWithinInterval, getDayOfYear, getDay, getMonth, getYear, getWeek, NearestMinutes } from 'date-fns';
|
|
2
|
+
export interface DateValues {
|
|
3
|
+
year?: number;
|
|
4
|
+
month?: number;
|
|
5
|
+
date?: number;
|
|
6
|
+
hours?: number;
|
|
7
|
+
minutes?: number;
|
|
8
|
+
seconds?: number;
|
|
9
|
+
milliseconds?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Parsing date strings with geoweb dateUtils:
|
|
13
|
+
*
|
|
14
|
+
* An ISO String *with timezone* can safely be parsed directly to a date:
|
|
15
|
+
*
|
|
16
|
+
* date = new Date('2022-10-10T15:30:00Z')
|
|
17
|
+
* date = new Date('2022-10-10T15:30:00+00:00')
|
|
18
|
+
* date = new Date('2022-10-10T15:30:00+02:00')
|
|
19
|
+
*
|
|
20
|
+
* or using the dateUtils isoStringToDate function *with utc=false*
|
|
21
|
+
*
|
|
22
|
+
* date = isoStringToDate('2022-10-10T15:30:00Z', false)
|
|
23
|
+
*
|
|
24
|
+
* An ISO String *without a timezone* can be parsed with isoStringToDate
|
|
25
|
+
*
|
|
26
|
+
* date = isoStringToDate('2022-10-10T15:30:00')
|
|
27
|
+
*
|
|
28
|
+
* *Do not parse ISO without timezone using `new Date()` unless you correct for the local timezone*
|
|
29
|
+
*
|
|
30
|
+
* To parse an arbitrary date string with timezone use:
|
|
31
|
+
*
|
|
32
|
+
* date = stringToDate('2022.11.10, 11:15 +01:00', 'yyyy.MM.dd, HH:mm xxx', false)
|
|
33
|
+
*
|
|
34
|
+
* To parse an arbitrary date string without timezone use:
|
|
35
|
+
*
|
|
36
|
+
* date = stringToDate('2022.11.10, 11:15', 'yyyy.MM.dd, HH:mm')
|
|
37
|
+
*
|
|
38
|
+
*
|
|
39
|
+
* To safely convert dates to utc strings use:
|
|
40
|
+
*
|
|
41
|
+
* date.toISOString()
|
|
42
|
+
*
|
|
43
|
+
* To get parts of UTC time use
|
|
44
|
+
*
|
|
45
|
+
* date.getUTCHours()
|
|
46
|
+
* date.getUTCMins()
|
|
47
|
+
*
|
|
48
|
+
* To parse an arbitrary date string to a UTC string use:
|
|
49
|
+
*
|
|
50
|
+
* dateToString(new Date('2022-10-10T15:30:00Z'), 'HH:ss dd MMM yyyy')
|
|
51
|
+
*
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* Parse an ISO string to a date
|
|
55
|
+
*
|
|
56
|
+
* Expects the following props:
|
|
57
|
+
* @param {string} input - string containing date
|
|
58
|
+
*
|
|
59
|
+
* @returns {Date} Date
|
|
60
|
+
* @example
|
|
61
|
+
* ``` isoStringToDate("2022-5-10T20:32:00+00:00") ```
|
|
62
|
+
* ``` isoStringToDate("2022-5-10T20:32:00:00Z", false) ```
|
|
63
|
+
*/
|
|
64
|
+
export declare const isoStringToDate: (input: string, utc?: boolean) => Date | undefined;
|
|
65
|
+
export declare const isValidIsoDateString: (input: string) => boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Parse a string to a date
|
|
68
|
+
*
|
|
69
|
+
* ***NOTE: String will be parsed in local time if utc is set to false***
|
|
70
|
+
*
|
|
71
|
+
* Expects the following props:
|
|
72
|
+
* @param {string} input - string containing date
|
|
73
|
+
* @param {string} strFormat - format of the string, see: https://date-fns.org/v2.29.3/docs/parse
|
|
74
|
+
* @param {boolean} utc [ default = true ] - boolean indicating whether to parse as UTC
|
|
75
|
+
* @param {Date} referenceDate [ default = new Date() ] - defines values missing from the parsed dateString
|
|
76
|
+
*
|
|
77
|
+
* @returns {Date} Date
|
|
78
|
+
* @example
|
|
79
|
+
* ``` stringToDate("2022 5 10 20:32", 'yyyy M d HH:mm')) ```
|
|
80
|
+
*/
|
|
81
|
+
export declare const stringToDate: (input: string | undefined, strFormat: string, utc?: boolean, referenceDate?: Date | number) => Date | undefined;
|
|
82
|
+
export declare const dateToIsoString: (input: Date | undefined) => string | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Use this if you initialise a date without a timezone to set it to utc correctly
|
|
85
|
+
* eg.
|
|
86
|
+
* new Date(2022, 10, 12, 15, 30)
|
|
87
|
+
* should be:
|
|
88
|
+
* setUTCDate(new Date(2022, 10, 12, 15, 30))
|
|
89
|
+
*
|
|
90
|
+
* Expects the following props:
|
|
91
|
+
* @param {Date} inDate - date to be set to UTC
|
|
92
|
+
*
|
|
93
|
+
* @returns {Date} - Date in UTC
|
|
94
|
+
* @example
|
|
95
|
+
* ``` setUTCDate(new Date(2022, 10, 12, 15, 30)) ```
|
|
96
|
+
*/
|
|
97
|
+
export declare const setUTCDate: (inDate: Date | undefined) => Date | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Format a date to a string
|
|
100
|
+
*
|
|
101
|
+
* Expects the following props:
|
|
102
|
+
* @param {Date} inDate - date to be formatted
|
|
103
|
+
* @param {string} strFormat - [default: "yyyy-MM-dd'T'HH:mm:ss'Z'"] format of string
|
|
104
|
+
* @param {boolean} utc - [default: true] true to return in utc otherwise return in local timezone
|
|
105
|
+
*
|
|
106
|
+
* @returns {string} - formatted date string
|
|
107
|
+
* @example
|
|
108
|
+
* ``` dateToString(new Date(2022, 10, 12, 15, 30), 'dd MMM yyyy') ```
|
|
109
|
+
*/
|
|
110
|
+
export declare const dateToString: (inDate: Date | undefined, strFormat?: string, utc?: boolean) => string | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Find out if a date is between two other dates.
|
|
113
|
+
*
|
|
114
|
+
* Inclusivity parameter matches that used in momentjs where '[' indicates inclusion and '(' indicates exclusion.
|
|
115
|
+
*
|
|
116
|
+
* Expects the following props:
|
|
117
|
+
* @param {Date} date - date to be tested
|
|
118
|
+
* @param {Date} from - first date
|
|
119
|
+
* @param {Date} to - last date
|
|
120
|
+
* @param {string} inclusivity - [default: '()'] Must be one of : '()', '[]', '(]', '[)'
|
|
121
|
+
*
|
|
122
|
+
* @returns {boolen} - true if date is between, otherwise false
|
|
123
|
+
*
|
|
124
|
+
*/
|
|
125
|
+
export declare const isBetween: (date: Date, from: Date, to: Date, inclusivity?: string) => boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Creates a new Date object with the specified date and time, or the current date and time if no arguments are provided.
|
|
128
|
+
*
|
|
129
|
+
* @param yearOrIsoString The year for the new Date object, or an ISO-formatted string representing the date and time.
|
|
130
|
+
* @param month The month for the new Date object (0-11).
|
|
131
|
+
* @param day The day for the new Date object (1-31).
|
|
132
|
+
* @param hours The hour for the new Date object (0-23).
|
|
133
|
+
* @param minutes The minute for the new Date object (0-59).
|
|
134
|
+
* @param seconds The second for the new Date object (0-59).
|
|
135
|
+
* @param milliseconds The millisecond for the new Date object (0-999).
|
|
136
|
+
* @returns A new Date object with the specified date and time, or the current date and time if no arguments are provided.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* createDate(2022, 11, 13);
|
|
140
|
+
* // => 2022-12-13T00:00:00.000Z
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* createDate('2022-12-13T00:00:00.000Z');
|
|
144
|
+
* // => 2022-12-13T00:00:00.000Z
|
|
145
|
+
*/
|
|
146
|
+
export declare const createDate: (yearOrIsoString?: number | string, month?: number, day?: number, hours?: number, minutes?: number, seconds?: number, milliseconds?: number) => Date;
|
|
147
|
+
/**
|
|
148
|
+
*
|
|
149
|
+
* @param date
|
|
150
|
+
* @param duration
|
|
151
|
+
* @returns {Date} the new Date
|
|
152
|
+
*/
|
|
153
|
+
export declare const add: (date: Date | number, duration: Duration) => Date;
|
|
154
|
+
/**
|
|
155
|
+
*
|
|
156
|
+
* @param date
|
|
157
|
+
* @param duration
|
|
158
|
+
* @returns {Date} the new Date
|
|
159
|
+
*/
|
|
160
|
+
export declare const sub: (date: Date | number, duration: Duration) => Date;
|
|
161
|
+
/**
|
|
162
|
+
* Finds the number of years between to dates
|
|
163
|
+
*
|
|
164
|
+
* @param dateLeft - the later date
|
|
165
|
+
* @param dateRight - the earlier date
|
|
166
|
+
* @returns {number} the number of minutes
|
|
167
|
+
*/
|
|
168
|
+
export declare const differenceInYears: (dateLeft: Date | number, dateRight: Date | number) => number;
|
|
169
|
+
/**
|
|
170
|
+
* Finds the number of months between to dates
|
|
171
|
+
*
|
|
172
|
+
* @param dateLeft - the later date
|
|
173
|
+
* @param dateRight - the earlier date
|
|
174
|
+
* @returns {number} the number of minutes
|
|
175
|
+
*/
|
|
176
|
+
export declare const differenceInMonths: (dateLeft: Date | number | string, dateRight: Date | number | string) => number;
|
|
177
|
+
/**
|
|
178
|
+
* Finds the number of days between to dates
|
|
179
|
+
*
|
|
180
|
+
* @param dateLeft - the later date
|
|
181
|
+
* @param dateRight - the earlier date
|
|
182
|
+
* @returns {number} the number of minutes
|
|
183
|
+
*/
|
|
184
|
+
export declare const differenceInDays: (dateLeft: Date | number | string, dateRight: Date | number | string) => number;
|
|
185
|
+
/**
|
|
186
|
+
* Finds the number of minuts between to dates
|
|
187
|
+
*
|
|
188
|
+
* @param dateLeft - the later date
|
|
189
|
+
* @param dateRight - the earlier date
|
|
190
|
+
* @returns {number} the number of minutes
|
|
191
|
+
*/
|
|
192
|
+
export declare const differenceInMinutes: (dateLeft: Date | number, dateRight: Date | number) => number;
|
|
193
|
+
/**
|
|
194
|
+
* Finds the number of hours between to dates
|
|
195
|
+
*
|
|
196
|
+
* @param dateLeft - the later date
|
|
197
|
+
* @param dateRight - the earlier date
|
|
198
|
+
* @returns {number} the number of hours
|
|
199
|
+
*/
|
|
200
|
+
export declare const differenceInHours: (dateLeft: Date | number, dateRight: Date | number, roundingMethod?: 'ceil' | 'floor' | 'round' | 'trunc') => number;
|
|
201
|
+
/**
|
|
202
|
+
* Finds the number of seconds between to dates
|
|
203
|
+
*
|
|
204
|
+
* @param dateLeft - the later date
|
|
205
|
+
* @param dateRight - the earlier date
|
|
206
|
+
* @returns {number} the number of minutes
|
|
207
|
+
*/
|
|
208
|
+
export declare const differenceInSeconds: (dateLeft: Date | number, dateRight: Date | number) => number;
|
|
209
|
+
/**
|
|
210
|
+
*
|
|
211
|
+
* @param date - the date to be rounded
|
|
212
|
+
* @param options - the options for rounding
|
|
213
|
+
* @returns the new date
|
|
214
|
+
*/
|
|
215
|
+
export declare const roundToNearestMinutes: (date: Date | number, options: {
|
|
216
|
+
nearestTo: NearestMinutes;
|
|
217
|
+
}) => Date;
|
|
218
|
+
/**
|
|
219
|
+
*
|
|
220
|
+
* @param date - the date that should be before the other one to return true
|
|
221
|
+
* @param dateToCompare -the date to compare with
|
|
222
|
+
*
|
|
223
|
+
* @returns the first date is before the second date
|
|
224
|
+
*/
|
|
225
|
+
export declare const isBefore: (date: Date | number, dateToCompare: Date | number) => boolean;
|
|
226
|
+
/**
|
|
227
|
+
*
|
|
228
|
+
* @param date - the date that should be after the other one to return true
|
|
229
|
+
* @param dateToCompare -the date to compare with
|
|
230
|
+
*
|
|
231
|
+
* @returns the first date is after the second date
|
|
232
|
+
*/
|
|
233
|
+
export declare const isAfter: (date: Date | number, dateToCompare: Date | number) => boolean;
|
|
234
|
+
/**
|
|
235
|
+
* Gracefully parsing string to a date, setting tz to UTC even if it's missing or input is invalid
|
|
236
|
+
* Note: use getUtcFromString() to convert a string to a date with stricter returns
|
|
237
|
+
* @param dateStr - string containing date
|
|
238
|
+
* @returns {Date} - Date in UTC, or current date when something invalid is passed.
|
|
239
|
+
*/
|
|
240
|
+
export declare const utc: (dateStr?: string | undefined) => Date;
|
|
241
|
+
/**
|
|
242
|
+
* Parsing string to a date. Stricter check, will return undefined when dateString is invalid.
|
|
243
|
+
* @param dateStr - string containing date
|
|
244
|
+
* @returns {Date} - Date in UTC, undefined when not valid
|
|
245
|
+
*/
|
|
246
|
+
export declare const getUtcFromString: (dateStr: string | undefined | null) => Date | undefined;
|
|
247
|
+
/**
|
|
248
|
+
* Check if a date object is valid
|
|
249
|
+
* @param {Date | number} date - date to be checked
|
|
250
|
+
* @returns {boolean} - True if valid
|
|
251
|
+
*/
|
|
252
|
+
export declare const isValid: (date: Date | number) => boolean;
|
|
253
|
+
/**
|
|
254
|
+
* Get the seconds timestamp of the given date
|
|
255
|
+
* @param {Date} date - the given date
|
|
256
|
+
* @returns the timestamp
|
|
257
|
+
*/
|
|
258
|
+
export declare const unix: (date: Date | number) => number;
|
|
259
|
+
/**
|
|
260
|
+
* Return the Date object for a given timestamp
|
|
261
|
+
* @param {number} unixTime - timestamp
|
|
262
|
+
* @returns the timestamp
|
|
263
|
+
*/
|
|
264
|
+
export declare const fromUnix: (unixTime: number) => Date;
|
|
265
|
+
export declare const parseCustomDateString: (dateStr: string) => Date;
|
|
266
|
+
/**
|
|
267
|
+
* Returns Date in UTC
|
|
268
|
+
* @returns {Date} - Date in UTC
|
|
269
|
+
*/
|
|
270
|
+
export declare const getNowUtc: () => Date;
|
|
271
|
+
/**
|
|
272
|
+
* Returns current time as string
|
|
273
|
+
* @param {string} strFormat - [default: "yyyy-MM-dd'T'HH:mm:ss'Z'"] format of string
|
|
274
|
+
* @param {boolean} utc - [default: true] true to return in utc otherwise return in local timezone
|
|
275
|
+
*
|
|
276
|
+
* @returns {string} - formatted date string
|
|
277
|
+
*/
|
|
278
|
+
export declare const getCurrentTimeAsString: (strFormat?: string, utc?: boolean) => string;
|
|
279
|
+
/**
|
|
280
|
+
* Set date values to a given date (by default it is assumed you are passing the new values in UTC).
|
|
281
|
+
* Note that months start at 0!
|
|
282
|
+
* @param date - the dater to be changed
|
|
283
|
+
* @param values - an object with options
|
|
284
|
+
* @param useLocalTimeZone - boolean true if you are passing the values in local timezone
|
|
285
|
+
* @returns the new date with options set
|
|
286
|
+
*/
|
|
287
|
+
export declare const set: (date: Date, values: DateValues, useLocalTimeZone?: boolean) => Date;
|
|
288
|
+
/**
|
|
289
|
+
* Get hours of a passed date in UTC (or local timezone if passed false)
|
|
290
|
+
* @param date - the date of which to extract hours
|
|
291
|
+
* @param utc - boolean true - whether to get UTC hours
|
|
292
|
+
* @returns the hour number
|
|
293
|
+
*/
|
|
294
|
+
export declare const getHours: (date: Date, utc?: boolean) => number;
|
|
295
|
+
/**
|
|
296
|
+
* Return the start of hour for the given date. The result will be in UTC.
|
|
297
|
+
* @param date - the date of which to retrieve the start of the hour
|
|
298
|
+
* @returns the new date
|
|
299
|
+
*/
|
|
300
|
+
export declare const startOfHourUTC: (date: Date) => Date;
|
|
301
|
+
/**
|
|
302
|
+
* Return the start of a day for the given date. The result will be in UTC.
|
|
303
|
+
* @param date - the date of which to retrieve the start of day
|
|
304
|
+
* @returns the new date
|
|
305
|
+
*/
|
|
306
|
+
export declare const startOfDayUTC: (date: Date) => Date;
|
|
307
|
+
/**
|
|
308
|
+
* Return the start of a week for the given date. The result will be in UTC.
|
|
309
|
+
* @param date - the date of which to retrieve the start of the week
|
|
310
|
+
* @returns the new date
|
|
311
|
+
*/
|
|
312
|
+
export declare const startOfWeekUTC: (date: Date) => Date;
|
|
313
|
+
/**
|
|
314
|
+
* Return the start of a month for the given date. The result will be in UTC.
|
|
315
|
+
* @param date - the date of which to retrieve the start of the month
|
|
316
|
+
* @returns the new date
|
|
317
|
+
*/
|
|
318
|
+
export declare const startOfMonthUTC: (date: Date) => Date;
|
|
319
|
+
/**
|
|
320
|
+
* Return the start of a year for the given date. The result will be in UTC.
|
|
321
|
+
* @param date - the date of which to retrieve the start of the year
|
|
322
|
+
* @returns the new date
|
|
323
|
+
*/
|
|
324
|
+
export declare const startOfYearUTC: (date: Date) => Date;
|
|
325
|
+
/**
|
|
326
|
+
* Parse custom time format of NOW+current time | current date in UTC. The result will be in UTC.
|
|
327
|
+
* @param timeValue - string value
|
|
328
|
+
* @returns Time in UTC format
|
|
329
|
+
*/
|
|
330
|
+
export declare const convertNOWFormatToUTC: (timeValue: string) => string;
|
|
331
|
+
/**
|
|
332
|
+
* Parse custom time format of NOW+-hours and minutes || TODAY+-hours and minutes into UTC. The result will be in UTC.
|
|
333
|
+
* @param timeValue - string value
|
|
334
|
+
* @returns Time in UTC format
|
|
335
|
+
*/
|
|
336
|
+
export declare const convertNOWandTODAYFormatsToUTC: (timeValue: string) => string;
|
|
337
|
+
/**
|
|
338
|
+
* Compares two dates if values are the same
|
|
339
|
+
* @param {Date} date - first date
|
|
340
|
+
* @param {Date} date - second date
|
|
341
|
+
* @returns {boolean} - True if dates are equal
|
|
342
|
+
*/
|
|
343
|
+
export { isEqual, startOfDay, parseISO, isWithinInterval, getDayOfYear, getDay, getMonth, getYear, getWeek, };
|