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';
const addEventToSection = (sections, date, event) => {
const day = date.date();
const month = date.month();
const year = date.year();
const sectionKey = (year * 100) + month;
if (!(month in sections)) {
sections[month] = {
if (!(sectionKey in sections)) {
sections[sectionKey] = {
key: date.format('MMMM'),
data: {},
};
}
if (!(day in sections[month].data)) {
sections[month].data[day] = {
if (!(day in sections[sectionKey].data)) {
sections[sectionKey].data[day] = {
dayNumber: day,
dayOfWeek: date.format('dd'),
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