From 62ddcfdb678567f1168d665129c88fc50b7f8158 Mon Sep 17 00:00:00 2001 From: mileswa1q2 <115095719+mileswolfallen2@users.noreply.github.com> Date: Wed, 29 Nov 2023 17:32:23 +0000 Subject: [PATCH] idk --- clok/cloc.css | 28 +++++++++++++++++++++++++ clok/clok.html | 16 ++++++++++++++ clok/idk.js | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ index.html | 1 + 4 files changed, 102 insertions(+) create mode 100644 clok/cloc.css create mode 100644 clok/clok.html create mode 100644 clok/idk.js diff --git a/clok/cloc.css b/clok/cloc.css new file mode 100644 index 00000000..510e7a97 --- /dev/null +++ b/clok/cloc.css @@ -0,0 +1,28 @@ +/*font family from google fonts*/ +@import url("https://fonts.googleapis.com/css2?family=Oswald:wght@300;400&display=swap"); + +html { + font-size: 62.5%; /*62.5% = 10px; to make it easier to calculate REM units.*/ +} +body { + text-align: center; + font-family: "Oswald", sans-serif; + font-weight: 300; + font-size: 2.2rem; + display: flex; + justify-content: center; + align-items: center; + background-color: #faedcd; + height: 100vh; +} +#clock {max-width: 600px;} + +/* for smaller screens below 700px */ +@media only screen and (max-width: 700px) { + body {font-size: 1.8rem;} +} + +/*for smaller screens below 300px*/ +@media only screen and (max-width: 300px) { + body {font-size: 1.6rem;} +} \ No newline at end of file diff --git a/clok/clok.html b/clok/clok.html new file mode 100644 index 00000000..17fe8591 --- /dev/null +++ b/clok/clok.html @@ -0,0 +1,16 @@ + + + + + + + Document + + + +
+

+
+ + + \ No newline at end of file diff --git a/clok/idk.js b/clok/idk.js new file mode 100644 index 00000000..5a6e8c71 --- /dev/null +++ b/clok/idk.js @@ -0,0 +1,57 @@ +window.addEventListener("load", () => { + clock(); + function clock() { + const today = new Date(); + + // get time components + const hours = today.getHours(); + const minutes = today.getMinutes(); + const seconds = today.getSeconds(); + + //add '0' to hour, minute & second when they are less 10 + const hour = hours < 10 ? "0" + hours : hours; + const minute = minutes < 10 ? "0" + minutes : minutes; + const second = seconds < 10 ? "0" + seconds : seconds; + + //make clock a 12-hour time clock + const hourTime = hour > 12 ? hour - 12 : hour; + + // if (hour === 0) { + // hour = 12; + // } + //assigning 'am' or 'pm' to indicate time of the day + const ampm = hour < 12 ? "AM" : "PM"; + + // get date components + const month = today.getMonth(); + const year = today.getFullYear(); + const day = today.getDate(); + + //declaring a list of all months in a year + const monthList = [ + "January", + "February", + "March", + "April", + "May", + "June", + "July", + "August", + "September", + "October", + "November", + "December" + ]; + + //get current date and time + const date = monthList[month] + " " + day + ", " + year; + const time = hourTime + ":" + minute + ":" + second + ampm; + + //combine current date and time + const dateTime = date + " - " + time; + + //print current date and time to the DOM + document.getElementById("date-time").innerHTML = dateTime; + setTimeout(clock, 1000); + } + }); \ No newline at end of file diff --git a/index.html b/index.html index 4e630a32..422e7453 100644 --- a/index.html +++ b/index.html @@ -21,6 +21,7 @@ login sinup coments inportend miless +clock