ts-time-utils 0.0.1 → 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.
Files changed (100) hide show
  1. package/README.md +590 -1
  2. package/dist/age.d.ts +1 -10
  3. package/dist/age.d.ts.map +1 -1
  4. package/dist/calculate.d.ts.map +1 -1
  5. package/dist/calculate.js +24 -10
  6. package/dist/constants.d.ts +2 -21
  7. package/dist/constants.d.ts.map +1 -1
  8. package/dist/constants.js +12 -13
  9. package/dist/countdown.d.ts +217 -0
  10. package/dist/countdown.d.ts.map +1 -0
  11. package/dist/countdown.js +298 -0
  12. package/dist/dateRange.d.ts +266 -0
  13. package/dist/dateRange.d.ts.map +1 -0
  14. package/dist/dateRange.js +433 -0
  15. package/dist/duration.d.ts +171 -0
  16. package/dist/duration.d.ts.map +1 -0
  17. package/dist/duration.js +382 -0
  18. package/dist/esm/age.d.ts +1 -10
  19. package/dist/esm/age.d.ts.map +1 -1
  20. package/dist/esm/calculate.d.ts.map +1 -1
  21. package/dist/esm/calculate.js +24 -10
  22. package/dist/esm/constants.d.ts +2 -21
  23. package/dist/esm/constants.d.ts.map +1 -1
  24. package/dist/esm/constants.js +12 -13
  25. package/dist/esm/countdown.d.ts +217 -0
  26. package/dist/esm/countdown.d.ts.map +1 -0
  27. package/dist/esm/countdown.js +298 -0
  28. package/dist/esm/dateRange.d.ts +266 -0
  29. package/dist/esm/dateRange.d.ts.map +1 -0
  30. package/dist/esm/dateRange.js +433 -0
  31. package/dist/esm/duration.d.ts +171 -0
  32. package/dist/esm/duration.d.ts.map +1 -0
  33. package/dist/esm/duration.js +382 -0
  34. package/dist/esm/format.d.ts.map +1 -1
  35. package/dist/esm/index.d.ts +14 -6
  36. package/dist/esm/index.d.ts.map +1 -1
  37. package/dist/esm/index.js +16 -0
  38. package/dist/esm/interval.d.ts +3 -6
  39. package/dist/esm/interval.d.ts.map +1 -1
  40. package/dist/esm/locale.d.ts +94 -0
  41. package/dist/esm/locale.d.ts.map +1 -0
  42. package/dist/esm/locale.js +1087 -0
  43. package/dist/esm/naturalLanguage.d.ts +107 -0
  44. package/dist/esm/naturalLanguage.d.ts.map +1 -0
  45. package/dist/esm/naturalLanguage.js +344 -0
  46. package/dist/esm/performance.d.ts +2 -9
  47. package/dist/esm/performance.d.ts.map +1 -1
  48. package/dist/esm/performance.js +7 -8
  49. package/dist/esm/rangePresets.d.ts +7 -8
  50. package/dist/esm/rangePresets.d.ts.map +1 -1
  51. package/dist/esm/rangePresets.js +11 -9
  52. package/dist/esm/recurrence.d.ts +149 -0
  53. package/dist/esm/recurrence.d.ts.map +1 -0
  54. package/dist/esm/recurrence.js +404 -0
  55. package/dist/esm/serialize.d.ts +73 -0
  56. package/dist/esm/serialize.d.ts.map +1 -0
  57. package/dist/esm/serialize.js +365 -0
  58. package/dist/esm/timezone.d.ts +2 -6
  59. package/dist/esm/timezone.d.ts.map +1 -1
  60. package/dist/esm/timezone.js +1 -1
  61. package/dist/esm/types.d.ts +250 -0
  62. package/dist/esm/types.d.ts.map +1 -0
  63. package/dist/esm/types.js +25 -0
  64. package/dist/esm/workingHours.d.ts +4 -13
  65. package/dist/esm/workingHours.d.ts.map +1 -1
  66. package/dist/esm/workingHours.js +3 -1
  67. package/dist/format.d.ts.map +1 -1
  68. package/dist/index.d.ts +14 -6
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.js +16 -0
  71. package/dist/interval.d.ts +3 -6
  72. package/dist/interval.d.ts.map +1 -1
  73. package/dist/locale.d.ts +94 -0
  74. package/dist/locale.d.ts.map +1 -0
  75. package/dist/locale.js +1087 -0
  76. package/dist/naturalLanguage.d.ts +107 -0
  77. package/dist/naturalLanguage.d.ts.map +1 -0
  78. package/dist/naturalLanguage.js +344 -0
  79. package/dist/performance.d.ts +2 -9
  80. package/dist/performance.d.ts.map +1 -1
  81. package/dist/performance.js +7 -8
  82. package/dist/rangePresets.d.ts +7 -8
  83. package/dist/rangePresets.d.ts.map +1 -1
  84. package/dist/rangePresets.js +11 -9
  85. package/dist/recurrence.d.ts +149 -0
  86. package/dist/recurrence.d.ts.map +1 -0
  87. package/dist/recurrence.js +404 -0
  88. package/dist/serialize.d.ts +73 -0
  89. package/dist/serialize.d.ts.map +1 -0
  90. package/dist/serialize.js +365 -0
  91. package/dist/timezone.d.ts +2 -6
  92. package/dist/timezone.d.ts.map +1 -1
  93. package/dist/timezone.js +1 -1
  94. package/dist/types.d.ts +250 -0
  95. package/dist/types.d.ts.map +1 -0
  96. package/dist/types.js +25 -0
  97. package/dist/workingHours.d.ts +4 -13
  98. package/dist/workingHours.d.ts.map +1 -1
  99. package/dist/workingHours.js +3 -1
  100. package/package.json +67 -3
@@ -0,0 +1,365 @@
1
+ /**
2
+ * Safe JSON date serialization and deserialization utilities
3
+ */
4
+ /**
5
+ * Safely serialize a date to JSON with various format options
6
+ */
7
+ export function serializeDate(date, options = {}) {
8
+ const { format = 'iso', includeTimezone = false, useUTC = false, precision = 'milliseconds', customFormat } = options;
9
+ const dateObj = normalizeDate(date);
10
+ if (!dateObj) {
11
+ throw new Error('Invalid date provided for serialization');
12
+ }
13
+ const workingDate = useUTC ? new Date(dateObj.getTime()) : dateObj;
14
+ switch (format) {
15
+ case 'iso':
16
+ return workingDate.toISOString();
17
+ case 'epoch':
18
+ return toEpochTimestamp(workingDate, precision);
19
+ case 'object':
20
+ return toDateObject(workingDate, includeTimezone);
21
+ case 'custom':
22
+ if (!customFormat) {
23
+ throw new Error('Custom format string required when format is "custom"');
24
+ }
25
+ return formatCustom(workingDate, customFormat);
26
+ default:
27
+ return workingDate.toISOString();
28
+ }
29
+ }
30
+ /**
31
+ * Safely deserialize a date from various formats
32
+ */
33
+ export function deserializeDate(serializedDate, options = {}) {
34
+ const { useUTC = false } = options;
35
+ try {
36
+ if (typeof serializedDate === 'string') {
37
+ return parseISOString(serializedDate, useUTC);
38
+ }
39
+ if (typeof serializedDate === 'number') {
40
+ if (isNaN(serializedDate)) {
41
+ return null;
42
+ }
43
+ return fromEpochTimestamp(serializedDate, options.precision || 'milliseconds');
44
+ }
45
+ if (typeof serializedDate === 'object' && serializedDate !== null) {
46
+ try {
47
+ return fromDateObject(serializedDate);
48
+ }
49
+ catch {
50
+ return null;
51
+ }
52
+ }
53
+ return null;
54
+ }
55
+ catch (error) {
56
+ return null;
57
+ }
58
+ }
59
+ /**
60
+ * Create a safe JSON reviver function for automatic date parsing
61
+ */
62
+ export function createDateReviver(dateKeys = ['createdAt', 'updatedAt', 'date', 'timestamp'], options = {}) {
63
+ return (key, value) => {
64
+ if (dateKeys.includes(key) && (typeof value === 'string' || typeof value === 'number')) {
65
+ const parsed = deserializeDate(value, options);
66
+ return parsed || value; // Return original value if parsing fails
67
+ }
68
+ return value;
69
+ };
70
+ }
71
+ /**
72
+ * Create a safe JSON replacer function for automatic date serialization
73
+ */
74
+ export function createDateReplacer(dateKeys = ['createdAt', 'updatedAt', 'date', 'timestamp'], options = {}) {
75
+ return (key, value) => {
76
+ if (dateKeys.includes(key)) {
77
+ if (value instanceof Date) {
78
+ return serializeDate(value, options);
79
+ }
80
+ // Handle case where Date was already converted to ISO string by JSON.stringify
81
+ if (typeof value === 'string' && isValidISODateString(value)) {
82
+ const date = parseISOString(value);
83
+ if (date) {
84
+ return serializeDate(date, options);
85
+ }
86
+ }
87
+ }
88
+ return value;
89
+ };
90
+ }
91
+ /**
92
+ * Parse ISO string with better error handling
93
+ */
94
+ export function parseISOString(isoString, useUTC = false) {
95
+ if (!isoString || typeof isoString !== 'string') {
96
+ return null;
97
+ }
98
+ // Handle various ISO formats
99
+ const cleanedString = isoString.trim();
100
+ // Check for valid ISO format
101
+ const isoRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?$/;
102
+ if (!isoRegex.test(cleanedString)) {
103
+ // Try to parse anyway, but be more forgiving
104
+ const relaxedRegex = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d{3})?(?:Z|[+-]\d{2}:\d{2})?)?$/;
105
+ if (!relaxedRegex.test(cleanedString)) {
106
+ return null;
107
+ }
108
+ }
109
+ try {
110
+ const date = new Date(cleanedString);
111
+ if (isNaN(date.getTime())) {
112
+ return null;
113
+ }
114
+ return useUTC ? new Date(date.getTime() + (date.getTimezoneOffset() * 60000)) : date;
115
+ }
116
+ catch {
117
+ return null;
118
+ }
119
+ }
120
+ /**
121
+ * Convert date to epoch timestamp with specified precision
122
+ */
123
+ export function toEpochTimestamp(date, precision = 'milliseconds') {
124
+ const dateObj = normalizeDate(date);
125
+ if (!dateObj) {
126
+ throw new Error('Invalid date provided for epoch conversion');
127
+ }
128
+ const ms = dateObj.getTime();
129
+ switch (precision) {
130
+ case 'seconds':
131
+ return Math.floor(ms / 1000);
132
+ case 'microseconds':
133
+ return ms * 1000; // JavaScript doesn't have true microsecond precision
134
+ case 'milliseconds':
135
+ default:
136
+ return ms;
137
+ }
138
+ }
139
+ /**
140
+ * Create date from epoch timestamp with specified precision
141
+ */
142
+ export function fromEpochTimestamp(timestamp, precision = 'milliseconds') {
143
+ let ms;
144
+ switch (precision) {
145
+ case 'seconds':
146
+ ms = timestamp * 1000;
147
+ break;
148
+ case 'microseconds':
149
+ ms = timestamp / 1000;
150
+ break;
151
+ case 'milliseconds':
152
+ default:
153
+ ms = timestamp;
154
+ break;
155
+ }
156
+ return new Date(ms);
157
+ }
158
+ /**
159
+ * Create epoch timestamp with metadata
160
+ */
161
+ export function createEpochTimestamp(date, precision = 'milliseconds', timezone) {
162
+ return {
163
+ timestamp: toEpochTimestamp(date, precision),
164
+ precision,
165
+ timezone
166
+ };
167
+ }
168
+ /**
169
+ * Convert date to safe object representation
170
+ */
171
+ export function toDateObject(date, includeTimezone = false) {
172
+ const dateObj = normalizeDate(date);
173
+ if (!dateObj) {
174
+ throw new Error('Invalid date provided for object conversion');
175
+ }
176
+ const obj = {
177
+ year: dateObj.getUTCFullYear(),
178
+ month: dateObj.getUTCMonth() + 1, // Convert to 1-12
179
+ day: dateObj.getUTCDate(),
180
+ hour: dateObj.getUTCHours(),
181
+ minute: dateObj.getUTCMinutes(),
182
+ second: dateObj.getUTCSeconds(),
183
+ millisecond: dateObj.getUTCMilliseconds()
184
+ };
185
+ if (includeTimezone) {
186
+ // Get timezone offset in minutes and convert to string format
187
+ const offset = dateObj.getTimezoneOffset();
188
+ const hours = Math.floor(Math.abs(offset) / 60);
189
+ const minutes = Math.abs(offset) % 60;
190
+ const sign = offset <= 0 ? '+' : '-';
191
+ obj.timezone = `${sign}${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
192
+ }
193
+ return obj;
194
+ }
195
+ /**
196
+ * Create date from object representation
197
+ */
198
+ export function fromDateObject(dateObj) {
199
+ // Validate required fields
200
+ if (!dateObj || typeof dateObj !== 'object') {
201
+ throw new Error('Invalid date object provided');
202
+ }
203
+ const { year, month, day, hour = 0, minute = 0, second = 0, millisecond = 0 } = dateObj;
204
+ if (!year || !month || !day) {
205
+ throw new Error('Date object must include year, month, and day');
206
+ }
207
+ // Validate ranges
208
+ if (month < 1 || month > 12) {
209
+ throw new Error('Month must be between 1 and 12');
210
+ }
211
+ if (day < 1 || day > 31) {
212
+ throw new Error('Day must be between 1 and 31');
213
+ }
214
+ if (hour < 0 || hour > 23) {
215
+ throw new Error('Hour must be between 0 and 23');
216
+ }
217
+ if (minute < 0 || minute > 59) {
218
+ throw new Error('Minute must be between 0 and 59');
219
+ }
220
+ if (second < 0 || second > 59) {
221
+ throw new Error('Second must be between 0 and 59');
222
+ }
223
+ if (millisecond < 0 || millisecond > 999) {
224
+ throw new Error('Millisecond must be between 0 and 999');
225
+ }
226
+ return new Date(Date.UTC(year, month - 1, day, hour, minute, second, millisecond));
227
+ }
228
+ /**
229
+ * Check if a string is a valid ISO date string for serialization
230
+ */
231
+ export function isValidISODateString(dateString) {
232
+ if (!dateString || typeof dateString !== 'string') {
233
+ return false;
234
+ }
235
+ const parsed = parseISOString(dateString);
236
+ return parsed !== null;
237
+ }
238
+ /**
239
+ * Check if a number is a valid epoch timestamp
240
+ */
241
+ export function isValidEpochTimestamp(timestamp, precision = 'milliseconds') {
242
+ if (typeof timestamp !== 'number' || isNaN(timestamp)) {
243
+ return false;
244
+ }
245
+ // Check reasonable bounds for timestamps
246
+ const now = Date.now();
247
+ let min, max;
248
+ switch (precision) {
249
+ case 'seconds':
250
+ min = 0; // Jan 1, 1970
251
+ max = Math.floor(now / 1000) + (50 * 365 * 24 * 60 * 60); // 50 years from now
252
+ break;
253
+ case 'microseconds':
254
+ min = 0;
255
+ max = now * 1000 + (50 * 365 * 24 * 60 * 60 * 1000 * 1000); // 50 years from now
256
+ break;
257
+ case 'milliseconds':
258
+ default:
259
+ min = 0; // Jan 1, 1970
260
+ max = now + (50 * 365 * 24 * 60 * 60 * 1000); // 50 years from now
261
+ break;
262
+ }
263
+ return timestamp >= min && timestamp <= max;
264
+ }
265
+ /**
266
+ * Clone a date safely (avoids reference issues)
267
+ */
268
+ export function cloneDate(date) {
269
+ const dateObj = normalizeDate(date);
270
+ return dateObj ? new Date(dateObj.getTime()) : null;
271
+ }
272
+ /**
273
+ * Compare two dates for equality (ignoring milliseconds if specified)
274
+ */
275
+ export function datesEqual(date1, date2, precision = 'milliseconds') {
276
+ const d1 = normalizeDate(date1);
277
+ const d2 = normalizeDate(date2);
278
+ if (!d1 || !d2) {
279
+ return false;
280
+ }
281
+ let time1 = d1.getTime();
282
+ let time2 = d2.getTime();
283
+ switch (precision) {
284
+ case 'seconds':
285
+ time1 = Math.floor(time1 / 1000);
286
+ time2 = Math.floor(time2 / 1000);
287
+ break;
288
+ case 'minutes':
289
+ time1 = Math.floor(time1 / 60000);
290
+ time2 = Math.floor(time2 / 60000);
291
+ break;
292
+ }
293
+ return time1 === time2;
294
+ }
295
+ /**
296
+ * Get current timestamp in various formats
297
+ */
298
+ export function now(format = 'date') {
299
+ const current = new Date();
300
+ switch (format) {
301
+ case 'iso':
302
+ return current.toISOString();
303
+ case 'epoch-ms':
304
+ return current.getTime();
305
+ case 'epoch-s':
306
+ return Math.floor(current.getTime() / 1000);
307
+ case 'date':
308
+ default:
309
+ return current;
310
+ }
311
+ }
312
+ /**
313
+ * Safely handle JSON parsing with date conversion
314
+ */
315
+ export function parseJSONWithDates(jsonString, dateKeys, options) {
316
+ try {
317
+ return JSON.parse(jsonString, createDateReviver(dateKeys, options));
318
+ }
319
+ catch (error) {
320
+ throw new Error(`Failed to parse JSON: ${error instanceof Error ? error.message : 'Unknown error'}`);
321
+ }
322
+ }
323
+ /**
324
+ * Safely handle JSON stringification with date conversion
325
+ */
326
+ export function stringifyWithDates(obj, dateKeys, options, space) {
327
+ try {
328
+ return JSON.stringify(obj, createDateReplacer(dateKeys, options), space);
329
+ }
330
+ catch (error) {
331
+ throw new Error(`Failed to stringify JSON: ${error instanceof Error ? error.message : 'Unknown error'}`);
332
+ }
333
+ }
334
+ // Helper functions
335
+ function normalizeDate(date) {
336
+ if (date instanceof Date) {
337
+ return isNaN(date.getTime()) ? null : date;
338
+ }
339
+ if (typeof date === 'string') {
340
+ const parsed = new Date(date);
341
+ return isNaN(parsed.getTime()) ? null : parsed;
342
+ }
343
+ if (typeof date === 'number') {
344
+ const parsed = new Date(date);
345
+ return isNaN(parsed.getTime()) ? null : parsed;
346
+ }
347
+ return null;
348
+ }
349
+ function formatCustom(date, format) {
350
+ // Simple custom formatter - can be extended
351
+ const formatMap = {
352
+ 'YYYY': date.getUTCFullYear().toString(),
353
+ 'MM': (date.getUTCMonth() + 1).toString().padStart(2, '0'),
354
+ 'DD': date.getUTCDate().toString().padStart(2, '0'),
355
+ 'HH': date.getUTCHours().toString().padStart(2, '0'),
356
+ 'mm': date.getUTCMinutes().toString().padStart(2, '0'),
357
+ 'ss': date.getUTCSeconds().toString().padStart(2, '0'),
358
+ 'SSS': date.getUTCMilliseconds().toString().padStart(3, '0')
359
+ };
360
+ let result = format;
361
+ for (const [token, value] of Object.entries(formatMap)) {
362
+ result = result.replace(new RegExp(token, 'g'), value);
363
+ }
364
+ return result;
365
+ }
@@ -1,11 +1,7 @@
1
1
  /**
2
- * Timezone utilities (rely on Intl API, fallbacks where possible)
2
+ * Timezone utilities using Intl API with fallbacks
3
3
  */
4
- export interface ZonedTime {
5
- date: Date;
6
- zone: string;
7
- offsetMinutes: number;
8
- }
4
+ import type { ZonedTime } from './types.js';
9
5
  /** Get offset (minutes) for a zone at a given date */
10
6
  export declare function getTimezoneOffset(zone: string, date?: Date): number | null;
11
7
  /** Format date/time in a zone */
@@ -1 +1 @@
1
- {"version":3,"file":"timezone.d.ts","sourceRoot":"","sources":["../../src/timezone.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,sDAAsD;AACtD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,IAAiB,GAAG,MAAM,GAAG,IAAI,CAgBtF;AAED,iCAAiC;AACjC,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,IAAI,CAAC,qBAA0B,GAAG,MAAM,CAG3G;AAED,yCAAyC;AACzC,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAIvE;AAED,qFAAqF;AACrF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;CAAE,GAAG,IAAI,CAoB9J;AAED,yDAAyD;AACzD,wBAAgB,eAAe,CA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AACzD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOrD;AAED,uEAAuE;AACvE,eAAO,MAAM,gBAAgB,UAK5B,CAAC;AAEF,0CAA0C;AAC1C,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,iDAAiD;AACjD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,IAAiB,GAAG,MAAM,GAAG,IAAI,CAKvG;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAI7E"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Timezone utilities (rely on Intl API, fallbacks where possible)
2
+ * Timezone utilities using Intl API with fallbacks
3
3
  */
4
4
  /** Get offset (minutes) for a zone at a given date */
5
5
  export function getTimezoneOffset(zone, date = new Date()) {
@@ -0,0 +1,250 @@
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
+ /** Recurrence frequency types */
108
+ export type RecurrenceFrequency = 'daily' | 'weekly' | 'monthly' | 'yearly';
109
+ /** Recurrence rule for repeating events (RRULE-inspired) */
110
+ export interface RecurrenceRule {
111
+ /** Frequency of recurrence */
112
+ frequency: RecurrenceFrequency;
113
+ /** Start date for the recurrence */
114
+ startDate: DateInput;
115
+ /** Interval between occurrences (default: 1) */
116
+ interval?: number;
117
+ /** Days of week (0=Sunday, 6=Saturday) */
118
+ byWeekday?: number[];
119
+ /** Days of month (1-31) */
120
+ byMonthDay?: number[];
121
+ /** Months of year (1-12) */
122
+ byMonth?: number[];
123
+ /** Number of occurrences (alternative to until) */
124
+ count?: number;
125
+ /** End date for recurrence (alternative to count) */
126
+ until?: DateInput;
127
+ }
128
+ /** Locale-specific formatting options */
129
+ export interface LocaleFormatOptions extends FormatOptions {
130
+ /** Calendar system to use */
131
+ calendar?: 'gregory' | 'islamic' | 'hebrew' | 'persian' | 'chinese';
132
+ /** Number system to use */
133
+ numberingSystem?: 'arab' | 'arabext' | 'bali' | 'beng' | 'latn';
134
+ }
135
+ /** Business calendar configuration */
136
+ export interface BusinessConfig {
137
+ /** Fiscal year start month (1-12) */
138
+ fiscalYearStart?: number;
139
+ /** Custom holidays */
140
+ holidays?: Date[];
141
+ /** Trading days override */
142
+ tradingDays?: number[];
143
+ /** Country code for built-in holidays */
144
+ country?: string;
145
+ }
146
+ /** Duration unit types */
147
+ export type DurationUnit = 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'months' | 'years';
148
+ /** Duration input configuration */
149
+ export interface DurationInput {
150
+ milliseconds?: number;
151
+ seconds?: number;
152
+ minutes?: number;
153
+ hours?: number;
154
+ days?: number;
155
+ weeks?: number;
156
+ months?: number;
157
+ years?: number;
158
+ }
159
+ /** Duration comparison result */
160
+ export type DurationComparison = -1 | 0 | 1;
161
+ /** Serialization format options */
162
+ export interface SerializationOptions {
163
+ /** Include timezone information */
164
+ includeTimezone?: boolean;
165
+ /** Use UTC for serialization */
166
+ useUTC?: boolean;
167
+ /** Custom date format */
168
+ format?: 'iso' | 'epoch' | 'object' | 'custom';
169
+ /** Precision for epoch timestamps */
170
+ precision?: 'milliseconds' | 'seconds' | 'microseconds';
171
+ /** Custom format string when format is 'custom' */
172
+ customFormat?: string;
173
+ }
174
+ /** Date object representation for safe serialization */
175
+ export interface DateObject {
176
+ year: number;
177
+ month: number;
178
+ day: number;
179
+ hour: number;
180
+ minute: number;
181
+ second: number;
182
+ millisecond: number;
183
+ timezone?: string;
184
+ }
185
+ /** Epoch timestamp with metadata */
186
+ export interface EpochTimestamp {
187
+ timestamp: number;
188
+ precision: 'milliseconds' | 'seconds' | 'microseconds';
189
+ timezone?: string;
190
+ }
191
+ /** Supported locales for internationalization */
192
+ 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';
193
+ /** Relative time units for localization */
194
+ export type RelativeTimeUnit = 'second' | 'seconds' | 'minute' | 'minutes' | 'hour' | 'hours' | 'day' | 'days' | 'week' | 'weeks' | 'month' | 'months' | 'year' | 'years';
195
+ /** Locale-specific configuration */
196
+ export interface LocaleConfig {
197
+ /** Locale identifier */
198
+ locale: SupportedLocale;
199
+ /** Date format patterns */
200
+ dateFormats?: {
201
+ short?: string;
202
+ medium?: string;
203
+ long?: string;
204
+ full?: string;
205
+ };
206
+ /** Time format patterns */
207
+ timeFormats?: {
208
+ short?: string;
209
+ medium?: string;
210
+ long?: string;
211
+ full?: string;
212
+ };
213
+ /** Relative time translations */
214
+ relativeTime?: {
215
+ future?: string;
216
+ past?: string;
217
+ units?: Partial<Record<RelativeTimeUnit, string>>;
218
+ };
219
+ /** Calendar-specific settings */
220
+ calendar?: {
221
+ weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
222
+ monthNames?: string[];
223
+ monthNamesShort?: string[];
224
+ dayNames?: string[];
225
+ dayNamesShort?: string[];
226
+ };
227
+ /** Number formatting */
228
+ numbers?: {
229
+ decimal?: string;
230
+ thousands?: string;
231
+ };
232
+ }
233
+ /** Relative time formatting options */
234
+ export interface RelativeTimeOptions {
235
+ /** Locale to use for formatting */
236
+ locale?: SupportedLocale;
237
+ /** Maximum unit to display (e.g., don't show years) */
238
+ maxUnit?: RelativeTimeUnit;
239
+ /** Minimum unit to display (e.g., don't show seconds) */
240
+ minUnit?: RelativeTimeUnit;
241
+ /** Number of decimal places for precise units */
242
+ precision?: number;
243
+ /** Use short forms (1h vs 1 hour) */
244
+ short?: boolean;
245
+ /** Use numeric format when possible */
246
+ numeric?: 'always' | 'auto';
247
+ /** Custom formatting style */
248
+ style?: 'long' | 'short' | 'narrow';
249
+ }
250
+ //# 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,qCAAqC;AACrC,MAAM,WAAW,Y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,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
+ }