-
Notifications
You must be signed in to change notification settings - Fork 0
/
schedule-to-brella.js
56 lines (51 loc) · 1.26 KB
/
schedule-to-brella.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
const {
data: {
conference: { schedules },
},
} = require("./2021-schedule.json");
const rows = schedules.flatMap(({ day, intervals }) =>
intervals
.flatMap(({ begin, end, sessions }) =>
sessions.flatMap(
({ type, title, description }) =>
type !== "WORKSHOP" && {
id: "",
external_id: "",
start_time: day + " " + begin + ":00",
duration: durationInMinutes(begin, end),
reservable: "FALSE",
title,
subtitle: "",
location: "YouTube",
content: "", // description.replace("\n", "\\n"),
tags: "",
}
)
)
.filter(Boolean)
);
console.log(
"id,external_id,start_time,duration,reservable,title,subtitle,location,content,tags"
);
rows.forEach(
({
id,
external_id,
start_time,
duration,
reservable,
title,
subtitle,
location,
content,
tags,
}) =>
console.log(
`${id},${external_id},${start_time},${duration},${reservable},${title},${subtitle},${location},${content},${tags}`
)
);
function durationInMinutes(a, b) {
const [aH, aM] = a.split(":");
const [bH, bM] = b.split(":");
return (parseInt(bH) - parseInt(aH)) * 60 + (parseInt(bM) - parseInt(aM));
}