forked from ShoroukAziz/notion_widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
greetings-date-clock.html
171 lines (141 loc) · 3.1 KB
/
greetings-date-clock.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<!-- original : https://codepen.io/SeanNorton/pen/LWBXQL -->
<!DOCTYPE html>
<html lang="en">
<head>
<link href="https://fonts.googleapis.com/css2?family=Dancing+Script:wght@700&family=Bebas+Neue" rel="stylesheet">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>greeting2</title>
<style>
/*CSS RESETS*/
body{
background-color: #fff;
line-height: 1.6;
}
h1 {
margin-top: 0;
}
/*CSS START*/
.full-table {
display: table;
height: 100%;
width: 100%;
}
.table-cell {
display: table-cell;
vertical-align: middle;
text-align: center;
}
.card {
padding: 10px 25px 10px 25px;
border-radius: 10px;
background: #553c4e;
width: 85vw;
color: #fff;
display: inline-block;
box-shadow: 2px 2px 1px 0px #330835;
}
.card:hover {
margin-top: 2px;
box-shadow: none;
}
.clock {
display: inline;
font-family: 'Bebas Neue', cursive;
font-size: 2em;
}
.time {
display: inline;
min-width: 37px;
}
.colon {
font-size: 1.1em;
display: inline-block;
}
.date {
display: inline;
min-width: 162px;
font-family: 'Bebas Neue', cursive;
font-size: 2em;
padding-right: 30px;
}
.greet{
display:inline;
font-family: 'Dancing Script', cursive;
font-size: 2rem;
padding-right: 30px;
}
</style>
</head>
<body>
<link href="https://fonts.googleapis.com/css?family=Lobster|Roboto:400,700" rel="stylesheet">
<div class="full-table">
<div class="table-cell">
<div class="card">
<div class="greet" id="greet"></div>
<div class="date" id="date"></div>
<div class="clock">
<div class="time" id="hour"></div>
<div class="colon">:</div>
<div class="time" id="min"></div>
<div class="colon">:</div>
<div class="time" id="sec"></div>
</div>
</div>
</div>
</div>
<script>
function date() {
var today = new Date();
document.getElementById('date').innerHTML = today.toDateString();
}
function clock() {
var today = new Date();
var hour = zeros(twelveHour(today.getHours()));
var minutes = zeros(today.getMinutes());
var seconds = zeros(today.getSeconds());
if(today.getHours() >=12){
seconds+=" pm"
}
else{
seconds+=" am"
}
hrs = today.getHours();
if (hrs < 12)
greet = 'Good Morning ';
else if (hrs >= 12 && hrs <= 17)
greet = 'Good Afternoon ';
else if (hrs >= 17 && hrs <= 24)
greet = 'Good Evening ';
// console.log(today.toLocaleTimeString());
document.getElementById('greet').innerHTML = greet;
document.getElementById('hour').innerHTML = hour;
document.getElementById('min').innerHTML = minutes;
document.getElementById('sec').innerHTML = seconds;
}
function twelveHour(hour) {
if (hour > 12) {
return hour -= 12
} else if (hour === 0) {
return hour = 12;
} else {
return hour
}
}
// adds zero infront of single digit number
function zeros(num) {
if (num < 10) {
num = '0' + num
};
return num;
}
function dateTime() {
date();
clock();
setTimeout(dateTime, 500);
}
dateTime()
// END
</script>
</body>
</html>