diff --git a/pages/index.js b/pages/index.js index c81db0b..65e5151 100644 --- a/pages/index.js +++ b/pages/index.js @@ -4,6 +4,7 @@ import Image from "next/image"; export default function Home() { const [input, setInput] = useState(); + const [isCurrentActive, setIsCurrentActive] = useState(true); const [weatherData, setWeatherData] = useState(); const clickHandler = async () => { @@ -24,10 +25,33 @@ export default function Home() { } }; + function degToCompass(num) { + var val = Math.floor(num / 22.5 + 0.5); + var arr = [ + "N", + "NNE", + "NE", + "ENE", + "E", + "ESE", + "SE", + "SSE", + "S", + "SSW", + "SW", + "WSW", + "W", + "WNW", + "NW", + "NNW", + ]; + return arr[val % 16]; + } + return (
Feels like {Math.round(weatherData.main.feels_like)}°
Humidity: {weatherData.main.humidity}
-Wind: {weatherData.wind.speed}
- > ++ Wind:{" "} + {`${weatherData.wind.speed} to ${ + weatherData.wind.gust + } ${degToCompass(weatherData.wind.deg)}`} +
++ Time:{" "} + {new Date( + weatherData.dt * 1000 + weatherData.timezone * 1000 + ).toLocaleString("en-US")} +
+Sunrise: {weatherData.sys.sunrise}
+Sunstet: {weatherData.sys.sunset}
+