chronos-ts 2.0.2 → 2.0.4

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.
@@ -1,290 +0,0 @@
1
- /**
2
- * ChronosTimezone - Timezone handling and conversions
3
- * @module ChronosTimezone
4
- */
5
- import { TimezoneInfo, TimezoneOffset, DSTransition } from '../types';
6
- /**
7
- * Common timezone identifiers
8
- */
9
- export declare const TIMEZONES: {
10
- readonly UTC: "UTC";
11
- readonly GMT: "GMT";
12
- readonly 'America/New_York': "America/New_York";
13
- readonly 'America/Chicago': "America/Chicago";
14
- readonly 'America/Denver': "America/Denver";
15
- readonly 'America/Los_Angeles': "America/Los_Angeles";
16
- readonly 'America/Phoenix': "America/Phoenix";
17
- readonly 'America/Anchorage': "America/Anchorage";
18
- readonly 'America/Toronto': "America/Toronto";
19
- readonly 'America/Vancouver': "America/Vancouver";
20
- readonly 'America/Mexico_City': "America/Mexico_City";
21
- readonly 'America/Sao_Paulo': "America/Sao_Paulo";
22
- readonly 'America/Buenos_Aires': "America/Buenos_Aires";
23
- readonly 'America/Lima': "America/Lima";
24
- readonly 'America/Bogota': "America/Bogota";
25
- readonly 'Europe/London': "Europe/London";
26
- readonly 'Europe/Paris': "Europe/Paris";
27
- readonly 'Europe/Berlin': "Europe/Berlin";
28
- readonly 'Europe/Madrid': "Europe/Madrid";
29
- readonly 'Europe/Rome': "Europe/Rome";
30
- readonly 'Europe/Amsterdam': "Europe/Amsterdam";
31
- readonly 'Europe/Brussels': "Europe/Brussels";
32
- readonly 'Europe/Vienna': "Europe/Vienna";
33
- readonly 'Europe/Warsaw': "Europe/Warsaw";
34
- readonly 'Europe/Prague': "Europe/Prague";
35
- readonly 'Europe/Moscow': "Europe/Moscow";
36
- readonly 'Europe/Istanbul': "Europe/Istanbul";
37
- readonly 'Europe/Athens': "Europe/Athens";
38
- readonly 'Europe/Helsinki': "Europe/Helsinki";
39
- readonly 'Europe/Stockholm': "Europe/Stockholm";
40
- readonly 'Europe/Oslo': "Europe/Oslo";
41
- readonly 'Europe/Copenhagen': "Europe/Copenhagen";
42
- readonly 'Europe/Dublin': "Europe/Dublin";
43
- readonly 'Europe/Zurich': "Europe/Zurich";
44
- readonly 'Asia/Tokyo': "Asia/Tokyo";
45
- readonly 'Asia/Shanghai': "Asia/Shanghai";
46
- readonly 'Asia/Hong_Kong': "Asia/Hong_Kong";
47
- readonly 'Asia/Singapore': "Asia/Singapore";
48
- readonly 'Asia/Seoul': "Asia/Seoul";
49
- readonly 'Asia/Taipei': "Asia/Taipei";
50
- readonly 'Asia/Bangkok': "Asia/Bangkok";
51
- readonly 'Asia/Jakarta': "Asia/Jakarta";
52
- readonly 'Asia/Manila': "Asia/Manila";
53
- readonly 'Asia/Kuala_Lumpur': "Asia/Kuala_Lumpur";
54
- readonly 'Asia/Ho_Chi_Minh': "Asia/Ho_Chi_Minh";
55
- readonly 'Asia/Dubai': "Asia/Dubai";
56
- readonly 'Asia/Kolkata': "Asia/Kolkata";
57
- readonly 'Asia/Mumbai': "Asia/Mumbai";
58
- readonly 'Asia/Karachi': "Asia/Karachi";
59
- readonly 'Asia/Dhaka': "Asia/Dhaka";
60
- readonly 'Asia/Tehran': "Asia/Tehran";
61
- readonly 'Asia/Riyadh': "Asia/Riyadh";
62
- readonly 'Asia/Jerusalem': "Asia/Jerusalem";
63
- readonly 'Australia/Sydney': "Australia/Sydney";
64
- readonly 'Australia/Melbourne': "Australia/Melbourne";
65
- readonly 'Australia/Brisbane': "Australia/Brisbane";
66
- readonly 'Australia/Perth': "Australia/Perth";
67
- readonly 'Australia/Adelaide': "Australia/Adelaide";
68
- readonly 'Pacific/Auckland': "Pacific/Auckland";
69
- readonly 'Pacific/Fiji': "Pacific/Fiji";
70
- readonly 'Pacific/Honolulu': "Pacific/Honolulu";
71
- readonly 'Africa/Cairo': "Africa/Cairo";
72
- readonly 'Africa/Johannesburg': "Africa/Johannesburg";
73
- readonly 'Africa/Lagos': "Africa/Lagos";
74
- readonly 'Africa/Nairobi': "Africa/Nairobi";
75
- readonly 'Africa/Casablanca': "Africa/Casablanca";
76
- };
77
- export type TimezoneId = keyof typeof TIMEZONES | string;
78
- /**
79
- * ChronosTimezone - Handles timezone operations and conversions
80
- *
81
- * This class provides comprehensive timezone handling including:
82
- * - Timezone information retrieval
83
- * - Offset calculations
84
- * - DST detection
85
- * - Timezone conversions
86
- *
87
- * @example
88
- * ```typescript
89
- * // Get timezone info
90
- * const tz = ChronosTimezone.create('America/New_York');
91
- * console.log(tz.offset); // -5 or -4 depending on DST
92
- *
93
- * // Check DST
94
- * console.log(tz.isDST(new Date())); // true/false
95
- *
96
- * // Convert between timezones
97
- * const utcDate = new Date();
98
- * const localDate = ChronosTimezone.convert(utcDate, 'UTC', 'America/New_York');
99
- * ```
100
- */
101
- export declare class ChronosTimezone {
102
- private _identifier;
103
- private _originalOffset;
104
- private _extraMinutes;
105
- private _cachedOffset;
106
- private _cachedDate;
107
- /**
108
- * Create a new ChronosTimezone
109
- */
110
- constructor(identifier?: TimezoneId);
111
- /**
112
- * Normalize timezone identifier
113
- */
114
- private _normalizeIdentifier;
115
- /**
116
- * Parse offset string to hours
117
- */
118
- private _parseOffsetString;
119
- /**
120
- * Create a timezone instance
121
- */
122
- static create(identifier?: TimezoneId): ChronosTimezone;
123
- /**
124
- * Create UTC timezone
125
- */
126
- static utc(): ChronosTimezone;
127
- /**
128
- * Create timezone from local system timezone
129
- */
130
- static local(): ChronosTimezone;
131
- /**
132
- * Create timezone from offset in hours
133
- */
134
- static fromOffset(offsetHours: number): ChronosTimezone;
135
- /**
136
- * Get the local system timezone identifier
137
- */
138
- static localIdentifier(): string;
139
- /**
140
- * Get timezone identifier
141
- * Returns the original offset string if created from an offset, otherwise returns the IANA identifier
142
- */
143
- get identifier(): string;
144
- /**
145
- * Get the internal IANA timezone identifier (used for Intl operations)
146
- */
147
- get ianaIdentifier(): string;
148
- /**
149
- * Get timezone name (alias for identifier)
150
- */
151
- get name(): string;
152
- /**
153
- * Get timezone abbreviation for a given date
154
- */
155
- getAbbreviation(date?: Date): string;
156
- /**
157
- * Get full timezone name for a given date
158
- */
159
- getFullName(date?: Date): string;
160
- /**
161
- * Get UTC offset in minutes for a given date
162
- */
163
- getOffsetMinutes(date?: Date): number;
164
- /**
165
- * Parse Intl formatter parts to components
166
- */
167
- private _parseIntlParts;
168
- /**
169
- * Get UTC offset in hours for a given date
170
- */
171
- getOffsetHours(date?: Date): number;
172
- /**
173
- * Get UTC offset as string (e.g., "+05:30", "-08:00")
174
- */
175
- getOffsetString(date?: Date): string;
176
- /**
177
- * Get complete offset information
178
- */
179
- getOffset(date?: Date): TimezoneOffset;
180
- /**
181
- * Check if DST is in effect for a given date
182
- */
183
- isDST(date?: Date): boolean;
184
- /**
185
- * Check if timezone observes DST
186
- */
187
- observesDST(): boolean;
188
- /**
189
- * Get the next DST transition
190
- */
191
- getNextDSTTransition(from?: Date): DSTransition | null;
192
- /**
193
- * Binary search to find exact DST transition time
194
- */
195
- private _findExactTransition;
196
- /**
197
- * Convert a date to this timezone (returns formatted string)
198
- */
199
- format(date: Date, formatOptions?: Intl.DateTimeFormatOptions): string;
200
- /**
201
- * Get date components in this timezone
202
- */
203
- getComponents(date: Date): {
204
- year: number;
205
- month: number;
206
- day: number;
207
- hour: number;
208
- minute: number;
209
- second: number;
210
- dayOfWeek: number;
211
- };
212
- /**
213
- * Convert a date from one timezone to another
214
- */
215
- static convert(date: Date, from: TimezoneId, to: TimezoneId): Date;
216
- /**
217
- * Convert a UTC date to this timezone
218
- */
219
- fromUTC(date: Date): Date;
220
- /**
221
- * Convert a date in this timezone to UTC
222
- */
223
- toUTC(date: Date): Date;
224
- /**
225
- * Get comprehensive timezone information
226
- */
227
- getInfo(date?: Date): TimezoneInfo;
228
- /**
229
- * Check if two timezones are equivalent at a given moment
230
- */
231
- equals(other: ChronosTimezone | string, date?: Date): boolean;
232
- /**
233
- * Check if this is the same timezone identifier
234
- */
235
- isSame(other: ChronosTimezone | string): boolean;
236
- /**
237
- * Get all available timezone identifiers
238
- * Note: This returns common timezones. Use Intl.supportedValuesOf('timeZone') for all.
239
- */
240
- static getAvailableTimezones(): string[];
241
- /**
242
- * Check if a timezone identifier is valid
243
- */
244
- static isValid(identifier: string): boolean;
245
- /**
246
- * Get timezones grouped by region
247
- */
248
- static getTimezonesByRegion(): Record<string, string[]>;
249
- /**
250
- * Find timezones that match a given offset
251
- */
252
- static findByOffset(offsetHours: number, date?: Date): ChronosTimezone[];
253
- /**
254
- * Get current time in a specific timezone
255
- */
256
- static now(identifier: TimezoneId): Date;
257
- /**
258
- * Convert to string
259
- */
260
- toString(): string;
261
- /**
262
- * Convert to JSON
263
- */
264
- toJSON(): object;
265
- /**
266
- * Get primitive value
267
- */
268
- valueOf(): string;
269
- }
270
- /**
271
- * Pre-created timezone instances for common timezones
272
- */
273
- export declare const Timezones: {
274
- readonly UTC: ChronosTimezone;
275
- readonly Local: ChronosTimezone;
276
- readonly Eastern: ChronosTimezone;
277
- readonly Central: ChronosTimezone;
278
- readonly Mountain: ChronosTimezone;
279
- readonly Pacific: ChronosTimezone;
280
- readonly London: ChronosTimezone;
281
- readonly Paris: ChronosTimezone;
282
- readonly Berlin: ChronosTimezone;
283
- readonly Tokyo: ChronosTimezone;
284
- readonly Shanghai: ChronosTimezone;
285
- readonly Singapore: ChronosTimezone;
286
- readonly Dubai: ChronosTimezone;
287
- readonly Mumbai: ChronosTimezone;
288
- readonly Sydney: ChronosTimezone;
289
- readonly Auckland: ChronosTimezone;
290
- };