dashboard-nanobot/frontend/src/utils/systemTimezones.ts

29 lines
772 B
TypeScript

export interface SystemTimezoneOption {
value: string;
}
const PRIMARY_SYSTEM_TIMEZONE_OPTIONS: SystemTimezoneOption[] = [
{ value: 'Asia/Shanghai' },
{ value: 'Europe/London' },
{ value: 'Europe/Berlin' },
{ value: 'America/New_York' },
{ value: 'America/Los_Angeles' },
{ value: 'Asia/Tokyo' },
];
export function getSystemTimezoneOptions(currentValue?: string): SystemTimezoneOption[] {
const normalized = String(currentValue || '').trim();
if (!normalized) {
return [...PRIMARY_SYSTEM_TIMEZONE_OPTIONS];
}
if (PRIMARY_SYSTEM_TIMEZONE_OPTIONS.some((option) => option.value === normalized)) {
return [...PRIMARY_SYSTEM_TIMEZONE_OPTIONS];
}
return [
{
value: normalized,
},
...PRIMARY_SYSTEM_TIMEZONE_OPTIONS,
];
}