import { useState, useEffect } from "react"; import { BerlinClock } from "./BerlinClock"; import { DigitalClock } from "./DigitalClock"; import { useCurrentTime } from "../hooks/useCurrentTime"; import { dateToBerlin } from "../utils"; export function TimeConverter() { const { currentTime, setCurrentTime } = useCurrentTime(); const [useSystemTime, setUseSystemTime] = useState(false); const berlinClock = dateToBerlin(currentTime); useEffect(() => { if (!useSystemTime) return; const id = setInterval(() => { setCurrentTime(new Date()); }, 1000); return () => clearInterval(id); }, [useSystemTime, setCurrentTime]); return (