From b97f3b42e1bad5753728315b5c7ebdacf6f81172 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Mon, 6 Jan 2025 23:48:56 -0800 Subject: initial commit --- app/components/DateWeatherLinks.tsx | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 app/components/DateWeatherLinks.tsx (limited to 'app/components/DateWeatherLinks.tsx') diff --git a/app/components/DateWeatherLinks.tsx b/app/components/DateWeatherLinks.tsx new file mode 100644 index 0000000..1c004fa --- /dev/null +++ b/app/components/DateWeatherLinks.tsx @@ -0,0 +1,47 @@ +"use client"; + +import { useState, useEffect, useContext } from "react"; +import QuickLinks from "./QuickLinks"; +import { DataContext } from "@/lib/data-context"; + +export default function DateWeatherLinksWelcome() { + const [date, setDate] = useState(new Date()); + const data = useContext(DataContext); + + useEffect(() => { + const timer = setInterval(() => setDate(new Date()), 1000); + return () => clearInterval(timer); + }, []); + + return ( +
+
+
+

+ {date.toLocaleDateString(undefined, { + weekday: "long", + year: "numeric", + month: "long", + day: "numeric", + })} +

+

+ {date.toLocaleTimeString()} +

+
+
+

+ {data?.weather + ? Math.round(data.weather.temperature * (9 / 5) + 32) + "°F" + : "--"} +

+

+ {data?.weather ? data.weather.description : "--"} +

+
+
+
+ +
+ ); +} -- cgit v1.2.3-70-g09d2