SelectPage.js 2.87 KB
import React, { useCallback, useState } from "react";
import "../style/SelectPage.scss"

function SelectPage(props) {

    const today = new Date();
    
    const today_year = today.getFullYear();
    const today_month = today.getMonth();
    const today_date = today.getDate();

    const tomorrow = new Date(today.setDate(today.getDate() + 1)); 
    
    const tomorrow_year = tomorrow.getFullYear();
    const tomorrow_month = tomorrow.getMonth();
    const tomorrow_date = tomorrow.getDate(); 

    const [Time, setTime] = useState("00:00:00");

    const currentTime = () => {
        const date = new Date();
        const hours = String(date.getHours()).padStart(2, "0");
        const minutes = String(date.getMinutes()).padStart(2, "0");
        const seconds = String(date.getSeconds()).padStart(2, "0");
        setTime(hours+":"+minutes+":"+seconds);
      }
    
    const startTimer = () => {
    setInterval(currentTime, 1000)
    }

    startTimer()

    return (
        <> 
            <dir id = "header">
            <dir className="clock">
            <h1 id="clock">{Time}</h1>
            </dir>
            <dir className="title">
                <h1>Weather_Briefing</h1>
            </dir>
            <dir className="Login-Register">
                <button type="button" onclick="location.href='http://localhost:3000/login';">Login</button>
                <button type="button" onclick="location.href='http://localhost:3000/register';">Register</button>
            </dir>
        </dir>

        <div id = "body">
            <dir className="date">
                <p>경기도 용인시 서천구</p>
            </dir>
            <dir className="today_weather">
                <dir className="days">
                    <h1 id="today">오늘의 날씨</h1>
                    <h2 id="day">{today_year} {today_month + 1} {today_date}</h2>
                </dir>
                <dir className="weather">
                    <h1 id="present_do">14</h1>
                    <p id="maxmin_do">최고: 22  최저: 7</p>
                </dir>
            </dir>
            <dir className="tomorrow_weather">
                <dir className="days">
                    <h1 id="today">내일의 날씨</h1>
                    <h2 id="day">{tomorrow_year} {tomorrow_month + 1} {tomorrow_date}</h2>
                </dir>
                <dir className="weather">
                    <h1 id="present_do">50</h1>
                    <p id="maxmin_do">최고: 13  최저: 2</p>
                </dir>
            </dir>
        </div>

        <dir id = "footer">
            <dir className="logo">
            <h1>logo</h1>
            </dir>
            <dir className="info">
                <p>경희대학교</p>
                <p>컴퓨터공학과 김건희ㅣ오석진ㅣ손수민</p>
            </dir>
        </dir>
        </>
    );
}

export default SelectPage;