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 2025-09-24 16:45:58 +05:30
parent 9ee8f301ed
commit 9e1fe2e363
No known key found for this signature in database
GPG key ID: C8463F2BFEB63A18
2 changed files with 13 additions and 4 deletions

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;