Merge pull request #27 from KrishnaMoorthy12/fix-theme-clock
fixed theme clock showing 0:00 pm for 12 noon
This commit is contained in:
commit
76203b0fa1
@ -10,7 +10,7 @@ const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "
|
|||||||
|
|
||||||
toggle.addEventListener('click', (e) => {
|
toggle.addEventListener('click', (e) => {
|
||||||
const html = document.querySelector('html')
|
const html = document.querySelector('html')
|
||||||
if(html.classList.contains('dark')) {
|
if (html.classList.contains('dark')) {
|
||||||
html.classList.remove('dark')
|
html.classList.remove('dark')
|
||||||
e.target.innerHTML = 'Dark mode'
|
e.target.innerHTML = 'Dark mode'
|
||||||
} else {
|
} else {
|
||||||
@ -25,7 +25,7 @@ function setTime() {
|
|||||||
const day = time.getDay()
|
const day = time.getDay()
|
||||||
const date = time.getDate()
|
const date = time.getDate()
|
||||||
const hours = time.getHours()
|
const hours = time.getHours()
|
||||||
const hoursForClock = hours % 12
|
const hoursForClock = hours >= 13 ? hours % 12 : hours;
|
||||||
const minutes = time.getMinutes()
|
const minutes = time.getMinutes()
|
||||||
const seconds = time.getSeconds()
|
const seconds = time.getSeconds()
|
||||||
const ampm = hours >= 12 ? 'PM' : 'AM'
|
const ampm = hours >= 12 ? 'PM' : 'AM'
|
||||||
@ -41,7 +41,7 @@ function setTime() {
|
|||||||
// StackOverflow https://stackoverflow.com/questions/10756313/javascript-jquery-map-a-range-of-numbers-to-another-range-of-numbers
|
// StackOverflow https://stackoverflow.com/questions/10756313/javascript-jquery-map-a-range-of-numbers-to-another-range-of-numbers
|
||||||
const scale = (num, in_min, in_max, out_min, out_max) => {
|
const scale = (num, in_min, in_max, out_min, out_max) => {
|
||||||
return (num - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
return (num - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTime()
|
setTime()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user