ts-time-utils 0.0.1 → 1.0.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/README.md +365 -1
- package/dist/age.d.ts +1 -10
- package/dist/age.d.ts.map +1 -1
- package/dist/constants.d.ts +2 -21
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +12 -13
- package/dist/duration.d.ts +171 -0
- package/dist/duration.d.ts.map +1 -0
- package/dist/duration.js +382 -0
- package/dist/esm/age.d.ts +1 -10
- package/dist/esm/age.d.ts.map +1 -1
- package/dist/esm/constants.d.ts +2 -21
- package/dist/esm/constants.d.ts.map +1 -1
- package/dist/esm/constants.js +12 -13
- package/dist/esm/duration.d.ts +171 -0
- package/dist/esm/duration.d.ts.map +1 -0
- package/dist/esm/duration.js +382 -0
- package/dist/esm/format.d.ts.map +1 -1
- package/dist/esm/index.d.ts +10 -6
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +8 -0
- package/dist/esm/interval.d.ts +3 -6
- package/dist/esm/interval.d.ts.map +1 -1
- package/dist/esm/locale.d.ts +94 -0
- package/dist/esm/locale.d.ts.map +1 -0
- package/dist/esm/locale.js +1087 -0
- package/dist/esm/performance.d.ts +2 -9
- package/dist/esm/performance.d.ts.map +1 -1
- package/dist/esm/performance.js +7 -8
- package/dist/esm/rangePresets.d.ts +7 -8
- package/dist/esm/rangePresets.d.ts.map +1 -1
- package/dist/esm/rangePresets.js +11 -9
- package/dist/esm/serialize.d.ts +73 -0
- package/dist/esm/serialize.d.ts.map +1 -0
- package/dist/esm/serialize.js +365 -0
- package/dist/esm/timezone.d.ts +2 -6
- package/dist/esm/timezone.d.ts.map +1 -1
- package/dist/esm/timezone.js +1 -1
- package/dist/esm/types.d.ts +229 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +25 -0
- package/dist/esm/workingHours.d.ts +4 -13
- package/dist/esm/workingHours.d.ts.map +1 -1
- package/dist/esm/workingHours.js +3 -1
- package/dist/format.d.ts.map +1 -1
- package/dist/index.d.ts +10 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/interval.d.ts +3 -6
- package/dist/interval.d.ts.map +1 -1
- package/dist/locale.d.ts +94 -0
- package/dist/locale.d.ts.map +1 -0
- package/dist/locale.js +1087 -0
- package/dist/performance.d.ts +2 -9
- package/dist/performance.d.ts.map +1 -1
- package/dist/performance.js +7 -8
- package/dist/rangePresets.d.ts +7 -8
- package/dist/rangePresets.d.ts.map +1 -1
- package/dist/rangePresets.js +11 -9
- package/dist/serialize.d.ts +73 -0
- package/dist/serialize.d.ts.map +1 -0
- package/dist/serialize.js +365 -0
- package/dist/timezone.d.ts +2 -6
- package/dist/timezone.d.ts.map +1 -1
- package/dist/timezone.js +1 -1
- package/dist/types.d.ts +229 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +25 -0
- package/dist/workingHours.d.ts +4 -13
- package/dist/workingHours.d.ts.map +1 -1
- package/dist/workingHours.js +3 -1
- package/package.json +39 -3
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types and interfaces used across ts-time-utils modules
|
|
3
|
+
*/
|
|
4
|
+
/** Input that can be converted to a Date */
|
|
5
|
+
export type DateInput = string | number | Date;
|
|
6
|
+
/** A date range with start and end dates */
|
|
7
|
+
export interface DateRange {
|
|
8
|
+
start: Date;
|
|
9
|
+
end: Date;
|
|
10
|
+
}
|
|
11
|
+
/** Options for parsing operations */
|
|
12
|
+
export interface ParseOptions {
|
|
13
|
+
/** Whether to use strict parsing (reject ambiguous formats) */
|
|
14
|
+
strict?: boolean;
|
|
15
|
+
/** Timezone to use for parsing */
|
|
16
|
+
timezone?: string;
|
|
17
|
+
/** Default locale for parsing */
|
|
18
|
+
locale?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Options for formatting operations */
|
|
21
|
+
export interface FormatOptions {
|
|
22
|
+
/** Use short format (abbreviated units) */
|
|
23
|
+
short?: boolean;
|
|
24
|
+
/** Maximum number of units to display */
|
|
25
|
+
maxUnits?: number;
|
|
26
|
+
/** Round fractional units */
|
|
27
|
+
round?: boolean;
|
|
28
|
+
/** Include milliseconds in output */
|
|
29
|
+
includeMs?: boolean;
|
|
30
|
+
/** Locale for formatting */
|
|
31
|
+
locale?: string;
|
|
32
|
+
}
|
|
33
|
+
/** Time units supported across the library */
|
|
34
|
+
export type TimeUnit = 'millisecond' | 'milliseconds' | 'ms' | 'second' | 'seconds' | 's' | 'minute' | 'minutes' | 'm' | 'hour' | 'hours' | 'h' | 'day' | 'days' | 'd' | 'week' | 'weeks' | 'w' | 'month' | 'months' | 'M' | 'year' | 'years' | 'y';
|
|
35
|
+
/** Standardized error types */
|
|
36
|
+
export declare class TimeUtilsError extends Error {
|
|
37
|
+
code?: string | undefined;
|
|
38
|
+
constructor(message: string, code?: string | undefined);
|
|
39
|
+
}
|
|
40
|
+
export declare class ParseError extends TimeUtilsError {
|
|
41
|
+
input?: unknown | undefined;
|
|
42
|
+
constructor(message: string, input?: unknown | undefined);
|
|
43
|
+
}
|
|
44
|
+
export declare class ValidationError extends TimeUtilsError {
|
|
45
|
+
value?: unknown | undefined;
|
|
46
|
+
constructor(message: string, value?: unknown | undefined);
|
|
47
|
+
}
|
|
48
|
+
/** Common validation function type */
|
|
49
|
+
export type DateValidator = (date: Date) => boolean;
|
|
50
|
+
/** Common date transformation function type */
|
|
51
|
+
export type DateTransformer = (date: Date) => Date;
|
|
52
|
+
/** Options for working hours calculations */
|
|
53
|
+
export interface WorkingHoursConfig {
|
|
54
|
+
/** Working days (0=Sunday, 1=Monday, etc.) */
|
|
55
|
+
workingDays: number[];
|
|
56
|
+
/** Working hours range */
|
|
57
|
+
hours: {
|
|
58
|
+
start: number;
|
|
59
|
+
end: number;
|
|
60
|
+
};
|
|
61
|
+
/** Break periods during working hours */
|
|
62
|
+
breaks?: {
|
|
63
|
+
start: number;
|
|
64
|
+
end: number;
|
|
65
|
+
}[];
|
|
66
|
+
/** Timezone for working hours calculation */
|
|
67
|
+
timezone?: string;
|
|
68
|
+
}
|
|
69
|
+
/** Result of age calculation */
|
|
70
|
+
export interface AgeResult {
|
|
71
|
+
years: number;
|
|
72
|
+
months: number;
|
|
73
|
+
days: number;
|
|
74
|
+
totalDays: number;
|
|
75
|
+
totalMonths: number;
|
|
76
|
+
}
|
|
77
|
+
/** Timezone information */
|
|
78
|
+
export interface ZonedTime {
|
|
79
|
+
date: Date;
|
|
80
|
+
zone: string;
|
|
81
|
+
offsetMinutes: number;
|
|
82
|
+
}
|
|
83
|
+
/** Interval between two points in time */
|
|
84
|
+
export interface Interval {
|
|
85
|
+
start: Date;
|
|
86
|
+
end: Date;
|
|
87
|
+
}
|
|
88
|
+
/** Performance benchmarking result */
|
|
89
|
+
export interface BenchmarkResult {
|
|
90
|
+
average: number;
|
|
91
|
+
min: number;
|
|
92
|
+
max: number;
|
|
93
|
+
total: number;
|
|
94
|
+
totalTime: number;
|
|
95
|
+
iterations: number;
|
|
96
|
+
}
|
|
97
|
+
/** Calendar event recurrence pattern */
|
|
98
|
+
export interface RecurrencePattern {
|
|
99
|
+
frequency: 'daily' | 'weekly' | 'monthly' | 'yearly';
|
|
100
|
+
interval?: number;
|
|
101
|
+
byWeekDay?: number[];
|
|
102
|
+
byMonthDay?: number[];
|
|
103
|
+
byMonth?: number[];
|
|
104
|
+
count?: number;
|
|
105
|
+
until?: Date;
|
|
106
|
+
}
|
|
107
|
+
/** Locale-specific formatting options */
|
|
108
|
+
export interface LocaleFormatOptions extends FormatOptions {
|
|
109
|
+
/** Calendar system to use */
|
|
110
|
+
calendar?: 'gregory' | 'islamic' | 'hebrew' | 'persian' | 'chinese';
|
|
111
|
+
/** Number system to use */
|
|
112
|
+
numberingSystem?: 'arab' | 'arabext' | 'bali' | 'beng' | 'latn';
|
|
113
|
+
}
|
|
114
|
+
/** Business calendar configuration */
|
|
115
|
+
export interface BusinessConfig {
|
|
116
|
+
/** Fiscal year start month (1-12) */
|
|
117
|
+
fiscalYearStart?: number;
|
|
118
|
+
/** Custom holidays */
|
|
119
|
+
holidays?: Date[];
|
|
120
|
+
/** Trading days override */
|
|
121
|
+
tradingDays?: number[];
|
|
122
|
+
/** Country code for built-in holidays */
|
|
123
|
+
country?: string;
|
|
124
|
+
}
|
|
125
|
+
/** Duration unit types */
|
|
126
|
+
export type DurationUnit = 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'months' | 'years';
|
|
127
|
+
/** Duration input configuration */
|
|
128
|
+
export interface DurationInput {
|
|
129
|
+
milliseconds?: number;
|
|
130
|
+
seconds?: number;
|
|
131
|
+
minutes?: number;
|
|
132
|
+
hours?: number;
|
|
133
|
+
days?: number;
|
|
134
|
+
weeks?: number;
|
|
135
|
+
months?: number;
|
|
136
|
+
years?: number;
|
|
137
|
+
}
|
|
138
|
+
/** Duration comparison result */
|
|
139
|
+
export type DurationComparison = -1 | 0 | 1;
|
|
140
|
+
/** Serialization format options */
|
|
141
|
+
export interface SerializationOptions {
|
|
142
|
+
/** Include timezone information */
|
|
143
|
+
includeTimezone?: boolean;
|
|
144
|
+
/** Use UTC for serialization */
|
|
145
|
+
useUTC?: boolean;
|
|
146
|
+
/** Custom date format */
|
|
147
|
+
format?: 'iso' | 'epoch' | 'object' | 'custom';
|
|
148
|
+
/** Precision for epoch timestamps */
|
|
149
|
+
precision?: 'milliseconds' | 'seconds' | 'microseconds';
|
|
150
|
+
/** Custom format string when format is 'custom' */
|
|
151
|
+
customFormat?: string;
|
|
152
|
+
}
|
|
153
|
+
/** Date object representation for safe serialization */
|
|
154
|
+
export interface DateObject {
|
|
155
|
+
year: number;
|
|
156
|
+
month: number;
|
|
157
|
+
day: number;
|
|
158
|
+
hour: number;
|
|
159
|
+
minute: number;
|
|
160
|
+
second: number;
|
|
161
|
+
millisecond: number;
|
|
162
|
+
timezone?: string;
|
|
163
|
+
}
|
|
164
|
+
/** Epoch timestamp with metadata */
|
|
165
|
+
export interface EpochTimestamp {
|
|
166
|
+
timestamp: number;
|
|
167
|
+
precision: 'milliseconds' | 'seconds' | 'microseconds';
|
|
168
|
+
timezone?: string;
|
|
169
|
+
}
|
|
170
|
+
/** Supported locales for internationalization */
|
|
171
|
+
export type SupportedLocale = 'en' | 'en-US' | 'en-GB' | 'en-CA' | 'en-AU' | 'es' | 'es-ES' | 'es-MX' | 'es-AR' | 'fr' | 'fr-FR' | 'fr-CA' | 'de' | 'de-DE' | 'de-AT' | 'de-CH' | 'it' | 'it-IT' | 'pt' | 'pt-PT' | 'pt-BR' | 'ru' | 'ru-RU' | 'zh' | 'zh-CN' | 'zh-TW' | 'ja' | 'ja-JP' | 'ko' | 'ko-KR' | 'ar' | 'ar-SA' | 'hi' | 'hi-IN' | 'tr' | 'tr-TR' | 'pl' | 'pl-PL' | 'nl' | 'nl-NL' | 'sv' | 'sv-SE' | 'da' | 'da-DK' | 'no' | 'no-NO' | 'fi' | 'fi-FI' | 'fa' | 'fa-IR';
|
|
172
|
+
/** Relative time units for localization */
|
|
173
|
+
export type RelativeTimeUnit = 'second' | 'seconds' | 'minute' | 'minutes' | 'hour' | 'hours' | 'day' | 'days' | 'week' | 'weeks' | 'month' | 'months' | 'year' | 'years';
|
|
174
|
+
/** Locale-specific configuration */
|
|
175
|
+
export interface LocaleConfig {
|
|
176
|
+
/** Locale identifier */
|
|
177
|
+
locale: SupportedLocale;
|
|
178
|
+
/** Date format patterns */
|
|
179
|
+
dateFormats?: {
|
|
180
|
+
short?: string;
|
|
181
|
+
medium?: string;
|
|
182
|
+
long?: string;
|
|
183
|
+
full?: string;
|
|
184
|
+
};
|
|
185
|
+
/** Time format patterns */
|
|
186
|
+
timeFormats?: {
|
|
187
|
+
short?: string;
|
|
188
|
+
medium?: string;
|
|
189
|
+
long?: string;
|
|
190
|
+
full?: string;
|
|
191
|
+
};
|
|
192
|
+
/** Relative time translations */
|
|
193
|
+
relativeTime?: {
|
|
194
|
+
future?: string;
|
|
195
|
+
past?: string;
|
|
196
|
+
units?: Partial<Record<RelativeTimeUnit, string>>;
|
|
197
|
+
};
|
|
198
|
+
/** Calendar-specific settings */
|
|
199
|
+
calendar?: {
|
|
200
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
201
|
+
monthNames?: string[];
|
|
202
|
+
monthNamesShort?: string[];
|
|
203
|
+
dayNames?: string[];
|
|
204
|
+
dayNamesShort?: string[];
|
|
205
|
+
};
|
|
206
|
+
/** Number formatting */
|
|
207
|
+
numbers?: {
|
|
208
|
+
decimal?: string;
|
|
209
|
+
thousands?: string;
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/** Relative time formatting options */
|
|
213
|
+
export interface RelativeTimeOptions {
|
|
214
|
+
/** Locale to use for formatting */
|
|
215
|
+
locale?: SupportedLocale;
|
|
216
|
+
/** Maximum unit to display (e.g., don't show years) */
|
|
217
|
+
maxUnit?: RelativeTimeUnit;
|
|
218
|
+
/** Minimum unit to display (e.g., don't show seconds) */
|
|
219
|
+
minUnit?: RelativeTimeUnit;
|
|
220
|
+
/** Number of decimal places for precise units */
|
|
221
|
+
precision?: number;
|
|
222
|
+
/** Use short forms (1h vs 1 hour) */
|
|
223
|
+
short?: boolean;
|
|
224
|
+
/** Use numeric format when possible */
|
|
225
|
+
numeric?: 'always' | 'auto';
|
|
226
|
+
/** Custom formatting style */
|
|
227
|
+
style?: 'long' | 'short' | 'narrow';
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,4CAA4C;AAC5C,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAE/C,4CAA4C;AAC5C,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,IAAI,CAAC;IACZ,GAAG,EAAE,IAAI,CAAC;CACX;AAED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AAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,CAAC;KACnD,CAAC;IACF,iCAAiC;IACjC,QAAQ,CAAC,EAAE;QACT,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACzC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QACtB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;QAC3B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;KAC1B,CAAC;IACF,wBAAwB;IACxB,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,uCAAuC;AACvC,MAAM,WAAW,mBAAmB;IAClC,mCAAmC;IACnC,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,uDAAuD;IACvD,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,yDAAyD;IACzD,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,uCAAuC;IACvC,OAAO,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC5B,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;CACrC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types and interfaces used across ts-time-utils modules
|
|
3
|
+
*/
|
|
4
|
+
/** Standardized error types */
|
|
5
|
+
export class TimeUtilsError extends Error {
|
|
6
|
+
constructor(message, code) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.name = 'TimeUtilsError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export class ParseError extends TimeUtilsError {
|
|
13
|
+
constructor(message, input) {
|
|
14
|
+
super(message, 'PARSE_ERROR');
|
|
15
|
+
this.input = input;
|
|
16
|
+
this.name = 'ParseError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export class ValidationError extends TimeUtilsError {
|
|
20
|
+
constructor(message, value) {
|
|
21
|
+
super(message, 'VALIDATION_ERROR');
|
|
22
|
+
this.value = value;
|
|
23
|
+
this.name = 'ValidationError';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
start: number;
|
|
6
|
-
end: number;
|
|
7
|
-
};
|
|
8
|
-
breaks?: {
|
|
9
|
-
start: number;
|
|
10
|
-
end: number;
|
|
11
|
-
}[];
|
|
12
|
-
timezone?: string;
|
|
13
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Working hours utilities for business time calculations
|
|
3
|
+
*/
|
|
4
|
+
import type { WorkingHoursConfig } from './types.js';
|
|
14
5
|
export declare const DEFAULT_WORKING_HOURS: WorkingHoursConfig;
|
|
15
6
|
/** Check if a date is a configured working day */
|
|
16
7
|
export declare function isWorkingDay(date: Date, config?: WorkingHoursConfig): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workingHours.d.ts","sourceRoot":"","sources":["../../src/workingHours.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"workingHours.d.ts","sourceRoot":"","sources":["../../src/workingHours.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,eAAO,MAAM,qBAAqB,EAAE,kBAInC,CAAC;AAEF,kDAAkD;AAClD,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,GAAE,kBAA0C,GAAG,OAAO,CAEpG;AAOD,uDAAuD;AACvD,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,GAAE,kBAA0C,GAAG,OAAO,CAUrG;AAED,+CAA+C;AAC/C,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,GAAE,kBAA0C,GAAG,IAAI,CAMpG;AAYD,kDAAkD;AAClD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAE,kBAA0C,GAAG,MAAM,CA+BrH;AAED,kEAAkE;AAClE,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,kBAA0C,GAAG,IAAI,CAcpH"}
|
package/dist/esm/workingHours.js
CHANGED
package/dist/format.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,aAAa,EACd,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,aAAa,EACd,MAAM,gBAAgB,CAAC;AAGxB;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,MAAM,CA2E9E;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,aAAkB,GAAG,MAAM,CA+CvE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,GAAE,KAAK,GAAG,KAAK,GAAG,KAAa,GAAG,MAAM,CAcpF;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAyDtD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,13 +5,17 @@
|
|
|
5
5
|
export { formatDuration, timeAgo, formatTime, parseDuration } from './format.js';
|
|
6
6
|
export { differenceInUnits, addTime, subtractTime, startOf, endOf, isBetween, businessDaysBetween } from './calculate.js';
|
|
7
7
|
export { isValidDate, isLeapYear, isPast, isFuture, isToday, isYesterday, isTomorrow, isSameDay, isWeekend, isWeekday, isValidTimeString, isValidISOString } from './validate.js';
|
|
8
|
-
export { calculateAge, getAgeInUnits, getLifeStage, getNextBirthday, getDaysUntilBirthday, isBirthday
|
|
8
|
+
export { calculateAge, getAgeInUnits, getLifeStage, getNextBirthday, getDaysUntilBirthday, isBirthday } from './age.js';
|
|
9
9
|
export { getWeekNumber, getWeekOfMonth, getQuarter, getDayOfYear, getWeeksInYear, getDaysInMonth, getDaysInYear, getEaster, getMonthsInYear, getDaysInMonthArray, getWeekdaysInMonth, getFirstDayOfMonth, getLastDayOfMonth, getFirstDayOfYear, getLastDayOfYear } from './calendar.js';
|
|
10
10
|
export { parseDate, parseRelativeDate, parseTimeAgo, parseCustomFormat, parseManyFormats } from './parse.js';
|
|
11
|
-
export { sleep, timeout, debounce, throttle, retry, createStopwatch, measureTime, measureAsync, benchmark, Stopwatch
|
|
12
|
-
export { createInterval, isValidInterval, intervalDuration, intervalContains, intervalsOverlap, intervalIntersection, mergeIntervals, subtractInterval, splitIntervalByDay, totalIntervalCoverage, normalizeIntervals
|
|
13
|
-
export { getTimezoneOffset, formatInTimeZone, getZonedTime, convertDateToZone, isValidTimeZone, COMMON_TIMEZONES, getLocalOffset, compareZoneOffsets, reinterpretAsZone
|
|
14
|
-
export { DEFAULT_WORKING_HOURS, isWorkingDay, isWorkingTime, nextWorkingTime, workingTimeBetween, addWorkingHours
|
|
15
|
-
export { today, yesterday, tomorrow, lastNDays, nextNDays, thisWeek, lastWeek, nextWeek, thisMonth, lastMonth, nextMonth, thisYear, lastYear, nextYear, rollingWindowDays, quarterRange, lastQuarter, nextQuarter, RANGE_PRESETS
|
|
11
|
+
export { sleep, timeout, debounce, throttle, retry, createStopwatch, measureTime, measureAsync, benchmark, Stopwatch } from './performance.js';
|
|
12
|
+
export { createInterval, isValidInterval, intervalDuration, intervalContains, intervalsOverlap, intervalIntersection, mergeIntervals, subtractInterval, splitIntervalByDay, totalIntervalCoverage, normalizeIntervals } from './interval.js';
|
|
13
|
+
export { getTimezoneOffset, formatInTimeZone, getZonedTime, convertDateToZone, isValidTimeZone, COMMON_TIMEZONES, getLocalOffset, compareZoneOffsets, reinterpretAsZone } from './timezone.js';
|
|
14
|
+
export { DEFAULT_WORKING_HOURS, isWorkingDay, isWorkingTime, nextWorkingTime, workingTimeBetween, addWorkingHours } from './workingHours.js';
|
|
15
|
+
export { today, yesterday, tomorrow, lastNDays, nextNDays, thisWeek, lastWeek, nextWeek, thisMonth, lastMonth, nextMonth, thisYear, lastYear, nextYear, rollingWindowDays, quarterRange, lastQuarter, nextQuarter, RANGE_PRESETS } from './rangePresets.js';
|
|
16
|
+
export { Duration, createDuration, isValidDuration, parseDurationString, formatDurationString, maxDuration, minDuration, sumDurations, averageDuration } from './duration.js';
|
|
17
|
+
export { serializeDate, deserializeDate, createDateReviver, createDateReplacer, parseISOString, toEpochTimestamp, fromEpochTimestamp, createEpochTimestamp, toDateObject, fromDateObject, isValidISODateString, isValidEpochTimestamp, cloneDate, datesEqual, now, parseJSONWithDates, stringifyWithDates } from './serialize.js';
|
|
18
|
+
export { registerLocale, getLocaleConfig, getSupportedLocales, formatRelativeTime, formatDateLocale, formatTimeLocale, formatDateTimeLocale, getMonthNames, getDayNames, getFirstDayOfWeek, isLocaleSupported, getBestMatchingLocale, detectLocale, convertRelativeTime, detectLocaleFromRelativeTime, convertFormatPattern, convertFormattedDate, convertRelativeTimeArray, compareLocaleFormats } from './locale.js';
|
|
16
19
|
export { MILLISECONDS_PER_SECOND, MILLISECONDS_PER_MINUTE, MILLISECONDS_PER_HOUR, MILLISECONDS_PER_DAY, MILLISECONDS_PER_WEEK, MILLISECONDS_PER_MONTH, MILLISECONDS_PER_YEAR, SECONDS_PER_MINUTE, SECONDS_PER_HOUR, SECONDS_PER_DAY, SECONDS_PER_WEEK, type TimeUnit, type FormatOptions } from './constants.js';
|
|
20
|
+
export type { DateInput, DateRange, ParseOptions, WorkingHoursConfig, AgeResult, ZonedTime, Interval, BenchmarkResult, RecurrencePattern, LocaleFormatOptions, BusinessConfig, DateValidator, DateTransformer, TimeUtilsError, ParseError, ValidationError, DurationUnit, DurationInput, DurationComparison, SerializationOptions, DateObject, EpochTimestamp, SupportedLocale, LocaleConfig, RelativeTimeOptions, RelativeTimeUnit } from './types.js';
|
|
17
21
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,cAAc,EACd,OAAO,EACP,UAAU,EACV,aAAa,EACd,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,iBAAiB,EACjB,OAAO,EACP,YAAY,EACZ,OAAO,EACP,KAAK,EACL,SAAS,EACT,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,OAAO,EACP,WAAW,EACX,UAAU,EACV,SAAS,EACT,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,eAAe,EACf,oBAAoB,EACpB,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,cAAc,EACd,OAAO,EACP,UAAU,EACV,aAAa,EACd,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,iBAAiB,EACjB,OAAO,EACP,YAAY,EACZ,OAAO,EACP,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ACV,SAAS,EACT,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,SAAS,EACT,QAAQ,EACR,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,eAAe,EACf,cAAc,EACd,UAAU,EACV,eAAe,EACf,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,UAAU,EACV,cAAc,EACd,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -24,5 +24,13 @@ export { getTimezoneOffset, formatInTimeZone, getZonedTime, convertDateToZone, i
|
|
|
24
24
|
export { DEFAULT_WORKING_HOURS, isWorkingDay, isWorkingTime, nextWorkingTime, workingTimeBetween, addWorkingHours } from './workingHours.js';
|
|
25
25
|
// Range preset utilities
|
|
26
26
|
export { today, yesterday, tomorrow, lastNDays, nextNDays, thisWeek, lastWeek, nextWeek, thisMonth, lastMonth, nextMonth, thisYear, lastYear, nextYear, rollingWindowDays, quarterRange, lastQuarter, nextQuarter, RANGE_PRESETS } from './rangePresets.js';
|
|
27
|
+
// Duration utilities
|
|
28
|
+
export { Duration, createDuration, isValidDuration, parseDurationString, formatDurationString, maxDuration, minDuration, sumDurations, averageDuration } from './duration.js';
|
|
29
|
+
// Serialization utilities
|
|
30
|
+
export { serializeDate, deserializeDate, createDateReviver, createDateReplacer, parseISOString, toEpochTimestamp, fromEpochTimestamp, createEpochTimestamp, toDateObject, fromDateObject, isValidISODateString, isValidEpochTimestamp, cloneDate, datesEqual, now, parseJSONWithDates, stringifyWithDates } from './serialize.js';
|
|
31
|
+
// Locale utilities
|
|
32
|
+
export { registerLocale, getLocaleConfig, getSupportedLocales, formatRelativeTime, formatDateLocale, formatTimeLocale, formatDateTimeLocale, getMonthNames, getDayNames, getFirstDayOfWeek, isLocaleSupported, getBestMatchingLocale, detectLocale,
|
|
33
|
+
// Conversion utilities
|
|
34
|
+
convertRelativeTime, detectLocaleFromRelativeTime, convertFormatPattern, convertFormattedDate, convertRelativeTimeArray, compareLocaleFormats } from './locale.js';
|
|
27
35
|
// Constants and types
|
|
28
36
|
export { MILLISECONDS_PER_SECOND, MILLISECONDS_PER_MINUTE, MILLISECONDS_PER_HOUR, MILLISECONDS_PER_DAY, MILLISECONDS_PER_WEEK, MILLISECONDS_PER_MONTH, MILLISECONDS_PER_YEAR, SECONDS_PER_MINUTE, SECONDS_PER_HOUR, SECONDS_PER_DAY, SECONDS_PER_WEEK } from './constants.js';
|
package/dist/interval.d.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Interval utilities: operations on time intervals [start, end)
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
start: Date;
|
|
6
|
-
end: Date;
|
|
7
|
-
}
|
|
4
|
+
import type { Interval, DateInput } from './types.js';
|
|
8
5
|
/** Create an interval ensuring start <= end */
|
|
9
|
-
export declare function createInterval(start:
|
|
6
|
+
export declare function createInterval(start: DateInput, end: DateInput): Interval | null;
|
|
10
7
|
/** Validate an object is a proper interval */
|
|
11
8
|
export declare function isValidInterval(i: any): i is Interval;
|
|
12
9
|
/** Duration of interval in ms */
|
|
13
10
|
export declare function intervalDuration(i: Interval): number;
|
|
14
11
|
/** Whether interval contains date (inclusive start, exclusive end) */
|
|
15
|
-
export declare function intervalContains(i: Interval, date:
|
|
12
|
+
export declare function intervalContains(i: Interval, date: DateInput): boolean;
|
|
16
13
|
/** Whether two intervals overlap */
|
|
17
14
|
export declare function intervalsOverlap(a: Interval, b: Interval): boolean;
|
|
18
15
|
/** Intersection of two intervals, or null */
|
package/dist/interval.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interval.d.ts","sourceRoot":"","sources":["../src/interval.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,
|
|
1
|
+
{"version":3,"file":"interval.d.ts","sourceRoot":"","sources":["../src/interval.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
package/dist/locale.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { DateInput, SupportedLocale, LocaleConfig, RelativeTimeOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Register a custom locale configuration
|
|
4
|
+
*/
|
|
5
|
+
export declare function registerLocale(config: LocaleConfig): void;
|
|
6
|
+
/**
|
|
7
|
+
* Get locale configuration, with fallback to base language or English
|
|
8
|
+
*/
|
|
9
|
+
export declare function getLocaleConfig(locale: SupportedLocale): LocaleConfig;
|
|
10
|
+
/**
|
|
11
|
+
* Get list of all registered locales
|
|
12
|
+
*/
|
|
13
|
+
export declare function getSupportedLocales(): SupportedLocale[];
|
|
14
|
+
/**
|
|
15
|
+
* Format relative time in the specified locale
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatRelativeTime(date: DateInput, options?: RelativeTimeOptions): string;
|
|
18
|
+
/**
|
|
19
|
+
* Format date in locale-specific format
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatDateLocale(date: DateInput, locale?: SupportedLocale, style?: 'short' | 'medium' | 'long' | 'full'): string;
|
|
22
|
+
/**
|
|
23
|
+
* Format time in locale-specific format
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatTimeLocale(date: DateInput, locale?: SupportedLocale, style?: 'short' | 'medium' | 'long' | 'full'): string;
|
|
26
|
+
/**
|
|
27
|
+
* Format both date and time in locale-specific format
|
|
28
|
+
*/
|
|
29
|
+
export declare function formatDateTimeLocale(date: DateInput, locale?: SupportedLocale, dateStyle?: 'short' | 'medium' | 'long' | 'full', timeStyle?: 'short' | 'medium' | 'long' | 'full'): string;
|
|
30
|
+
/**
|
|
31
|
+
* Get localized month names
|
|
32
|
+
*/
|
|
33
|
+
export declare function getMonthNames(locale?: SupportedLocale, short?: boolean): string[];
|
|
34
|
+
/**
|
|
35
|
+
* Get localized day names
|
|
36
|
+
*/
|
|
37
|
+
export declare function getDayNames(locale?: SupportedLocale, short?: boolean): string[];
|
|
38
|
+
/**
|
|
39
|
+
* Get the first day of week for a locale (0 = Sunday, 1 = Monday, etc.)
|
|
40
|
+
*/
|
|
41
|
+
export declare function getFirstDayOfWeek(locale?: SupportedLocale): number;
|
|
42
|
+
/**
|
|
43
|
+
* Check if a locale is supported
|
|
44
|
+
*/
|
|
45
|
+
export declare function isLocaleSupported(locale: string): locale is SupportedLocale;
|
|
46
|
+
/**
|
|
47
|
+
* Get the best matching locale from a list of preferences
|
|
48
|
+
*/
|
|
49
|
+
export declare function getBestMatchingLocale(preferences: string[], fallback?: SupportedLocale): SupportedLocale;
|
|
50
|
+
/**
|
|
51
|
+
* Auto-detect locale from browser or system (if available)
|
|
52
|
+
*/
|
|
53
|
+
export declare function detectLocale(fallback?: SupportedLocale): SupportedLocale;
|
|
54
|
+
/**
|
|
55
|
+
* Convert a relative time string from one locale to another
|
|
56
|
+
* Attempts to parse the relative time and reformat in target locale
|
|
57
|
+
*/
|
|
58
|
+
export declare function convertRelativeTime(relativeTimeString: string, fromLocale: SupportedLocale, toLocale: SupportedLocale): string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Detect the locale of a formatted relative time string
|
|
61
|
+
* Returns the most likely locale or null if detection fails
|
|
62
|
+
*/
|
|
63
|
+
export declare function detectLocaleFromRelativeTime(relativeTimeString: string): SupportedLocale | null;
|
|
64
|
+
/**
|
|
65
|
+
* Convert a date format pattern from one locale's convention to another
|
|
66
|
+
*/
|
|
67
|
+
export declare function convertFormatPattern(pattern: string, fromLocale: SupportedLocale, toLocale: SupportedLocale, style?: 'short' | 'medium' | 'long' | 'full'): string;
|
|
68
|
+
/**
|
|
69
|
+
* Convert a formatted date string from one locale to another
|
|
70
|
+
* Attempts to parse the date and reformat in target locale
|
|
71
|
+
*/
|
|
72
|
+
export declare function convertFormattedDate(formattedDate: string, fromLocale: SupportedLocale, toLocale: SupportedLocale, targetStyle?: 'short' | 'medium' | 'long' | 'full'): string | null;
|
|
73
|
+
/**
|
|
74
|
+
* Bulk convert an array of relative time strings to a different locale
|
|
75
|
+
*/
|
|
76
|
+
export declare function convertRelativeTimeArray(relativeTimeStrings: string[], fromLocale: SupportedLocale, toLocale: SupportedLocale): (string | null)[];
|
|
77
|
+
/**
|
|
78
|
+
* Get format pattern differences between two locales
|
|
79
|
+
*/
|
|
80
|
+
export declare function compareLocaleFormats(locale1: SupportedLocale, locale2: SupportedLocale): {
|
|
81
|
+
dateFormats: Record<string, {
|
|
82
|
+
locale1: string;
|
|
83
|
+
locale2: string;
|
|
84
|
+
}>;
|
|
85
|
+
timeFormats: Record<string, {
|
|
86
|
+
locale1: string;
|
|
87
|
+
locale2: string;
|
|
88
|
+
}>;
|
|
89
|
+
weekStartsOn: {
|
|
90
|
+
locale1: number;
|
|
91
|
+
locale2: number;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=locale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../src/locale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,mBAAmB,EAAoB,MAAM,YAAY,CAAC;AA6alH;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAQzD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,YAAY,CAcrE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,eAAe,EAAE,CAEvD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,SAAS,EACf,OAAO,GAAE,mBAAwB,GAChC,MAAM,CA6FR;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,SAAS,EACf,MAAM,GAAE,eAAsB,EAC9B,KAAK,GAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAiB,GACrD,MAAM,CAUR;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9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