-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhackNights.js
More file actions
63 lines (56 loc) · 1.65 KB
/
hackNights.js
File metadata and controls
63 lines (56 loc) · 1.65 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
60
61
62
63
// This file declares a variable with all HackNights info
var hackNights = {
season: "2024",
defaultEvent: {
date: "undefined",
name: "Episode Extra",
summary: "",
theme: { emoji: "🌙", name: "undefined" },
applyUrl: "#",
schedule: undefined,
done: false,
next: false,
},
events: [
{
date: "2026-02-27 21:00",
name: "Episodi I (2026)",
theme: { emoji: "🤖", name: "Estudiar en temps de IA" },
applyUrl: "https://hackersatupc.typeform.com/hacknights2026",
schedule: [
{ hour: "21:00", name: "Registre" },
{ hour: "21:15", name: "Cerimònia d'obertura" },
{ hour: "21:30", name: "Workshop: AI tools for university and school." },
{ hour: "00:00", name: "Midnight Snack" },
{ hour: "05:00", name: "Cerimònia de clausura" },
],
summary: ""
},
],
nextEvent: undefined,
};
// sort events
function compare(a,b) {
let aDate = new Date(a.date);
let bDate = new Date(b.date);
if (aDate < bDate) return -1;
if (aDate > bDate) return 1;
return 0;
}
hackNights.events.sort(compare);
let now = new Date();
// set the next event
hackNights.nextEvent = hackNights.events.reduce((event, next) => {
let date = new Date(event.date);
let dateNext = new Date(next.date);
// if the event is in the future and the next event is in the future
if(date > now && date < dateNext) return event;
else return next;
}, hackNights.events[0]);
hackNights.nextEvent.next = true;
// set done and next attribute
for (const event of hackNights.events) {
let date = new Date(event.date);
event.done = date < now;
event.next = event == hackNights.nextEvent;
}