-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
40 lines (34 loc) · 816 Bytes
/
index.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
function extractValues(date) {
return {
year: date.getUTCFullYear(),
month: date.getUTCMonth(),
date: date.getUTCDate()
}
}
function isToday(date) {
var today = extractValues(new Date());
var value = extractValues(date);
if (
today.year !== value.year ||
today.month !== value.month ||
today.date !== value.date
) {
return false;
}
return true;
}
module.exports = {
test: function (val) {
if (val && typeof val === 'object' && 'getFullYear' in val) {
return true;
}
return false;
},
print: function (val) {
if (isToday(val)) {
return `Current Date`
}
var d = extractValues(val);
return [d.month, d.date, d.year].join('-');
}
}