mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
- Updated import statements in various test files to use relative paths instead of absolute paths. - Adjusted import paths in UI components to ensure they correctly reference the Types and Models directories. - Ensured all components and tests are aligned with the new directory structure for better maintainability.
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import Timezone from "../../Types/Timezone";
|
|
import { DropdownOption } from "../Components/Dropdown/Dropdown";
|
|
import OneUptimeDate from "../../Types/Date";
|
|
|
|
export default class TimezoneUtil {
|
|
public static getTimezoneDropdownOptions(): DropdownOption[] {
|
|
let timezoneOptions: Array<string> = Object.keys(Timezone);
|
|
|
|
// order timezone by GMT offset.
|
|
|
|
timezoneOptions = timezoneOptions.sort((a: string, b: string) => {
|
|
const keyOfTimezoneA: keyof typeof Timezone = a as keyof typeof Timezone;
|
|
const keyOfTimezoneB: keyof typeof Timezone = b as keyof typeof Timezone;
|
|
|
|
return (
|
|
OneUptimeDate.getGmtOffsetByTimezone(Timezone[keyOfTimezoneA]) -
|
|
OneUptimeDate.getGmtOffsetByTimezone(Timezone[keyOfTimezoneB])
|
|
);
|
|
});
|
|
|
|
return timezoneOptions.map((key: string) => {
|
|
const keyOfTimezone: keyof typeof Timezone = key as keyof typeof Timezone;
|
|
|
|
const value: string =
|
|
Timezone && Timezone[keyOfTimezone]
|
|
? Timezone[keyOfTimezone].toString()
|
|
: "";
|
|
|
|
return {
|
|
value: value,
|
|
label: OneUptimeDate.getGmtOffsetFriendlyStringByTimezone(
|
|
Timezone[keyOfTimezone],
|
|
),
|
|
};
|
|
});
|
|
}
|
|
}
|