-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinning.js
More file actions
28 lines (23 loc) · 864 Bytes
/
binning.js
File metadata and controls
28 lines (23 loc) · 864 Bytes
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
// Binning (resampling) Time series data
const events = [
{ timestamp: 1714123200000, type: "login" },
{ timestamp: 1714126800000, type: "logout" },
{ timestamp: 1714130400000, type: "purchase" },
{ timestamp: 1714134000000, type: "login" },
{ timestamp: 1714137600000, type: "view" },
{ timestamp: 1714141200000, type: "purchase" },
{ timestamp: 1714144800000, type: "logout" },
{ timestamp: 1714148400000, type: "login" },
{ timestamp: 1714152000000, type: "view" },
{ timestamp: 1714155600000, type: "purchase" },
];
const INTERVAL = 30 * 60 * 1000;
const binningTimeStamp = (timestamp) => {
const date = new Date(timestamp);
// console.log(timestamp);
// console.log(data.getTime());
const floorDate = Math.floor(date.getTime() / INTERVAL) * INTERVAL;
console.log(floorDate);
};
``;
binningTimeStamp("2025-10-22T10:01:00Z");