-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcount.js
36 lines (29 loc) · 887 Bytes
/
count.js
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
// the very latest in election detection
exports.TimeLeft = function() {
var USElectionDay = new Date ("Nov 8, 2016, 19:00 GMT-0500");
var now = new Date();
var remaining = USElectionDay - now;
var seconds = 1000;
var minutes = seconds * 60;
var hours = minutes * 60;
var days = hours * 24;
var blurb = " There are " +
DaysLeft() + " days, " +
HoursLeft() + " hours, " +
MinsLeft() + " minutes, " +
SecsLeft() + " seconds until the 2016 U.S. general election is over. " +
"Don't forget to vote! 🇺🇸" ;
return blurb;
function SecsLeft () {
return Math.floor((remaining % minutes)/seconds);
}
function MinsLeft () {
return Math.floor((remaining % hours) / minutes).toString();
}
function HoursLeft () {
return Math.floor((remaining % days) / hours).toString();
}
function DaysLeft () {
return Math.floor(remaining / days).toString();
}
}