Commit c08852b8 authored by Wietse Kuipers's avatar Wietse Kuipers
Browse files

Merge branch 'fix/calendar-ordering' into 'master'

Fix calendar ordering using years

Closes #37

See merge request thalia/ThaliApp-react!104
parents eff5b066 e3420c88
...@@ -16,23 +16,25 @@ import styles from './style/calendar'; ...@@ -16,23 +16,25 @@ import styles from './style/calendar';
const addEventToSection = (sections, date, event) => { const addEventToSection = (sections, date, event) => {
const day = date.date(); const day = date.date();
const month = date.month(); const month = date.month();
const year = date.year();
const sectionKey = (year * 100) + month;
if (!(month in sections)) { if (!(sectionKey in sections)) {
sections[month] = { sections[sectionKey] = {
key: date.format('MMMM'), key: date.format('MMMM'),
data: {}, data: {},
}; };
} }
if (!(day in sections[month].data)) { if (!(day in sections[sectionKey].data)) {
sections[month].data[day] = { sections[sectionKey].data[day] = {
dayNumber: day, dayNumber: day,
dayOfWeek: date.format('dd'), dayOfWeek: date.format('dd'),
events: [], events: [],
}; };
} }
sections[month].data[day].events.push(event); sections[sectionKey].data[day].events.push(event);
}; };
/** /**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment