-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdate-test.js
96 lines (92 loc) · 2.65 KB
/
date-test.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
const docs = [
{
"_id": "5ce3b801f08d794128331921",
"type": "smartWatch",
"name": "smartWatch01",
"user": "alex",
"startDate": "2019-05-21T14:03:00Z",
"endDate": "2019-05-21T14:03:00Z",
"status": "Inbed"
},
{
"_id": "5ce3b801f08d794128331922",
"type": "smartWatch",
"name": "smartWatch01",
"user": "alex",
"startDate": "2019-05-21T14:03:00Z",
"endDate": "2019-05-21T14:03:00Z",
"status": "Inbed"
},
{
"_id": "5ce3b801f08d794128331923",
"type": "smartWatch",
"name": "smartWatch01",
"user": "alex",
"startDate": "2019-05-21T01:52:00Z",
"endDate": "2019-05-21T01:52:00Z",
"status": "Inbed"
},
{
"_id": "5ce3b801f08d794128331924",
"type": "smartWatch",
"name": "smartWatch01",
"user": "alex",
"startDate": "2019-05-21T01:50:00Z",
"endDate": "2019-05-21T01:50:00Z",
"status": "Asleep"
},
{
"_id": "5ce3b801f08d794128331925",
"type": "smartWatch",
"name": "smartWatch01",
"user": "alex",
"startDate": "2019-05-21T01:45:00Z",
"endDate": "2019-05-21T01:49:00Z",
"status": "Inbed"
},
{
"_id": "5ce3b801f08d794128331926",
"type": "smartWatch",
"name": "smartWatch01",
"user": "alex",
"startDate": "2019-05-20T12:24:00Z",
"endDate": "2019-05-20T14:59:00Z",
"status": "Asleep"
},
{
"_id": "5ce3b801f08d794128331927",
"type": "smartWatch",
"name": "smartWatch01",
"user": "alex",
"startDate": "2019-05-19T13:05:00Z",
"endDate": "2019-05-19T13:20:00Z",
"status": "Inbed"
},
{
"_id": "5ce3b801f08d794128331928",
"type": "smartWatch",
"name": "smartWatch01",
"user": "alex",
"startDate": "2019-05-15T11:13:00Z",
"endDate": "2019-05-15T11:37:00Z",
"status": "Asleep"
},
{
"_id": "5ce3b801f08d794128331929",
"type": "smartWatch",
"name": "smartWatch01",
"user": "alex",
"startDate": "2019-05-15T10:13:00Z",
"endDate": "2019-05-15T11:13:00Z",
"status": "Inbed"
}
];
const startDate = "2019-05-21T14:02:00Z";
const endDate = "2019-05-21T14:03:00Z";
const filtered = docs.filter((item) => {
return new Date(startDate) <= new Date(item.startDate) && new Date(item.endDate) >= new Date(endDate);
});
// console.log(true && true)
console.log( new Date(endDate) <= new Date(endDate))
console.log(new Date(startDate) >= new Date(endDate))
console.log(docs)