@xbg.solutions/utils-timezone 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/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +15 -0
- package/lib/index.js.map +1 -0
- package/lib/timezone-calculator.d.ts +122 -0
- package/lib/timezone-calculator.d.ts.map +1 -0
- package/lib/timezone-calculator.js +340 -0
- package/lib/timezone-calculator.js.map +1 -0
- package/package.json +22 -0
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timezone Utilities
|
|
3
|
+
*
|
|
4
|
+
* Exports timezone calculation and validation utilities
|
|
5
|
+
*/
|
|
6
|
+
export { calculateTimezone, calculateTimezoneWithLogger, isValidTimezone, getCountryTimezones, getCountryInfo, type TimezoneCalculationOptions, type TimezoneCalculationResult } from './timezone-calculator';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,iBAAiB,EACjB,2BAA2B,EAC3B,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC/B,MAAM,uBAAuB,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Timezone Utilities
|
|
4
|
+
*
|
|
5
|
+
* Exports timezone calculation and validation utilities
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.getCountryInfo = exports.getCountryTimezones = exports.isValidTimezone = exports.calculateTimezoneWithLogger = exports.calculateTimezone = void 0;
|
|
9
|
+
var timezone_calculator_1 = require("./timezone-calculator");
|
|
10
|
+
Object.defineProperty(exports, "calculateTimezone", { enumerable: true, get: function () { return timezone_calculator_1.calculateTimezone; } });
|
|
11
|
+
Object.defineProperty(exports, "calculateTimezoneWithLogger", { enumerable: true, get: function () { return timezone_calculator_1.calculateTimezoneWithLogger; } });
|
|
12
|
+
Object.defineProperty(exports, "isValidTimezone", { enumerable: true, get: function () { return timezone_calculator_1.isValidTimezone; } });
|
|
13
|
+
Object.defineProperty(exports, "getCountryTimezones", { enumerable: true, get: function () { return timezone_calculator_1.getCountryTimezones; } });
|
|
14
|
+
Object.defineProperty(exports, "getCountryInfo", { enumerable: true, get: function () { return timezone_calculator_1.getCountryInfo; } });
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,6DAQ+B;AAP7B,wHAAA,iBAAiB,OAAA;AACjB,kIAAA,2BAA2B,OAAA;AAC3B,sHAAA,eAAe,OAAA;AACf,0HAAA,mBAAmB,OAAA;AACnB,qHAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timezone Calculator Utility
|
|
3
|
+
*
|
|
4
|
+
* Calculates IANA timezone from city and country.
|
|
5
|
+
* Strategy: Country-based lookup (offline, fast, good for MVP)
|
|
6
|
+
* Future: Can integrate Google Places/Timezone API for precision
|
|
7
|
+
*
|
|
8
|
+
* @module utilities/timezone
|
|
9
|
+
* @reusable - Can be used in any Node.js project
|
|
10
|
+
*/
|
|
11
|
+
import ct from 'countries-and-timezones';
|
|
12
|
+
/**
|
|
13
|
+
* Timezone calculation options
|
|
14
|
+
*/
|
|
15
|
+
export interface TimezoneCalculationOptions {
|
|
16
|
+
/** Fallback timezone if calculation fails (default: 'UTC') */
|
|
17
|
+
fallbackTimezone?: string;
|
|
18
|
+
/** Enable verbose logging (default: false) */
|
|
19
|
+
verbose?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Timezone calculation result
|
|
23
|
+
*/
|
|
24
|
+
export interface TimezoneCalculationResult {
|
|
25
|
+
/** Calculated IANA timezone (e.g., 'Australia/Sydney') */
|
|
26
|
+
timezone: string;
|
|
27
|
+
/** Whether fallback was used */
|
|
28
|
+
usedFallback: boolean;
|
|
29
|
+
/** Whether country has multiple timezones */
|
|
30
|
+
multipleTimezones: boolean;
|
|
31
|
+
/** All available timezones for the country (if multiple) */
|
|
32
|
+
availableTimezones?: string[];
|
|
33
|
+
/** Confidence level: 'high' (single TZ), 'medium' (multi TZ), 'low' (fallback) */
|
|
34
|
+
confidence: 'high' | 'medium' | 'low';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Calculate timezone from city and country
|
|
38
|
+
*
|
|
39
|
+
* @param city - City name (currently used for logging only; precision TBD in future)
|
|
40
|
+
* @param countryCode - ISO 3166-1 alpha-2 country code (e.g., 'AU', 'US', 'GB')
|
|
41
|
+
* @param options - Calculation options
|
|
42
|
+
* @returns Timezone calculation result
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const result = calculateTimezone('Sydney', 'AU');
|
|
47
|
+
* console.log(result.timezone); // 'Australia/Sydney'
|
|
48
|
+
* console.log(result.confidence); // 'high'
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const result = calculateTimezone('New York', 'US');
|
|
54
|
+
* console.log(result.timezone); // 'America/New_York' (first in list)
|
|
55
|
+
* console.log(result.confidence); // 'medium'
|
|
56
|
+
* console.log(result.multipleTimezones); // true
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function calculateTimezone(city: string, countryCode: string, options?: TimezoneCalculationOptions): TimezoneCalculationResult;
|
|
60
|
+
/**
|
|
61
|
+
* Validate if a timezone string is a valid IANA timezone
|
|
62
|
+
*
|
|
63
|
+
* @param timezone - Timezone string to validate
|
|
64
|
+
* @returns true if valid IANA timezone
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* isValidTimezone('Australia/Sydney'); // true
|
|
69
|
+
* isValidTimezone('Invalid/Timezone'); // false
|
|
70
|
+
* isValidTimezone('EST'); // false (abbreviations not allowed)
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function isValidTimezone(timezone: string): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Get all timezones for a country
|
|
76
|
+
*
|
|
77
|
+
* @param countryCode - ISO 3166-1 alpha-2 country code
|
|
78
|
+
* @returns Array of IANA timezones, or empty array if country not found
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* getCountryTimezones('AU');
|
|
83
|
+
* // ['Australia/Sydney', 'Australia/Melbourne', 'Australia/Brisbane', ...]
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function getCountryTimezones(countryCode: string): string[];
|
|
87
|
+
/**
|
|
88
|
+
* Get country information including timezones
|
|
89
|
+
*
|
|
90
|
+
* @param countryCode - ISO 3166-1 alpha-2 country code
|
|
91
|
+
* @returns Country data or null if not found
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const aus = getCountryInfo('AU');
|
|
96
|
+
* console.log(aus.name); // 'Australia'
|
|
97
|
+
* console.log(aus.timezones); // ['Australia/Sydney', ...]
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare function getCountryInfo(countryCode: string): ct.Country | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* Calculate timezone with logging support (for use with Logger instance)
|
|
103
|
+
*
|
|
104
|
+
* @param city - City name
|
|
105
|
+
* @param countryCode - ISO 3166-1 alpha-2 country code
|
|
106
|
+
* @param logger - Logger instance (optional)
|
|
107
|
+
* @returns Timezone calculation result
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* import { logger } from '@xbg/utils-logger';
|
|
112
|
+
*
|
|
113
|
+
* const result = calculateTimezoneWithLogger('Sydney', 'AU', logger);
|
|
114
|
+
* // Logs to your application logger
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export declare function calculateTimezoneWithLogger(city: string, countryCode: string, logger?: {
|
|
118
|
+
debug?: Function;
|
|
119
|
+
warn?: Function;
|
|
120
|
+
info?: Function;
|
|
121
|
+
}): TimezoneCalculationResult;
|
|
122
|
+
//# sourceMappingURL=timezone-calculator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timezone-calculator.d.ts","sourceRoot":"","sources":["../src/timezone-calculator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAuFzC;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,8DAA8D;IAC9D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,8CAA8C;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,YAAY,EAAE,OAAO,CAAC;IACtB,6CAA6C;IAC7C,iBAAiB,EAAE,OAAO,CAAC;IAC3B,4DAA4D;IAC5D,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,kFAAkF;IAClF,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,0BAA+B,GACvC,yBAAyB,CAgG3B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAczD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CASjE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,0BAGjD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,QAAQ,CAAC;IAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAAC,IAAI,CAAC,EAAE,QAAQ,CAAA;CAAE,GAC9D,yBAAyB,CA2E3B"}
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Timezone Calculator Utility
|
|
4
|
+
*
|
|
5
|
+
* Calculates IANA timezone from city and country.
|
|
6
|
+
* Strategy: Country-based lookup (offline, fast, good for MVP)
|
|
7
|
+
* Future: Can integrate Google Places/Timezone API for precision
|
|
8
|
+
*
|
|
9
|
+
* @module utilities/timezone
|
|
10
|
+
* @reusable - Can be used in any Node.js project
|
|
11
|
+
*/
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.calculateTimezone = calculateTimezone;
|
|
17
|
+
exports.isValidTimezone = isValidTimezone;
|
|
18
|
+
exports.getCountryTimezones = getCountryTimezones;
|
|
19
|
+
exports.getCountryInfo = getCountryInfo;
|
|
20
|
+
exports.calculateTimezoneWithLogger = calculateTimezoneWithLogger;
|
|
21
|
+
const countries_and_timezones_1 = __importDefault(require("countries-and-timezones"));
|
|
22
|
+
/**
|
|
23
|
+
* Australian city to timezone mapping (offline, high precision)
|
|
24
|
+
* Covers all major cities and state capitals for launch market
|
|
25
|
+
*/
|
|
26
|
+
const AUSTRALIAN_CITY_TIMEZONES = {
|
|
27
|
+
// New South Wales
|
|
28
|
+
'sydney': 'Australia/Sydney',
|
|
29
|
+
'newcastle': 'Australia/Sydney',
|
|
30
|
+
'wollongong': 'Australia/Sydney',
|
|
31
|
+
'centralcoast': 'Australia/Sydney',
|
|
32
|
+
'bluemountains': 'Australia/Sydney',
|
|
33
|
+
'canberra': 'Australia/Sydney', // ACT uses Sydney timezone
|
|
34
|
+
// Victoria
|
|
35
|
+
'melbourne': 'Australia/Melbourne',
|
|
36
|
+
'geelong': 'Australia/Melbourne',
|
|
37
|
+
'ballarat': 'Australia/Melbourne',
|
|
38
|
+
'bendigo': 'Australia/Melbourne',
|
|
39
|
+
// Queensland
|
|
40
|
+
'brisbane': 'Australia/Brisbane',
|
|
41
|
+
'goldcoast': 'Australia/Brisbane',
|
|
42
|
+
'sunshinecoast': 'Australia/Brisbane',
|
|
43
|
+
'townsville': 'Australia/Brisbane',
|
|
44
|
+
'cairns': 'Australia/Brisbane',
|
|
45
|
+
'toowoomba': 'Australia/Brisbane',
|
|
46
|
+
'rockhampton': 'Australia/Brisbane',
|
|
47
|
+
'mackay': 'Australia/Brisbane',
|
|
48
|
+
// Western Australia
|
|
49
|
+
'perth': 'Australia/Perth',
|
|
50
|
+
'fremantle': 'Australia/Perth',
|
|
51
|
+
'bunbury': 'Australia/Perth',
|
|
52
|
+
'geraldton': 'Australia/Perth',
|
|
53
|
+
'kalgoorlie': 'Australia/Perth',
|
|
54
|
+
'albany': 'Australia/Perth',
|
|
55
|
+
// South Australia
|
|
56
|
+
'adelaide': 'Australia/Adelaide',
|
|
57
|
+
'mountgambier': 'Australia/Adelaide',
|
|
58
|
+
'whyalla': 'Australia/Adelaide',
|
|
59
|
+
'portaugusta': 'Australia/Adelaide',
|
|
60
|
+
// Tasmania
|
|
61
|
+
'hobart': 'Australia/Hobart',
|
|
62
|
+
'launceston': 'Australia/Hobart',
|
|
63
|
+
'burnie': 'Australia/Hobart',
|
|
64
|
+
'devonport': 'Australia/Hobart',
|
|
65
|
+
// Northern Territory
|
|
66
|
+
'darwin': 'Australia/Darwin',
|
|
67
|
+
'alicesprings': 'Australia/Darwin',
|
|
68
|
+
'katherina': 'Australia/Darwin',
|
|
69
|
+
// Lord Howe Island (special case - UTC+10:30/+11)
|
|
70
|
+
'lordhowe': 'Australia/Lord_Howe',
|
|
71
|
+
'lordhoweisland': 'Australia/Lord_Howe',
|
|
72
|
+
// Broken Hill (NSW but uses SA time)
|
|
73
|
+
'brokenhill': 'Australia/Broken_Hill',
|
|
74
|
+
// Eucla (WA border town with unique timezone)
|
|
75
|
+
'eucla': 'Australia/Eucla'
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Normalize city name for lookup
|
|
79
|
+
* Removes spaces, hyphens, apostrophes and converts to lowercase
|
|
80
|
+
*/
|
|
81
|
+
function normalizeCityName(city) {
|
|
82
|
+
return city
|
|
83
|
+
.toLowerCase()
|
|
84
|
+
.trim()
|
|
85
|
+
.replace(/[\s\-']/g, ''); // Remove spaces, hyphens, apostrophes
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Look up timezone for Australian city
|
|
89
|
+
* Returns timezone if found, undefined if not in mapping
|
|
90
|
+
*/
|
|
91
|
+
function getAustralianCityTimezone(city) {
|
|
92
|
+
const normalized = normalizeCityName(city);
|
|
93
|
+
return AUSTRALIAN_CITY_TIMEZONES[normalized];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Calculate timezone from city and country
|
|
97
|
+
*
|
|
98
|
+
* @param city - City name (currently used for logging only; precision TBD in future)
|
|
99
|
+
* @param countryCode - ISO 3166-1 alpha-2 country code (e.g., 'AU', 'US', 'GB')
|
|
100
|
+
* @param options - Calculation options
|
|
101
|
+
* @returns Timezone calculation result
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const result = calculateTimezone('Sydney', 'AU');
|
|
106
|
+
* console.log(result.timezone); // 'Australia/Sydney'
|
|
107
|
+
* console.log(result.confidence); // 'high'
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const result = calculateTimezone('New York', 'US');
|
|
113
|
+
* console.log(result.timezone); // 'America/New_York' (first in list)
|
|
114
|
+
* console.log(result.confidence); // 'medium'
|
|
115
|
+
* console.log(result.multipleTimezones); // true
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
function calculateTimezone(city, countryCode, options = {}) {
|
|
119
|
+
const { fallbackTimezone = 'UTC', verbose = false } = options;
|
|
120
|
+
// Normalize country code
|
|
121
|
+
const normalizedCountryCode = countryCode.toUpperCase().trim();
|
|
122
|
+
if (verbose) {
|
|
123
|
+
console.log(`[TimezoneCalculator] Calculating timezone for: ${city}, ${normalizedCountryCode}`);
|
|
124
|
+
}
|
|
125
|
+
// Get country data
|
|
126
|
+
const country = countries_and_timezones_1.default.getCountry(normalizedCountryCode);
|
|
127
|
+
// Country not found - use fallback
|
|
128
|
+
if (!country || !country.timezones || country.timezones.length === 0) {
|
|
129
|
+
if (verbose) {
|
|
130
|
+
console.warn(`[TimezoneCalculator] Country not found or has no timezones: ${normalizedCountryCode}`);
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
timezone: fallbackTimezone,
|
|
134
|
+
usedFallback: true,
|
|
135
|
+
multipleTimezones: false,
|
|
136
|
+
confidence: 'low'
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
// Single timezone country - high confidence
|
|
140
|
+
if (country.timezones.length === 1) {
|
|
141
|
+
const timezone = country.timezones[0];
|
|
142
|
+
if (verbose) {
|
|
143
|
+
console.log(`[TimezoneCalculator] Single timezone country: ${timezone}`);
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
timezone,
|
|
147
|
+
usedFallback: false,
|
|
148
|
+
multipleTimezones: false,
|
|
149
|
+
confidence: 'high'
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
// Multiple timezone country - try city-level precision for Australia
|
|
153
|
+
if (normalizedCountryCode === 'AU' && city) {
|
|
154
|
+
const cityTimezone = getAustralianCityTimezone(city);
|
|
155
|
+
if (cityTimezone) {
|
|
156
|
+
if (verbose) {
|
|
157
|
+
console.log(`[TimezoneCalculator] Australian city matched: ${city} → ${cityTimezone}`);
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
timezone: cityTimezone,
|
|
161
|
+
usedFallback: false,
|
|
162
|
+
multipleTimezones: true,
|
|
163
|
+
availableTimezones: country.timezones,
|
|
164
|
+
confidence: 'high' // High confidence for city-level match
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
if (verbose) {
|
|
168
|
+
console.log(`[TimezoneCalculator] Australian city not in mapping: ${city}`);
|
|
169
|
+
console.log(`[TimezoneCalculator] Falling back to Sydney timezone (most populous)`);
|
|
170
|
+
}
|
|
171
|
+
// Fallback to Sydney for unknown Australian cities (most populous)
|
|
172
|
+
return {
|
|
173
|
+
timezone: 'Australia/Sydney',
|
|
174
|
+
usedFallback: false,
|
|
175
|
+
multipleTimezones: true,
|
|
176
|
+
availableTimezones: country.timezones,
|
|
177
|
+
confidence: 'medium'
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
// Multiple timezone country (non-AU) - use first (usually most populous)
|
|
181
|
+
const defaultTimezone = country.timezones[0];
|
|
182
|
+
if (verbose) {
|
|
183
|
+
console.log(`[TimezoneCalculator] Multi-timezone country: ${normalizedCountryCode}`);
|
|
184
|
+
console.log(`[TimezoneCalculator] Selected: ${defaultTimezone}`);
|
|
185
|
+
console.log(`[TimezoneCalculator] Available: ${country.timezones.join(', ')}`);
|
|
186
|
+
console.log(`[TimezoneCalculator] Note: Using default timezone for country.`);
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
timezone: defaultTimezone,
|
|
190
|
+
usedFallback: false,
|
|
191
|
+
multipleTimezones: true,
|
|
192
|
+
availableTimezones: country.timezones,
|
|
193
|
+
confidence: 'medium'
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Validate if a timezone string is a valid IANA timezone
|
|
198
|
+
*
|
|
199
|
+
* @param timezone - Timezone string to validate
|
|
200
|
+
* @returns true if valid IANA timezone
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```typescript
|
|
204
|
+
* isValidTimezone('Australia/Sydney'); // true
|
|
205
|
+
* isValidTimezone('Invalid/Timezone'); // false
|
|
206
|
+
* isValidTimezone('EST'); // false (abbreviations not allowed)
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
function isValidTimezone(timezone) {
|
|
210
|
+
try {
|
|
211
|
+
// Check if timezone follows IANA format (Region/City) or is UTC
|
|
212
|
+
// Reject abbreviations like EST, PST, GMT+10, etc.
|
|
213
|
+
if (timezone !== 'UTC' && !timezone.includes('/')) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
// Additional validation using Intl API
|
|
217
|
+
Intl.DateTimeFormat(undefined, { timeZone: timezone });
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
catch (_a) {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Get all timezones for a country
|
|
226
|
+
*
|
|
227
|
+
* @param countryCode - ISO 3166-1 alpha-2 country code
|
|
228
|
+
* @returns Array of IANA timezones, or empty array if country not found
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```typescript
|
|
232
|
+
* getCountryTimezones('AU');
|
|
233
|
+
* // ['Australia/Sydney', 'Australia/Melbourne', 'Australia/Brisbane', ...]
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
function getCountryTimezones(countryCode) {
|
|
237
|
+
const normalizedCountryCode = countryCode.toUpperCase().trim();
|
|
238
|
+
const country = countries_and_timezones_1.default.getCountry(normalizedCountryCode);
|
|
239
|
+
if (!country || !country.timezones) {
|
|
240
|
+
return [];
|
|
241
|
+
}
|
|
242
|
+
return country.timezones;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Get country information including timezones
|
|
246
|
+
*
|
|
247
|
+
* @param countryCode - ISO 3166-1 alpha-2 country code
|
|
248
|
+
* @returns Country data or null if not found
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```typescript
|
|
252
|
+
* const aus = getCountryInfo('AU');
|
|
253
|
+
* console.log(aus.name); // 'Australia'
|
|
254
|
+
* console.log(aus.timezones); // ['Australia/Sydney', ...]
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
function getCountryInfo(countryCode) {
|
|
258
|
+
const normalizedCountryCode = countryCode.toUpperCase().trim();
|
|
259
|
+
return countries_and_timezones_1.default.getCountry(normalizedCountryCode);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Calculate timezone with logging support (for use with Logger instance)
|
|
263
|
+
*
|
|
264
|
+
* @param city - City name
|
|
265
|
+
* @param countryCode - ISO 3166-1 alpha-2 country code
|
|
266
|
+
* @param logger - Logger instance (optional)
|
|
267
|
+
* @returns Timezone calculation result
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```typescript
|
|
271
|
+
* import { logger } from '@xbg/utils-logger';
|
|
272
|
+
*
|
|
273
|
+
* const result = calculateTimezoneWithLogger('Sydney', 'AU', logger);
|
|
274
|
+
* // Logs to your application logger
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
function calculateTimezoneWithLogger(city, countryCode, logger) {
|
|
278
|
+
var _a, _b, _c, _d, _e, _f;
|
|
279
|
+
const normalizedCountryCode = countryCode.toUpperCase().trim();
|
|
280
|
+
(_a = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _a === void 0 ? void 0 : _a.call(logger, 'Calculating timezone', { city, countryCode: normalizedCountryCode });
|
|
281
|
+
const country = countries_and_timezones_1.default.getCountry(normalizedCountryCode);
|
|
282
|
+
// Country not found
|
|
283
|
+
if (!country || !country.timezones || country.timezones.length === 0) {
|
|
284
|
+
(_b = logger === null || logger === void 0 ? void 0 : logger.warn) === null || _b === void 0 ? void 0 : _b.call(logger, 'Country not found or has no timezones', { countryCode: normalizedCountryCode });
|
|
285
|
+
return {
|
|
286
|
+
timezone: 'UTC',
|
|
287
|
+
usedFallback: true,
|
|
288
|
+
multipleTimezones: false,
|
|
289
|
+
confidence: 'low'
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
// Single timezone country
|
|
293
|
+
if (country.timezones.length === 1) {
|
|
294
|
+
const timezone = country.timezones[0];
|
|
295
|
+
(_c = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _c === void 0 ? void 0 : _c.call(logger, 'Single timezone country', { timezone });
|
|
296
|
+
return {
|
|
297
|
+
timezone,
|
|
298
|
+
usedFallback: false,
|
|
299
|
+
multipleTimezones: false,
|
|
300
|
+
confidence: 'high'
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
// Multiple timezone country - try city-level precision for Australia
|
|
304
|
+
if (normalizedCountryCode === 'AU' && city) {
|
|
305
|
+
const cityTimezone = getAustralianCityTimezone(city);
|
|
306
|
+
if (cityTimezone) {
|
|
307
|
+
(_d = logger === null || logger === void 0 ? void 0 : logger.debug) === null || _d === void 0 ? void 0 : _d.call(logger, 'Australian city matched', { city, timezone: cityTimezone });
|
|
308
|
+
return {
|
|
309
|
+
timezone: cityTimezone,
|
|
310
|
+
usedFallback: false,
|
|
311
|
+
multipleTimezones: true,
|
|
312
|
+
availableTimezones: country.timezones,
|
|
313
|
+
confidence: 'high'
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
(_e = logger === null || logger === void 0 ? void 0 : logger.info) === null || _e === void 0 ? void 0 : _e.call(logger, 'Australian city not in mapping, using Sydney default', { city });
|
|
317
|
+
return {
|
|
318
|
+
timezone: 'Australia/Sydney',
|
|
319
|
+
usedFallback: false,
|
|
320
|
+
multipleTimezones: true,
|
|
321
|
+
availableTimezones: country.timezones,
|
|
322
|
+
confidence: 'medium'
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
// Multiple timezone country (non-AU)
|
|
326
|
+
const defaultTimezone = country.timezones[0];
|
|
327
|
+
(_f = logger === null || logger === void 0 ? void 0 : logger.info) === null || _f === void 0 ? void 0 : _f.call(logger, 'Multi-timezone country - using default', {
|
|
328
|
+
countryCode: normalizedCountryCode,
|
|
329
|
+
selectedTimezone: defaultTimezone,
|
|
330
|
+
availableTimezones: country.timezones
|
|
331
|
+
});
|
|
332
|
+
return {
|
|
333
|
+
timezone: defaultTimezone,
|
|
334
|
+
usedFallback: false,
|
|
335
|
+
multipleTimezones: true,
|
|
336
|
+
availableTimezones: country.timezones,
|
|
337
|
+
confidence: 'medium'
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
//# sourceMappingURL=timezone-calculator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timezone-calculator.js","sourceRoot":"","sources":["../src/timezone-calculator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;AA0IH,8CAoGC;AAeD,0CAcC;AAcD,kDASC;AAeD,wCAGC;AAkBD,kEA+EC;AAnZD,sFAAyC;AAEzC;;;GAGG;AACH,MAAM,yBAAyB,GAA2B;IACxD,kBAAkB;IAClB,QAAQ,EAAE,kBAAkB;IAC5B,WAAW,EAAE,kBAAkB;IAC/B,YAAY,EAAE,kBAAkB;IAChC,cAAc,EAAE,kBAAkB;IAClC,eAAe,EAAE,kBAAkB;IACnC,UAAU,EAAE,kBAAkB,EAAE,2BAA2B;IAE3D,WAAW;IACX,WAAW,EAAE,qBAAqB;IAClC,SAAS,EAAE,qBAAqB;IAChC,UAAU,EAAE,qBAAqB;IACjC,SAAS,EAAE,qBAAqB;IAEhC,aAAa;IACb,UAAU,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AM,uBAAN,MAAM,CAAE,KAAK,uDAAG,yBAAyB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC;YAE7E,OAAO;gBACL,QAAQ,EAAE,YAAY;gBACtB,YAAY,EAAE,KAAK;gBACnB,iBAAiB,EAAE,IAAI;gBACvB,kBAAkB,EAAE,OAAO,CAAC,SAAS;gBACrC,UAAU,EAAE,MAAM;aACnB,CAAC;QACJ,CAAC;QAED,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,uDAAG,sDAAsD,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QAEjF,OAAO;YACL,QAAQ,EAAE,kBAAkB;YAC5B,YAAY,EAAE,KAAK;YACnB,iBAAiB,EAAE,IAAI;YACvB,kBAAkB,EAAE,OAAO,CAAC,SAAS;YACrC,UAAU,EAAE,QAAQ;SACrB,CAAC;IACJ,CAAC;IAED,qCAAqC;IACrC,MAAM,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAE7C,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,uDAAG,wCAAwC,EAAE;QACvD,WAAW,EAAE,qBAAqB;QAClC,gBAAgB,EAAE,eAAe;QACjC,kBAAkB,EAAE,OAAO,CAAC,SAAS;KACtC,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ,EAAE,eAAe;QACzB,YAAY,EAAE,KAAK;QACnB,iBAAiB,EAAE,IAAI;QACvB,kBAAkB,EAAE,OAAO,CAAC,SAAS;QACrC,UAAU,EAAE,QAAQ;KACrB,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xbg.solutions/utils-timezone",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Timezone conversion helper",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"files": ["lib"],
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"build:watch": "tsc --watch",
|
|
11
|
+
"clean": "rm -rf lib",
|
|
12
|
+
"prepublishOnly": "npm run build"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {"countries-and-timezones": "^3.6.0"},
|
|
15
|
+
"devDependencies": {"@types/node": "^20.11.0", "typescript": "^5.3.3"},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": "22"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
}
|
|
22
|
+
}
|