diff --git a/docs/src/components/DockerComposeGenerator/components/OtherOptions.tsx b/docs/src/components/DockerComposeGenerator/components/OtherOptions.tsx index 69b3a59c1..8d1efef0f 100644 --- a/docs/src/components/DockerComposeGenerator/components/OtherOptions.tsx +++ b/docs/src/components/DockerComposeGenerator/components/OtherOptions.tsx @@ -1,7 +1,24 @@ -import React from "react"; +import React, { useMemo } from "react"; import CodeInline from "@theme/CodeInline"; import styles from "../styles.module.css"; +const AUTO_TIMEZONE_VALUE = "__auto__"; + +function getTimezoneList(): string[] { + if (typeof Intl !== "undefined") { + const intl = Intl as typeof Intl & { + supportedValuesOf?: (key: string) => string[]; + }; + const supported = intl.supportedValuesOf?.("timeZone"); + if (supported && supported.length > 0) { + return [...supported].sort(); + } + } + + const fallback = Intl.DateTimeFormat().resolvedOptions().timeZone; + return fallback ? [fallback] : ["UTC"]; +} + interface Props { rtspPassword: string; timezone: string; @@ -21,6 +38,11 @@ export default function OtherOptions({ onTimezoneChange, onShmSizeChange, }: Props) { + const timezones = useMemo(() => getTimezoneList(), []); + const systemTimezone = + Intl.DateTimeFormat().resolvedOptions().timeZone || "Etc/UTC"; + const selectedValue = timezone || AUTO_TIMEZONE_VALUE; + return (

Other Options

@@ -29,14 +51,25 @@ export default function OtherOptions({ - onTimezoneChange(e.target.value)} - /> + className={`${styles.input} ${styles.select}`} + value={selectedValue} + onChange={(e) => + onTimezoneChange( + e.target.value === AUTO_TIMEZONE_VALUE ? "" : e.target.value + ) + } + > + + {timezones.map((tz) => ( + + ))} +