-
Notifications
You must be signed in to change notification settings - Fork 9
/
BotDate.js
29 lines (26 loc) · 1.05 KB
/
BotDate.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
class BotDate {
getDateAndTime(which) {
var currentDate = new Date();
var day = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var date = currentDate.getDate();
var month = ["January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var year = currentDate.getFullYear();
var hour = currentDate.getHours();
var min = currentDate.getMinutes();
var def = "th ";
switch (which) {
case "date":
if (date === 3 || date === 23) {
def = "rd ";
} else if (date === 1 || date === 21) {
def = "st ";
} else if (date === 2 || date === 22) {
def = "nd ";
}
return day[currentDate.getDay()] + ", " + date + def + month[currentDate.getMonth()] + ", " + year;
case "time":
return hour + ":" + min;
}
}
}
module.exports = BotDate;