Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Task - 2/IIB2019011/Clock.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<title>Clock</title>
<link rel="stylesheet" type="text/css" href="clock.css">
</head>
<body>
<div class="container">
<div class="digital_clock"></div>
<div class="date"></div>
</div>







<script type="text/javascript" src="clock.js"></script>
</body>
</html>
Binary file added Task - 2/IIB2019011/background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions Task - 2/IIB2019011/clock.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@import url('https://fonts.googleapis.com/css?family=Anton|Bangers&display=swap');

body {
background-image: url("background.jpg");
}

.digital_clock{
color: #66ff99;
font-family: 'Anton', sans-serif;
font-size: 56px;
text-align: center;
padding-top: 40px;
}

.date{
color: #66ff99;
font-size: 20px;
font-family: 'Bangers', cursive;
font-weight: 100;
text-align: center;
padding-bottom: 40px;
}

.container{
margin-top: 15%;
}

45 changes: 45 additions & 0 deletions Task - 2/IIB2019011/clock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function current_time(){
var date = new Date();
var hour = date.getHours();
var min = date.getMinutes();
var sec = date.getSeconds();
var sess = "AM";
var day = date.getDay(); //(0-6)
var dated = date.getDate(); //(1-31)
var year = date.getFullYear(); //YYYY
var month = date.getMonth() + 1; //(0-11)

day = correct_day(day);

if(hour >= 12) sess = "PM";
else sess = "AM";

hour = (hour == 0) ? 12 : ((hour > 12) ? (hour - 12): hour);

hour = formatted_time(hour);
min = formatted_time(min);
sec = formatted_time(sec);

document.querySelector(".digital_clock").innerText = hour + " : " + min + " : " + sec + " " + sess;
document.querySelector(".date").innerText = day + " " + dated + "-" + month + "-" + year;

setTimeout(current_time, 1000);

}

function formatted_time(c){
if(c < 10) return "0" + c;
else return c;
}

function correct_day(numb){
if(numb == 0) return "Sunday";
else if(numb == 1) return "Monday";
else if(numb == 2) return "Tuesday";
else if(numb == 3) return "Wednesday";
else if(numb == 4) return "Thursday";
else if(numb == 5) return "Friday";
else if(numb == 6) return "Saturday";
}

current_time();