DIY가 가능한 작은 시계를 만들어보았다!
function getTime(){
let time = new Date();
let hours = time.getHours();
let minutes = time.getMinutes();
let seconds = time.getSeconds();
}
function working(){
getTime ();
setInterval(getTime, 1000);
}
const makeRandColor = () => {
const r = Math.floor(Math.random() * 255);
const g = Math.floor(Math.random() * 255);
const b = Math.floor(Math.random() * 255);
if(r+g+b < 280){
clock.style.color = 'white';
optionDay.style.color = 'white';
optionDan.style.color = 'white';
} else {
clock.style.color = 'black';
optionDay.style.color = 'black';
optionDan.style.color = 'black';
}
return `rgb(${r},${g},${b})`;
}
rgb <200
으로는 부족한 것 같아서 범위를 조금 더 늘렸다. 그럼에도 다소 어두운 색을 잡아낼 수 없어서 아쉬웠다.dateBtn.addEventListener('click', () =>{
optionDay.innerText = `${year}.${month <10? `0${month}` : month}.${date}.${day}`;
optionDay.classList.toggle('op');
})
display:none
을 on,off했다.halfBtn.addEventListener('click', () => {
if(hours > 12){
optionDan.innerText = 'pm'
} else {
optionDan.innerText = 'am'
}
optionDan.classList.toggle('op');
})