scdate 0.2.3 → 0.2.5
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/dist/index.d.ts +9 -9
- package/dist/index.js +5 -5
- package/dist/internal/SDate.d.ts +3 -0
- package/dist/internal/SDate.js +4 -1
- package/dist/internal/STime.d.ts +3 -0
- package/dist/internal/STime.js +4 -1
- package/dist/internal/STimestamp.d.ts +3 -0
- package/dist/internal/STimestamp.js +4 -1
- package/dist/internal/SWeekdays.d.ts +7 -0
- package/dist/internal/SWeekdays.js +8 -1
- package/dist/internal/constants.d.ts +1 -1
- package/dist/internal/constants.js +1 -1
- package/dist/internal/date.d.ts +1 -1
- package/dist/internal/date.js +1 -0
- package/dist/internal/time.js +2 -0
- package/dist/internal/timestamp.d.ts +1 -1
- package/dist/internal/timestamp.js +2 -2
- package/dist/internal/utils.d.ts +4 -0
- package/dist/internal/utils.js +4 -0
- package/dist/internal/weekdays.d.ts +1 -1
- package/dist/internal/weekdays.js +1 -1
- package/dist/internal/zoned.d.ts +6 -2
- package/dist/internal/zoned.js +6 -2
- package/dist/sDate.d.ts +282 -2
- package/dist/sDate.js +289 -6
- package/dist/sTime.d.ts +132 -1
- package/dist/sTime.js +135 -4
- package/dist/sTimestamp.d.ts +269 -3
- package/dist/sTimestamp.js +272 -6
- package/dist/sWeekdays.d.ts +119 -3
- package/dist/sWeekdays.js +123 -5
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from './constants';
|
|
2
|
-
export * from './sDate';
|
|
3
|
-
export * from './sTime';
|
|
4
|
-
export * from './sTimestamp';
|
|
5
|
-
export * from './sWeekdays';
|
|
6
|
-
export type * from './internal/SDate';
|
|
7
|
-
export type * from './internal/STime';
|
|
8
|
-
export type * from './internal/STimestamp';
|
|
9
|
-
export type * from './internal/SWeekdays';
|
|
1
|
+
export * from './constants.js';
|
|
2
|
+
export * from './sDate.js';
|
|
3
|
+
export * from './sTime.js';
|
|
4
|
+
export * from './sTimestamp.js';
|
|
5
|
+
export * from './sWeekdays.js';
|
|
6
|
+
export type * from './internal/SDate.js';
|
|
7
|
+
export type * from './internal/STime.js';
|
|
8
|
+
export type * from './internal/STimestamp.js';
|
|
9
|
+
export type * from './internal/SWeekdays.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './constants';
|
|
2
|
-
export * from './sDate';
|
|
3
|
-
export * from './sTime';
|
|
4
|
-
export * from './sTimestamp';
|
|
5
|
-
export * from './sWeekdays';
|
|
1
|
+
export * from './constants.js';
|
|
2
|
+
export * from './sDate.js';
|
|
3
|
+
export * from './sTime.js';
|
|
4
|
+
export * from './sTimestamp.js';
|
|
5
|
+
export * from './sWeekdays.js';
|
package/dist/internal/SDate.d.ts
CHANGED
package/dist/internal/SDate.js
CHANGED
package/dist/internal/STime.d.ts
CHANGED
package/dist/internal/STime.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { validateISOTimestamp } from './timestamp';
|
|
1
|
+
import { validateISOTimestamp } from './timestamp.js';
|
|
2
|
+
/**
|
|
3
|
+
* STimestamp represents a timestamp in the ISO-8601 format (YYYY-MM-DDTHH:MM)
|
|
4
|
+
*/
|
|
2
5
|
export class STimestamp {
|
|
3
6
|
timestamp;
|
|
4
7
|
constructor(timestamp) {
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SWeekdays represents a string of weekdays in the format 'SMTWTFS' where each
|
|
3
|
+
* position is represented by a flag indicating if the weekday (starting on
|
|
4
|
+
* Sunday and ending on Saturday using the first letter of the english word for
|
|
5
|
+
* the week day) is included or excluded. If excluded, the position is filled
|
|
6
|
+
* with a '-' character.
|
|
7
|
+
*/
|
|
1
8
|
export declare class SWeekdays {
|
|
2
9
|
readonly weekdays: string;
|
|
3
10
|
constructor(weekdays: string);
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import { validateWeekdays } from './weekdays';
|
|
1
|
+
import { validateWeekdays } from './weekdays.js';
|
|
2
|
+
/**
|
|
3
|
+
* SWeekdays represents a string of weekdays in the format 'SMTWTFS' where each
|
|
4
|
+
* position is represented by a flag indicating if the weekday (starting on
|
|
5
|
+
* Sunday and ending on Saturday using the first letter of the english word for
|
|
6
|
+
* the week day) is included or excluded. If excluded, the position is filled
|
|
7
|
+
* with a '-' character.
|
|
8
|
+
*/
|
|
2
9
|
export class SWeekdays {
|
|
3
10
|
weekdays;
|
|
4
11
|
constructor(weekdays) {
|
package/dist/internal/date.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UTCDateMini } from '@date-fns/utc';
|
|
2
|
-
import { SDate } from './SDate';
|
|
2
|
+
import { SDate } from './SDate.js';
|
|
3
3
|
export declare const getISOYearFromISODate: (isoDate: string) => string;
|
|
4
4
|
export declare const getISOMonthFromISODate: (isoDate: string) => string;
|
|
5
5
|
export declare const getISODateFromISODate: (isoDate: string) => string;
|
package/dist/internal/date.js
CHANGED
|
@@ -25,6 +25,7 @@ export const validateISODate = (isoDate) => {
|
|
|
25
25
|
const date = Number(getISODateFromISODate(isoDate));
|
|
26
26
|
const nativeDate = new Date();
|
|
27
27
|
nativeDate.setUTCFullYear(year, month, date);
|
|
28
|
+
// This will result in an error if for example the date uses 32 as the date
|
|
28
29
|
if (nativeDate.getUTCFullYear() !== year ||
|
|
29
30
|
nativeDate.getUTCMonth() !== month ||
|
|
30
31
|
nativeDate.getUTCDate() !== date) {
|
package/dist/internal/time.js
CHANGED
|
@@ -19,6 +19,8 @@ export const validateISOTime = (isoTime) => {
|
|
|
19
19
|
const nativeDate = new Date();
|
|
20
20
|
nativeDate.setUTCHours(hours);
|
|
21
21
|
nativeDate.setUTCMinutes(minutes);
|
|
22
|
+
// The following will result in an error if for example the date uses a time
|
|
23
|
+
// outside of 0:00 and 23:59.
|
|
22
24
|
if (nativeDate.getUTCMinutes() !== minutes ||
|
|
23
25
|
nativeDate.getUTCHours() !== hours) {
|
|
24
26
|
throw new Error(`Invalid ISO time value. Expected from 00:00 to 23:59. Current value: '${isoTime}'.`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UTCDateMini } from '@date-fns/utc';
|
|
2
|
-
import { STimestamp } from './STimestamp';
|
|
2
|
+
import { STimestamp } from './STimestamp.js';
|
|
3
3
|
export declare const getISODateFromISOTimestamp: (isoTimestamp: string) => string;
|
|
4
4
|
export declare const getISOTimeFromISOTimestamp: (isoTimestamp: string) => string;
|
|
5
5
|
export declare const getISOTimestampFromZonedDate: (date: Date) => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UTCDateMini } from '@date-fns/utc';
|
|
2
|
-
import { getISODateFromZonedDate, validateISODate } from './date';
|
|
3
|
-
import { getISOTimeFromDate, validateISOTime } from './time';
|
|
2
|
+
import { getISODateFromZonedDate, validateISODate } from './date.js';
|
|
3
|
+
import { getISOTimeFromDate, validateISOTime } from './time.js';
|
|
4
4
|
export const getISODateFromISOTimestamp = (isoTimestamp) => {
|
|
5
5
|
const EndOfDateIndex = 10;
|
|
6
6
|
return isoTimestamp.slice(0, EndOfDateIndex);
|
package/dist/internal/utils.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export declare const hasFlag: (flags: number, checkFlag: number) => boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the value from the array or string at the defined index or throws
|
|
4
|
+
* if the value is undefined.
|
|
5
|
+
*/
|
|
2
6
|
export declare const getAtIndex: <T extends string | unknown[]>(arrayOrString: T, index: number) => T[number];
|
package/dist/internal/utils.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export const hasFlag = (flags, checkFlag) => (flags & checkFlag) === checkFlag;
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the value from the array or string at the defined index or throws
|
|
4
|
+
* if the value is undefined.
|
|
5
|
+
*/
|
|
2
6
|
export const getAtIndex = (arrayOrString, index) => {
|
|
3
7
|
const value = arrayOrString[index];
|
|
4
8
|
if (value === undefined) {
|
package/dist/internal/zoned.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { SDate } from './SDate';
|
|
2
|
-
import { STimestamp } from './STimestamp';
|
|
1
|
+
import { SDate } from './SDate.js';
|
|
2
|
+
import { STimestamp } from './STimestamp.js';
|
|
3
3
|
export declare const getMillisecondsInUTCFromTimestamp: (timestamp: STimestamp, timeZone: string) => number;
|
|
4
4
|
export declare const getMillisecondsInUTCFromDate: (date: SDate, timeZone: string) => number;
|
|
5
|
+
/**
|
|
6
|
+
* @param timeZone For a list of valid time zones run
|
|
7
|
+
* `Intl.supportedValuesOf('timeZone')` on your environment.
|
|
8
|
+
*/
|
|
5
9
|
export declare const getTimeZonedDate: (millisecondsInUTC: number, timeZone: string) => Date;
|
package/dist/internal/zoned.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getTimezoneOffset, toZonedTime } from 'date-fns-tz';
|
|
2
|
-
import { getDateAsUTCDateMini } from './date';
|
|
3
|
-
import { getTimestampAsUTCDateMini } from './timestamp';
|
|
2
|
+
import { getDateAsUTCDateMini } from './date.js';
|
|
3
|
+
import { getTimestampAsUTCDateMini } from './timestamp.js';
|
|
4
4
|
const getValidatedTimeZoneOffset = (timeZone, utcDate) => {
|
|
5
5
|
const timeZoneOffset = getTimezoneOffset(timeZone, utcDate);
|
|
6
6
|
if (isNaN(timeZoneOffset)) {
|
|
@@ -18,6 +18,10 @@ export const getMillisecondsInUTCFromDate = (date, timeZone) => {
|
|
|
18
18
|
const timeZoneOffset = getValidatedTimeZoneOffset(timeZone, utcDate);
|
|
19
19
|
return utcDate.getTime() - timeZoneOffset;
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* @param timeZone For a list of valid time zones run
|
|
23
|
+
* `Intl.supportedValuesOf('timeZone')` on your environment.
|
|
24
|
+
*/
|
|
21
25
|
export const getTimeZonedDate = (millisecondsInUTC, timeZone) => {
|
|
22
26
|
if (isNaN(millisecondsInUTC.valueOf())) {
|
|
23
27
|
throw new Error(`Invalid date. Date: '${String(millisecondsInUTC.valueOf())}'`);
|
package/dist/sDate.d.ts
CHANGED
|
@@ -1,33 +1,313 @@
|
|
|
1
|
-
import { Weekday } from './constants';
|
|
2
|
-
import { SDate } from './internal/SDate';
|
|
1
|
+
import { Weekday } from './constants.js';
|
|
2
|
+
import { SDate } from './internal/SDate.js';
|
|
3
3
|
export interface SDateShortStringOptions {
|
|
4
4
|
includeWeekday: boolean;
|
|
5
5
|
onTodayText: () => string;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* --- Factory ---
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Returns a new SDate instance.
|
|
12
|
+
*
|
|
13
|
+
* @param date An instance of SDate or a string in the YYYY-MM-DD format.
|
|
14
|
+
*/
|
|
7
15
|
export declare const sDate: (date: string | SDate) => SDate;
|
|
16
|
+
/**
|
|
17
|
+
* --- Factory helpers ---
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Returns a new SDate instance with the current date in the given time zone.
|
|
21
|
+
*
|
|
22
|
+
* @param timeZone The time zone to get the current date for. See
|
|
23
|
+
* `Intl.supportedValuesOf('timeZone')` for a list of valid time zones.
|
|
24
|
+
*/
|
|
8
25
|
export declare const getDateToday: (timeZone: string) => SDate;
|
|
26
|
+
/**
|
|
27
|
+
* Returns a new SDate instance set to the next date after the provided date
|
|
28
|
+
* that match the given weekday.
|
|
29
|
+
*
|
|
30
|
+
* @param date The date to start from (not included). It can be an SDate or a
|
|
31
|
+
* string in the YYYY-MM-DD format.
|
|
32
|
+
* @param weekday The weekday to find the next date for.
|
|
33
|
+
*/
|
|
9
34
|
export declare const getNextDateByWeekday: (date: string | SDate, weekday: Weekday) => SDate;
|
|
35
|
+
/**
|
|
36
|
+
* Returns a new SDate instance set to date that is before the provided date and
|
|
37
|
+
* matches the given weekday.
|
|
38
|
+
*
|
|
39
|
+
* @param date The date to start from (not included).
|
|
40
|
+
* @param weekday The weekday to find the previous date for. It can be an SDate
|
|
41
|
+
* or a string in the YYYY-MM-DD format.
|
|
42
|
+
*/
|
|
10
43
|
export declare const getPreviousDateByWeekday: (date: string | SDate, weekday: Weekday) => SDate;
|
|
44
|
+
/**
|
|
45
|
+
* Returns a new SDate instance set to the first day of the month for the
|
|
46
|
+
* provided date.
|
|
47
|
+
*
|
|
48
|
+
* @param date The date to get the first day of the month for. It can be an
|
|
49
|
+
* SDate or a string in the YYYY-MM-DD format.
|
|
50
|
+
*/
|
|
11
51
|
export declare const getDateForFirstDayOfMonth: (date: string | SDate) => SDate;
|
|
52
|
+
/**
|
|
53
|
+
* Returns a new SDate instance set to the last day of the month for the
|
|
54
|
+
* provided date.
|
|
55
|
+
*
|
|
56
|
+
* @param date The date to get the last day of the month for. It can be an SDate
|
|
57
|
+
* or a string in the YYYY-MM-DD format.
|
|
58
|
+
*/
|
|
12
59
|
export declare const getDateForLastDayOfMonth: (date: string | SDate) => SDate;
|
|
60
|
+
/**
|
|
61
|
+
* --- Getters ---
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* Returns the year from the given date.
|
|
65
|
+
*
|
|
66
|
+
* @param date The date to get the year from. It can be an SDate or a string in
|
|
67
|
+
* the YYYY-MM-DD format.
|
|
68
|
+
*/
|
|
13
69
|
export declare const getYearFromDate: (date: string | SDate) => number;
|
|
70
|
+
/**
|
|
71
|
+
* Returns the month from the given date. Returns a 0-index value (i.e. Janary
|
|
72
|
+
* is 0 and December is 11) to match the result from native Date object.
|
|
73
|
+
*
|
|
74
|
+
* @param date The date to get the month from. It can be an SDate or a string in
|
|
75
|
+
* the YYYY-MM-DD format.
|
|
76
|
+
*/
|
|
14
77
|
export declare const getMonthFromDate: (date: string | SDate) => number;
|
|
78
|
+
/**
|
|
79
|
+
* Returns the day of the month from the given date.
|
|
80
|
+
*
|
|
81
|
+
* @param date The date to get the day from. It can be an SDate or a string in
|
|
82
|
+
* the YYYY-MM-DD format.
|
|
83
|
+
*/
|
|
15
84
|
export declare const getDateFromDate: (date: string | SDate) => number;
|
|
85
|
+
/**
|
|
86
|
+
* Returns the day of the week from the given date (Sunday to Saturday / 0 to
|
|
87
|
+
* 6).
|
|
88
|
+
*
|
|
89
|
+
* @param date The date to get the weekday from. It can be an SDate or a string
|
|
90
|
+
* in the YYYY-MM-DD format.
|
|
91
|
+
*/
|
|
16
92
|
export declare const getWeekdayFromDate: (date: string | SDate) => number;
|
|
93
|
+
/**
|
|
94
|
+
* Returns a native Date adjusted so that the local time of that date matches
|
|
95
|
+
* the local time at the specified time zone.
|
|
96
|
+
*
|
|
97
|
+
* @param date The date to get the time zoned date from. It can be an SDate or a
|
|
98
|
+
* string in the YYYY-MM-DD format.
|
|
99
|
+
* @param timeZone The time zone to adjust the date to. See
|
|
100
|
+
* `Intl.supportedValuesOf('timeZone')` for a list of valid time zones.
|
|
101
|
+
*/
|
|
17
102
|
export declare const getTimeZonedDateFromDate: (date: string | SDate, timeZone: string) => Date;
|
|
103
|
+
/**
|
|
104
|
+
* Returns the number of days between the first date to the second date. The
|
|
105
|
+
* value is positive if the first date is before the second date, and negative
|
|
106
|
+
* if the first date is after the second date. This accounts for calendar days
|
|
107
|
+
* and not full 24-hour periods which could be different due to daylight saving
|
|
108
|
+
* adjustments.
|
|
109
|
+
*
|
|
110
|
+
* @param date1 The first date to get the days between. It can be an SDate or a
|
|
111
|
+
* string in the YYYY-MM-DD format.
|
|
112
|
+
* @param date2 The second date to get the days between. It can be an SDate or a
|
|
113
|
+
* string in the YYYY-MM-DD format.
|
|
114
|
+
*/
|
|
18
115
|
export declare const getDaysBetweenDates: (date1: string | SDate, date2: string | SDate) => number;
|
|
116
|
+
/**
|
|
117
|
+
* Returns a string representation that includes all of the date components of
|
|
118
|
+
* the given date formatted according to the given locale.
|
|
119
|
+
*
|
|
120
|
+
* @param date The date to get the full string representation for. It can be an
|
|
121
|
+
* SDate or a string in the YYYY-MM-DD format.
|
|
122
|
+
* @param locale The locale to use for the string representation.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* getFullDateString('2021-02-05', 'es')
|
|
127
|
+
* //=> 'viernes, 5 de febrero de 2021'
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* getFullDateString('2021-02-05', 'en')
|
|
133
|
+
* //=> 'Friday, February 5, 2021'
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
19
136
|
export declare const getFullDateString: (date: string | SDate, locale: Intl.LocalesArgument) => string;
|
|
137
|
+
/**
|
|
138
|
+
* Get the short string representation of the given date in the given locale.
|
|
139
|
+
*
|
|
140
|
+
* @param date The date to get the short string representation for. It can be an
|
|
141
|
+
* SDate or a string in the YYYY-MM-DD format.
|
|
142
|
+
* @param timeZone The time zone used to determine if in the current year. See
|
|
143
|
+
* `Intl.supportedValuesOf('timeZone')` for a list of valid time zones.
|
|
144
|
+
* @param locale The locale to use for the string representation.
|
|
145
|
+
* @param options The options to customize the short string representation.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```ts
|
|
149
|
+
* getShortDateString('2021-02-05', TestLocalTimeZone, 'en', {
|
|
150
|
+
* onTodayText,
|
|
151
|
+
* includeWeekday: false,
|
|
152
|
+
* }),
|
|
153
|
+
* //=> 'Feb 5' (year is not shown when in the current year)
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```ts
|
|
158
|
+
* getShortDateString('2021-02-05', TestLocalTimeZone, 'es', {
|
|
159
|
+
* onTodayText,
|
|
160
|
+
* includeWeekday: true,
|
|
161
|
+
* })
|
|
162
|
+
* //=> 'vie, 5 feb 21' (year when not in current year)
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
20
165
|
export declare const getShortDateString: (date: string | SDate, timeZone: string, locale: Intl.LocalesArgument, options: SDateShortStringOptions) => string;
|
|
166
|
+
/**
|
|
167
|
+
* --- Operations ---
|
|
168
|
+
*/
|
|
169
|
+
/**
|
|
170
|
+
* Returns a new SDates instance with the date resulting from adding the given
|
|
171
|
+
* number of days to the given date. Because it adds calendar days rather than
|
|
172
|
+
* 24-hour days, this operation is not affected by time zones.
|
|
173
|
+
*
|
|
174
|
+
* @param date The date to add days to. It can be an SDate or a string in the
|
|
175
|
+
* YYYY-MM-DD format.
|
|
176
|
+
* @param days The number of days to add to the date.
|
|
177
|
+
*/
|
|
21
178
|
export declare const addDaysToDate: (date: string | SDate, days: number) => SDate;
|
|
179
|
+
/**
|
|
180
|
+
* Returns a new SDate instance with the date resulting from adding the given
|
|
181
|
+
* number of months to the given date. Because it just adds to the month
|
|
182
|
+
* component of the date, this operation is not affected by time zones.
|
|
183
|
+
*
|
|
184
|
+
* @param date The date to add months to. It can be an SDate or a string in the
|
|
185
|
+
* YYYY-MM-DD format.
|
|
186
|
+
* @param months The number of months to add to the date.
|
|
187
|
+
*/
|
|
22
188
|
export declare const addMonthsToDate: (date: string | SDate, months: number) => SDate;
|
|
189
|
+
/**
|
|
190
|
+
* Returns a new SDate instance with the date resulting from adding the given
|
|
191
|
+
* number of years to the given date. Because this only adds to the year
|
|
192
|
+
* component of the date, this method is not affected by leap years.
|
|
193
|
+
*
|
|
194
|
+
* @param date The date to add years to. It can be an SDate or a string in the
|
|
195
|
+
* YYYY-MM-DD format.
|
|
196
|
+
* @param years The number of years to add to the date.
|
|
197
|
+
*/
|
|
23
198
|
export declare const addYearsToDate: (date: string | SDate, years: number) => SDate;
|
|
199
|
+
/**
|
|
200
|
+
* --- Comparisons ---
|
|
201
|
+
*/
|
|
202
|
+
/**
|
|
203
|
+
* Returns true when the two given dates represent the same day and false
|
|
204
|
+
* otherwise.
|
|
205
|
+
*
|
|
206
|
+
* @param date1 The first date to compare. It can be an SDate or a string in the
|
|
207
|
+
* YYYY-MM-DD format.
|
|
208
|
+
* @param date2 The second date to compare. It can be an SDate or a string in
|
|
209
|
+
* the YYYY-MM-DD format.
|
|
210
|
+
*/
|
|
24
211
|
export declare const isSameDate: (date1: string | SDate, date2: string | SDate) => boolean;
|
|
212
|
+
/**
|
|
213
|
+
* Returns true when the first date represents a date before the second date and
|
|
214
|
+
* false otherwise.
|
|
215
|
+
*
|
|
216
|
+
* @param date1 The first date to compare. It can be an SDate or a string in the
|
|
217
|
+
* YYYY-MM-DD format.
|
|
218
|
+
* @param date2 The second date to compare. It can be an SDate or a string in
|
|
219
|
+
* the YYYY-MM-DD format.
|
|
220
|
+
*/
|
|
25
221
|
export declare const isBeforeDate: (date1: string | SDate, date2: string | SDate) => boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Returns true when the first date represents a date that happens on the same
|
|
224
|
+
* date or before the second date and false otherwise.
|
|
225
|
+
*
|
|
226
|
+
* @param date1 The first date to compare. It can be an SDate or a string in the
|
|
227
|
+
* YYYY-MM-DD format.
|
|
228
|
+
* @param date2 The second date to compare. It can be an SDate or a string in the
|
|
229
|
+
* the YYYY-MM-DD format.
|
|
230
|
+
*/
|
|
26
231
|
export declare const isSameDateOrBefore: (date1: string | SDate, date2: string | SDate) => boolean;
|
|
232
|
+
/**
|
|
233
|
+
* Returns true when the first date represents a date that happens after the
|
|
234
|
+
* second date and false otherwise.
|
|
235
|
+
*
|
|
236
|
+
* @param date1 The first date to compare. It can be an SDate or a string in the
|
|
237
|
+
* YYYY-MM-DD format.
|
|
238
|
+
* @param date2 The second date to compare. It can be an SDate or a string in the
|
|
239
|
+
* the YYYY-MM-DD format.
|
|
240
|
+
*/
|
|
27
241
|
export declare const isAfterDate: (date1: string | SDate, date2: string | SDate) => boolean;
|
|
242
|
+
/**
|
|
243
|
+
* Returns true when the first date represents a date that happens on the same
|
|
244
|
+
* date or after the second date and false otherwise.
|
|
245
|
+
*
|
|
246
|
+
* @param date1 The first date to compare. It can be an SDate or a string in the
|
|
247
|
+
* YYYY-MM-DD format.
|
|
248
|
+
* @param date2 The second date to compare. It can be an SDate or a string in the
|
|
249
|
+
* the YYYY-MM-DD format.
|
|
250
|
+
*/
|
|
28
251
|
export declare const isSameDateOrAfter: (date1: string | SDate, date2: string | SDate) => boolean;
|
|
252
|
+
/**
|
|
253
|
+
* Returns true when the date is today and false otherwise.
|
|
254
|
+
*
|
|
255
|
+
* @param date The date to check if it is today. It can be an SDate or a string
|
|
256
|
+
* in the YYYY-MM-DD format.
|
|
257
|
+
* @param timeZone The time zone to check if the date is today. See
|
|
258
|
+
* `Intl.supportedValuesOf('timeZone')` for a list of valid time zones.
|
|
259
|
+
*/
|
|
29
260
|
export declare const isDateToday: (date: string | SDate, timeZone: string) => boolean;
|
|
261
|
+
/**
|
|
262
|
+
* Returns true when the month on the first date is the same as the month on the
|
|
263
|
+
* second date. It also checks that the year is the same. Returns false
|
|
264
|
+
* otherwise.
|
|
265
|
+
*
|
|
266
|
+
* @param date1 The first date to compare. It can be an SDate or a string in the
|
|
267
|
+
* YYYY-MM-DD format.
|
|
268
|
+
* @param date2 The second date to compare. It can be an SDate or a string in
|
|
269
|
+
* the YYYY-MM-DD format.
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```ts
|
|
273
|
+
* areDatesInSameMonth('2021-02-05', '2021-02-15')
|
|
274
|
+
* //=> true
|
|
275
|
+
* ```
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```ts
|
|
279
|
+
* areDatesInSameMonth('2022-02-05', '2023-02-15')
|
|
280
|
+
* //=> false (different years)
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
30
283
|
export declare const areDatesInSameMonth: (date1: string | SDate, date2: string | SDate) => boolean;
|
|
284
|
+
/**
|
|
285
|
+
* Returns true when the date represents a date in the current month and year.
|
|
286
|
+
* Returns false otherwise.
|
|
287
|
+
*
|
|
288
|
+
* @param date The date to check if it is in the current month. It can be an
|
|
289
|
+
* SDate or a string in the YYYY-MM-DD format.
|
|
290
|
+
* @param timeZone The time zone to check if the date is in the current month.
|
|
291
|
+
* See `Intl.supportedValuesOf('timeZone')` for a list of valid time zones.
|
|
292
|
+
*/
|
|
31
293
|
export declare const isDateInCurrentMonth: (date: string | SDate, timeZone: string) => boolean;
|
|
294
|
+
/**
|
|
295
|
+
* Returns true when the year of the first date is the same as the year on the
|
|
296
|
+
* second date. Returns false otherwise.
|
|
297
|
+
*
|
|
298
|
+
* @param date1 The first date to compare. It can be an SDate or a string in the
|
|
299
|
+
* YYYY-MM-DD format.
|
|
300
|
+
* @param date2 The second date to compare. It can be an SDate or a string in
|
|
301
|
+
* the YYYY-MM-DD format.
|
|
302
|
+
*/
|
|
32
303
|
export declare const areDatesInSameYear: (date1: string | SDate, date2: string | SDate) => boolean;
|
|
304
|
+
/**
|
|
305
|
+
* Returns true when the year component of the date matches the current year in
|
|
306
|
+
* the given time zone. Returns false otherwise.
|
|
307
|
+
*
|
|
308
|
+
* @param date The date to check if it is in the current year. It can be an
|
|
309
|
+
* SDate or a string in the YYYY-MM-DD format.
|
|
310
|
+
* @param timeZone The time zone to check if the date is in the current year.
|
|
311
|
+
* See `Intl.supportedValuesOf('timeZone')` for a list of valid time zones.
|
|
312
|
+
*/
|
|
33
313
|
export declare const isDateInCurrentYear: (date: string | SDate, timeZone: string) => boolean;
|