Enhance timezone handling by adding normalization for 'Asia/Calcutta' to 'Asia/Kolkata' and updating validation schema to use normalized timezones.

This commit is contained in:
mcnaveen committed 2025-09-24 16:45:58 +05:30
1 parent 9ee8f301ed
commit 9e1fe2e363
2 files changed
+13 -4

No files matched your search

+10 -1
View File
@@ -104,9 +104,18 @@ const DATE_FUNCTIONS = {
},
};
const TIMEZONE_MAPPINGS: Record<string, string> = {
'Asia/Calcutta': 'Asia/Kolkata',
};
export function normalizeTimezone(timezone: string): string {
return TIMEZONE_MAPPINGS[timezone] || timezone;
}
export function isValidTimezone(timezone: string) {
try {
Intl.DateTimeFormat(undefined, { timeZone: timezone });
const normalizedTimezone = normalizeTimezone(timezone);
Intl.DateTimeFormat(undefined, { timeZone: normalizedTimezone });
return true;
} catch (error) {
return false;