-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmethods.js
52 lines (48 loc) · 1.26 KB
/
methods.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var now = new Date();
const { Client } = require('pg');
var methods = {
formatDate: function (date){
months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
suffix = ['st', 'nd', 'rd', 'th'];
month = parseInt(date[0]+date[1]).toString();
day = parseInt(date[3]+date[4]).toString();
if (date[3] == '1'){
suff = suffix[3];
}
else if (date[4] == '1'){
suff = suffix[0]
}
else if (date[4] == '2'){
suff = suffix[1];
}
else if (date[4] == '3'){
suff = suffix[2];
}
else{
suff = suffix[3];
}
month_str = months[month-1];
return [month_str+" " + day + suff, day + suff + " " + month_str];
},
createClient: function () {
const client = new Client({
connectionString: process.env.DATABASE_URL,
ssl: true,
});
return client;
},
encodeToday: function() {
var d;
if (now.getMonth()+1<10)
mon = '0'+(now.getMonth()+1).toString();
else
mon = (now.getMonth()+1).toString();
if (now.getDate()<10)
day = '0'+now.getDate().toString();
else
day = now.getDate().toString();
d = mon + "/" + day;
return d;
}
};
module.exports = methods;