@checkdigit/time 1.0.0 → 1.1.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/dist/date-fns/_lib/defaultOptions/index.d.ts +1 -1
- package/dist/date-fns/_lib/format/formatters/index.d.ts +1 -1
- package/dist/date-fns/_lib/format/longFormatters/index.d.ts +1 -1
- package/dist/date-fns/intlFormat/index.d.ts +3 -3
- package/dist/date-fns/locale/_lib/buildLocalizeFn/index.d.ts +9 -9
- package/dist/date-fns/locale/types.d.ts +23 -23
- package/dist/date-fns/parse/_lib/types.d.ts +2 -2
- package/dist/date-fns/types.d.ts +10 -10
- package/dist/date-fns-tz/types.d.ts +1 -1
- package/dist/date-fns-tz.spec.d.ts +1 -0
- package/dist/date-fns.spec.d.ts +1 -0
- package/dist/format-utc.spec.d.ts +1 -0
- package/dist/holidays/index.d.ts +1 -0
- package/dist/holidays/united-states/federal-reserve-bank/add-us-federal-reserve-bank-business-days.d.ts +14 -0
- package/dist/holidays/united-states/federal-reserve-bank/add-us-federal-reserve-bank-business-days.spec.d.ts +1 -0
- package/dist/holidays/united-states/federal-reserve-bank/get-all-us-federal-reserve-bank-holidays.d.ts +18 -0
- package/dist/holidays/united-states/federal-reserve-bank/get-all-us-federal-reserve-bank-holidays.spec.d.ts +1 -0
- package/dist/holidays/united-states/federal-reserve-bank/index.d.ts +4 -0
- package/dist/holidays/united-states/federal-reserve-bank/is-us-federal-reserve-bank-closed.d.ts +14 -0
- package/dist/holidays/united-states/federal-reserve-bank/is-us-federal-reserve-bank-closed.spec.d.ts +1 -0
- package/dist/holidays/united-states/federal-reserve-bank/plain-date.d.ts +5 -0
- package/dist/holidays/united-states/federal-reserve-bank/subtract-us-federal-reserve-bank-business-days.spec.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/instant.d.ts +1 -1
- package/dist/instant.spec.d.ts +1 -0
- package/dist/now.spec.d.ts +1 -0
- package/package.json +9 -6
- package/.github/workflows/ci.yml +0 -72
- package/.github/workflows/codeql-analysis.yml +0 -31
- package/.github/workflows/coverage.yml +0 -46
- package/SECURITY.md +0 -14
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { FirstWeekContainsDateOptions, LocaleOptions, WeekStartOptions } from '../../types';
|
|
2
|
-
export
|
|
2
|
+
export type DefaultOptions = LocaleOptions & WeekStartOptions & FirstWeekContainsDateOptions;
|
|
3
3
|
export declare function getDefaultOptions(): DefaultOptions;
|
|
4
4
|
export declare function setDefaultOptions(newOptions: DefaultOptions): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Localize } from '../../../locale/types';
|
|
2
2
|
import type { FirstWeekContainsDateOptions, LocaleOptions, WeekStartOptions } from '../../../types';
|
|
3
|
-
|
|
3
|
+
type Formatter = (date: Date, token: string, localize: Localize, options: Required<LocaleOptions & WeekStartOptions & FirstWeekContainsDateOptions> & {
|
|
4
4
|
_originalDate: Date;
|
|
5
5
|
}) => string;
|
|
6
6
|
declare const formatters: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { FormatLong } from '../../../locale/types';
|
|
2
|
-
|
|
2
|
+
type LongFormatter = (pattern: string, formatLong: FormatLong) => string;
|
|
3
3
|
declare const longFormatters: Record<string, LongFormatter>;
|
|
4
4
|
export default longFormatters;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
type Locale = Intl.ResolvedDateTimeFormatOptions['locale'];
|
|
2
|
+
type FormatOptions = Intl.DateTimeFormatOptions;
|
|
3
|
+
type LocaleOptions = {
|
|
4
4
|
locale: Locale | Locale[];
|
|
5
5
|
};
|
|
6
6
|
export default function intlFormat<DateType extends Date>(date: DateType): string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Era, Quarter, Month, Day } from '../../../types';
|
|
2
2
|
import type { LocaleDayPeriod, LocalePatternWidth, LocaleUnit, LocalizeFn, LocalizeUnitIndex } from '../../types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
type LocalizeEraValues = readonly [string, string];
|
|
4
|
+
type LocalizeQuarterValues = readonly [string, string, string, string];
|
|
5
|
+
type LocalizeDayValues = readonly [string, string, string, string, string, string, string];
|
|
6
|
+
type LocalizeMonthValues = readonly [
|
|
7
7
|
string,
|
|
8
8
|
string,
|
|
9
9
|
string,
|
|
@@ -17,13 +17,13 @@ declare type LocalizeMonthValues = readonly [
|
|
|
17
17
|
string,
|
|
18
18
|
string
|
|
19
19
|
];
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
20
|
+
export type LocalizeUnitValuesIndex<Values extends LocalizeUnitValues<any>> = Values extends Record<LocaleDayPeriod, string> ? string : Values extends LocalizeEraValues ? Era : Values extends LocalizeQuarterValues ? Quarter : Values extends LocalizeDayValues ? Day : Values extends LocalizeMonthValues ? Month : never;
|
|
21
|
+
export type LocalizeUnitValues<Unit extends LocaleUnit> = Unit extends LocaleDayPeriod ? Record<LocaleDayPeriod, string> : Unit extends Era ? LocalizeEraValues : Unit extends Quarter ? LocalizeQuarterValues : Unit extends Day ? LocalizeDayValues : Unit extends Month ? LocalizeMonthValues : never;
|
|
22
|
+
export type LocalizePeriodValuesMap<Unit extends LocaleUnit> = {
|
|
23
23
|
[pattern in LocalePatternWidth]?: LocalizeUnitValues<Unit>;
|
|
24
24
|
};
|
|
25
|
-
export
|
|
26
|
-
export
|
|
25
|
+
export type BuildLocalizeFnArgCallback<Result extends LocaleUnit | number> = (value: Result) => LocalizeUnitIndex<Result>;
|
|
26
|
+
export type BuildLocalizeFnArgs<Result extends LocaleUnit, ArgCallback extends BuildLocalizeFnArgCallback<Result> | undefined> = {
|
|
27
27
|
values: LocalizePeriodValuesMap<Result>;
|
|
28
28
|
defaultWidth: LocalePatternWidth;
|
|
29
29
|
formattingValues?: LocalizePeriodValuesMap<Result>;
|
|
@@ -13,31 +13,31 @@ export interface LocaleOptions {
|
|
|
13
13
|
weekStartsOn?: Day;
|
|
14
14
|
firstWeekContainsDate?: FirstWeekContainsDate;
|
|
15
15
|
}
|
|
16
|
-
export
|
|
17
|
-
export
|
|
16
|
+
export type FormatDistanceToken = 'lessThanXSeconds' | 'xSeconds' | 'halfAMinute' | 'lessThanXMinutes' | 'xMinutes' | 'aboutXHours' | 'xHours' | 'xDays' | 'aboutXWeeks' | 'xWeeks' | 'aboutXMonths' | 'xMonths' | 'aboutXYears' | 'xYears' | 'overXYears' | 'almostXYears';
|
|
17
|
+
export type FormatDistanceLocale<Value> = {
|
|
18
18
|
[token in FormatDistanceToken]: Value;
|
|
19
19
|
};
|
|
20
20
|
export interface FormatDistanceFnOptions {
|
|
21
21
|
addSuffix?: boolean;
|
|
22
22
|
comparison?: -1 | 0 | 1;
|
|
23
23
|
}
|
|
24
|
-
export
|
|
24
|
+
export type FormatDistanceTokenFn = (count: number, options?: FormatDistanceFnOptions) => string;
|
|
25
25
|
export interface FormatDistanceFnOptions {
|
|
26
26
|
addSuffix?: boolean;
|
|
27
27
|
comparison?: -1 | 0 | 1;
|
|
28
28
|
}
|
|
29
|
-
export
|
|
30
|
-
export
|
|
29
|
+
export type FormatDistanceFn = (token: FormatDistanceToken, count: number, options?: FormatDistanceFnOptions) => string;
|
|
30
|
+
export type FormatRelativeTokenFn = <DateType extends Date>(date: DateType | number, baseDate: DateType | number, options?: {
|
|
31
31
|
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
32
32
|
}) => string;
|
|
33
|
-
export
|
|
33
|
+
export type FormatRelativeToken = 'lastWeek' | 'yesterday' | 'today' | 'tomorrow' | 'nextWeek' | 'other';
|
|
34
34
|
export interface FormatRelativeFnOptions {
|
|
35
35
|
weekStartsOn?: Day;
|
|
36
36
|
locale?: Locale;
|
|
37
37
|
}
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
export
|
|
38
|
+
export type FormatRelativeFn = <DateType extends Date>(token: FormatRelativeToken, date: DateType, baseDate: DateType, options?: FormatRelativeFnOptions) => string;
|
|
39
|
+
export type LocalizeUnitIndex<Unit extends LocaleUnit | number> = Unit extends LocaleUnit ? LocalizeUnitValuesIndex<LocalizeUnitValues<Unit>> : number;
|
|
40
|
+
export type LocalizeFn<Result extends LocaleUnit | number, ArgCallback extends BuildLocalizeFnArgCallback<Result> | undefined = undefined> = (value: ArgCallback extends undefined ? Result : Result extends Quarter ? Quarter : LocalizeUnitIndex<Result>, options?: {
|
|
41
41
|
width?: LocalePatternWidth;
|
|
42
42
|
context?: 'formatting' | 'standalone';
|
|
43
43
|
unit?: Unit;
|
|
@@ -57,19 +57,19 @@ export interface BuildMatchFnArgs<Result extends LocaleUnit, DefaultMatchWidth e
|
|
|
57
57
|
defaultParseWidth: DefaultParseWidth;
|
|
58
58
|
valueCallback?: MatchValueCallback<Result extends LocaleDayPeriod ? string : number, Result>;
|
|
59
59
|
}
|
|
60
|
-
export
|
|
60
|
+
export type MatchPatterns<DefaultWidth extends LocalePatternWidth> = {
|
|
61
61
|
[pattern in LocalePatternWidth]?: RegExp;
|
|
62
62
|
} & {
|
|
63
63
|
[key in DefaultWidth]: RegExp;
|
|
64
64
|
};
|
|
65
|
-
export
|
|
65
|
+
export type ParsePatterns<Result extends LocaleUnit, DefaultWidth extends LocalePatternWidth> = {
|
|
66
66
|
[pattern in LocalePatternWidth]?: ParsePattern<Result>;
|
|
67
67
|
} & {
|
|
68
68
|
[key in DefaultWidth]: ParsePattern<Result>;
|
|
69
69
|
};
|
|
70
|
-
export
|
|
71
|
-
export
|
|
72
|
-
export
|
|
70
|
+
export type ParsePattern<Result extends LocaleUnit> = Result extends LocaleDayPeriod ? Record<LocaleDayPeriod, RegExp> : Result extends Quarter ? readonly [RegExp, RegExp, RegExp, RegExp] : Result extends Era ? readonly [RegExp, RegExp] : Result extends Day ? readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp] : Result extends Month ? readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp] : never;
|
|
71
|
+
export type BuildMatchFn<Result extends LocaleUnit, DefaultMatchWidth extends LocalePatternWidth, DefaultParseWidth extends LocalePatternWidth> = (args: BuildMatchFnArgs<Result, DefaultMatchWidth, DefaultParseWidth>) => MatchFn<Result>;
|
|
72
|
+
export type MatchFn<Result, ExtraOptions = Record<string, unknown>> = (str: string, options?: {
|
|
73
73
|
width?: LocalePatternWidth;
|
|
74
74
|
/**
|
|
75
75
|
* @deprecated Map the value manually instead.
|
|
@@ -84,7 +84,7 @@ export declare type MatchFn<Result, ExtraOptions = Record<string, unknown>> = (s
|
|
|
84
84
|
value: Result;
|
|
85
85
|
rest: string;
|
|
86
86
|
} | null;
|
|
87
|
-
export
|
|
87
|
+
export type MatchValueCallback<Arg, Result> = (value: Arg) => Result;
|
|
88
88
|
export interface Match {
|
|
89
89
|
ordinalNumber: MatchFn<number, {
|
|
90
90
|
unit: LocaleOrdinalUnit;
|
|
@@ -95,15 +95,15 @@ export interface Match {
|
|
|
95
95
|
day: MatchFn<Day>;
|
|
96
96
|
dayPeriod: MatchFn<LocaleDayPeriod>;
|
|
97
97
|
}
|
|
98
|
-
export
|
|
99
|
-
export
|
|
100
|
-
export
|
|
101
|
-
export
|
|
102
|
-
export
|
|
103
|
-
export
|
|
98
|
+
export type LocaleOrdinalUnit = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year' | 'date' | 'dayOfYear';
|
|
99
|
+
export type LocalePatternWidth = 'narrow' | 'short' | 'abbreviated' | 'wide' | 'any';
|
|
100
|
+
export type LocaleDayPeriod = 'am' | 'pm' | 'midnight' | 'noon' | 'morning' | 'afternoon' | 'evening' | 'night';
|
|
101
|
+
export type LocaleOptionUnit = 'year' | 'quarter' | 'month' | 'week' | 'date' | 'dayOfYear' | 'day' | 'hour' | 'minute' | 'second';
|
|
102
|
+
export type FormatLongWidth = 'full' | 'long' | 'medium' | 'short' | 'any';
|
|
103
|
+
export type DateTimeFormat = {
|
|
104
104
|
[format in FormatLongWidth]: string;
|
|
105
105
|
};
|
|
106
|
-
export
|
|
106
|
+
export type LocaleUnit = Era | Quarter | Month | Day | LocaleDayPeriod;
|
|
107
107
|
export interface FormatLong {
|
|
108
108
|
date: FormatLongFn;
|
|
109
109
|
time: FormatLongFn;
|
|
@@ -112,4 +112,4 @@ export interface FormatLong {
|
|
|
112
112
|
export interface FormatLongFnOptions {
|
|
113
113
|
width?: FormatLongWidth;
|
|
114
114
|
}
|
|
115
|
-
export
|
|
115
|
+
export type FormatLongFn = (options: FormatLongFnOptions) => string;
|
|
@@ -3,8 +3,8 @@ export interface ParseFlags {
|
|
|
3
3
|
timestampIsSet?: boolean;
|
|
4
4
|
era?: number;
|
|
5
5
|
}
|
|
6
|
-
export
|
|
7
|
-
export
|
|
6
|
+
export type ParserOptions = Required<LocaleOptions & FirstWeekContainsDateOptions & WeekStartOptions>;
|
|
7
|
+
export type ParseResult<TValue> = {
|
|
8
8
|
value: TValue;
|
|
9
9
|
rest: string;
|
|
10
10
|
} | null;
|
package/dist/date-fns/types.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface Duration {
|
|
|
13
13
|
minutes?: number;
|
|
14
14
|
seconds?: number;
|
|
15
15
|
}
|
|
16
|
-
export
|
|
16
|
+
export type DurationUnit = keyof Duration;
|
|
17
17
|
export interface Interval<DateType extends Date = Date> {
|
|
18
18
|
start: DateType | number;
|
|
19
19
|
end: DateType | number;
|
|
@@ -36,10 +36,10 @@ export interface FormatOptions {
|
|
|
36
36
|
export interface RepresentationOptions {
|
|
37
37
|
representation?: 'complete' | 'date' | 'time';
|
|
38
38
|
}
|
|
39
|
-
export
|
|
40
|
-
export
|
|
41
|
-
export
|
|
42
|
-
export
|
|
39
|
+
export type Era = 0 | 1;
|
|
40
|
+
export type Quarter = 1 | 2 | 3 | 4;
|
|
41
|
+
export type Day = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
42
|
+
export type Month = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11;
|
|
43
43
|
/**
|
|
44
44
|
* FirstWeekContainsDate is used to determine which week is the first week of the year, based on what day the January, 1 is in that week.
|
|
45
45
|
*
|
|
@@ -47,7 +47,7 @@ export declare type Month = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11;
|
|
|
47
47
|
*
|
|
48
48
|
* Please see https://en.wikipedia.org/wiki/Week#Week_numbering for more information.
|
|
49
49
|
*/
|
|
50
|
-
export
|
|
50
|
+
export type FirstWeekContainsDate = 1 | 4;
|
|
51
51
|
export interface DateValues {
|
|
52
52
|
year?: number;
|
|
53
53
|
month?: number;
|
|
@@ -57,14 +57,14 @@ export interface DateValues {
|
|
|
57
57
|
seconds?: number;
|
|
58
58
|
milliseconds?: number;
|
|
59
59
|
}
|
|
60
|
-
export
|
|
60
|
+
export type RoundingMethod = 'ceil' | 'floor' | 'round' | 'trunc';
|
|
61
61
|
export interface RoundingOptions {
|
|
62
62
|
roundingMethod?: RoundingMethod;
|
|
63
63
|
}
|
|
64
|
-
export
|
|
65
|
-
export
|
|
64
|
+
export type Unit = 'second' | 'minute' | 'hour' | 'day' | 'dayOfYear' | 'date' | 'week' | 'month' | 'quarter' | 'year';
|
|
65
|
+
export type FormatDistanceStrictUnit = 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year';
|
|
66
66
|
export interface AdditionalTokensOptions {
|
|
67
67
|
useAdditionalWeekYearTokens?: boolean;
|
|
68
68
|
useAdditionalDayOfYearTokens?: boolean;
|
|
69
69
|
}
|
|
70
|
-
export
|
|
70
|
+
export type IntlOptionsUnit = 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './united-states/federal-reserve-bank';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PlainDate } from './index';
|
|
2
|
+
/**
|
|
3
|
+
* @name addUSFederalReserveBankBusinessDays
|
|
4
|
+
* @summary Add or subtract the specified number of US Federal Reserve Bank business days to the given date.
|
|
5
|
+
*
|
|
6
|
+
* @description
|
|
7
|
+
* Add or subtract the specified number of US Federal Reserve Bank business days to the given date.
|
|
8
|
+
*
|
|
9
|
+
* @param plainDate - the date to be changed
|
|
10
|
+
* @param amount - the amount of business days to be added or subtracted. Positive amount will add the number of US
|
|
11
|
+
* Federal Reserve Bank business days and negative amount will subtract the number of US Federal Reserve Bank business days.
|
|
12
|
+
* @returns plainDate with the business days added/subtracted
|
|
13
|
+
*/
|
|
14
|
+
export default function (plainDate: PlainDate, amount: number): PlainDate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface FederalReserveBankHoliday {
|
|
2
|
+
name: string;
|
|
3
|
+
date: string;
|
|
4
|
+
observedOn?: string | undefined;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* @name getAllUSFederalReserveBankHolidays
|
|
8
|
+
* @summary Get all US Federal Rserve Bank Holidays for the year
|
|
9
|
+
*
|
|
10
|
+
* @description
|
|
11
|
+
* US Federal Reserve Bank is closed on the holidays outlined in https://www.federalreserve.gov/aboutthefed/k8.htm.
|
|
12
|
+
* If a holiday falls on a Sunday, it's observed the following Monday.
|
|
13
|
+
* This function calculates all the US Federal Reserve Bank holidays for a given year.
|
|
14
|
+
*
|
|
15
|
+
* @param year - the year for which US Federal Bank Holidays should be calculated for
|
|
16
|
+
* @returns list of holiday name and actual or observed date of US Federal Reserve Bank holidays for the given year
|
|
17
|
+
*/
|
|
18
|
+
export default function (year: number): FederalReserveBankHoliday[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as addUSFederalReserveBankBusinessDays } from './add-us-federal-reserve-bank-business-days';
|
|
2
|
+
export { default as getAllUSFederalReserveBankHolidays } from './get-all-us-federal-reserve-bank-holidays';
|
|
3
|
+
export { default as isUSFederalReserveBankClosed } from './is-us-federal-reserve-bank-closed';
|
|
4
|
+
export { PlainDate } from './plain-date';
|
package/dist/holidays/united-states/federal-reserve-bank/is-us-federal-reserve-bank-closed.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PlainDate } from './index';
|
|
2
|
+
/**
|
|
3
|
+
* @name isUSFederalReserveBankClosed
|
|
4
|
+
* @summary Is the US Federal Reserve Bank Closed?
|
|
5
|
+
*
|
|
6
|
+
* @description
|
|
7
|
+
* US Federal Reserve Bank is closed on United States weekends and holidays outlined in
|
|
8
|
+
* https://www.federalreserve.gov/aboutthefed/k8.htm. This function checks if the US Federal Reserve Bank is closed
|
|
9
|
+
* on a given date.
|
|
10
|
+
*
|
|
11
|
+
* @param plainDate - the date to be checked
|
|
12
|
+
* @returns boolean indicating if the US Federal Reserve Bank is closed on a given date
|
|
13
|
+
*/
|
|
14
|
+
export default function (plainDate: PlainDate): boolean;
|
package/dist/holidays/united-states/federal-reserve-bank/is-us-federal-reserve-bank-closed.spec.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED