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.
- package/README.md +590 -1
- package/dist/age.d.ts +1 -10
- package/dist/age.d.ts.map +1 -1
- package/dist/calculate.d.ts.map +1 -1
- package/dist/calculate.js +24 -10
- package/dist/constants.d.ts +2 -21
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +12 -13
- package/dist/countdown.d.ts +217 -0
- package/dist/countdown.d.ts.map +1 -0
- package/dist/countdown.js +298 -0
- package/dist/dateRange.d.ts +266 -0
- package/dist/dateRange.d.ts.map +1 -0
- package/dist/dateRange.js +433 -0
- 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/calculate.d.ts.map +1 -1
- package/dist/esm/calculate.js +24 -10
- 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/countdown.d.ts +217 -0
- package/dist/esm/countdown.d.ts.map +1 -0
- package/dist/esm/countdown.js +298 -0
- package/dist/esm/dateRange.d.ts +266 -0
- package/dist/esm/dateRange.d.ts.map +1 -0
- package/dist/esm/dateRange.js +433 -0
- 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 +14 -6
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +16 -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/naturalLanguage.d.ts +107 -0
- package/dist/esm/naturalLanguage.d.ts.map +1 -0
- package/dist/esm/naturalLanguage.js +344 -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/recurrence.d.ts +149 -0
- package/dist/esm/recurrence.d.ts.map +1 -0
- package/dist/esm/recurrence.js +404 -0
- 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 +250 -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 +14 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -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/naturalLanguage.d.ts +107 -0
- package/dist/naturalLanguage.d.ts.map +1 -0
- package/dist/naturalLanguage.js +344 -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/recurrence.d.ts +149 -0
- package/dist/recurrence.d.ts.map +1 -0
- package/dist/recurrence.js +404 -0
- 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 +250 -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 +67 -3
|
@@ -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,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