-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdates.js
More file actions
59 lines (53 loc) · 1.13 KB
/
Copy pathdates.js
File metadata and controls
59 lines (53 loc) · 1.13 KB
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
const days = {
'Mon': 'Monday',
'Tue': 'Tuesday',
'Wed': 'Wednesday',
'Thu': 'Thursday',
'Fri': 'Friday',
'Sat': 'Saturday',
'Sun': 'Sunday'
};
const ONE_DAY = 86400000;
const TWO_DAYS = 172800000;
function getAcronym(date) {
return date.toString().slice(0, 3);
}
function getDayNumber(date) {
return date.toString().slice(8, 10);
}
function getDate(milliseconds = 0) {
return new Date(Date.now() + milliseconds);
}
const data = [
{
id: 1,
name: days[getAcronym(getDate(-TWO_DAYS))],
short: getAcronym(getDate(-TWO_DAYS)),
number: getDayNumber(getDate(-TWO_DAYS))
},
{
id: 2,
name: 'Yesterday',
short: getAcronym(getDate(-ONE_DAY)),
number: getDayNumber(getDate(-ONE_DAY))
},
{
id: 3,
name: 'Today',
short: getAcronym(getDate()),
number: getDayNumber(getDate())
},
{
id: 4,
name: 'Tomorrow',
short: getAcronym(getDate(ONE_DAY)),
number: getDayNumber(getDate(ONE_DAY))
},
{
id: 5,
name: days[getAcronym(getDate(TWO_DAYS))],
short: getAcronym(getDate(TWO_DAYS)),
number: getDayNumber(getDate(TWO_DAYS))
}
];
module.exports = data;