mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 23:27:12 +01:00
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:
parent
9ee8f301ed
commit
9e1fe2e363
2 changed files with 13 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue