Skip to content

Commit 77a45c7

Browse files
Update 05-Weather-App/script.js
Co-authored-by: Copilot <[email protected]>
1 parent 61db534 commit 77a45c7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

05-Weather-App/script.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,11 @@ setInterval(() => {
7979
const date = newdt.getDate();
8080
/* console.log(dy[day]); */
8181
/* console.log(hours); */
82-
const hrin12format = hours >= 13 ? hours % 12 : hours;
83-
const apmp = hours >= 12 ? "PM " : "AM";
82+
const hrin12format = hours === 0 ? 12 : (hours > 12 ? hours - 12 : hours);
83+
const apmp = hours >= 12 ? "PM" : "AM";
8484
const min = minutes < 10 ? "0" + minutes : minutes;
8585
const hrs = hrin12format < 10 ? "0" + hrin12format : hrin12format;
86-
const nhr = hrin12format == "00" ? "12" : hrin12format;
87-
time.innerHTML = ` <span class="tm">${nhr}:${min} ${apmp}</span>`;
86+
time.innerHTML = ` <span class="tm">${hrs}:${min} ${apmp}</span>`;
8887
dt.innerHTML = `<span class="dt1"> ${dy[day]}, ${date} ${mth[month]}</span>`;
8988
}, 1000);
9089

0 commit comments

Comments
 (0)