[terminology][calendar] sort events

This commit is contained in:
Avris 2021-10-15 21:49:49 +02:00
parent f5ab02dca2
commit 61cab320d0
1 changed files with 9 additions and 0 deletions

View File

@ -23,6 +23,11 @@ class Day {
toString() {
return `${this.year}-${this.month.toString().padStart(2, '0')}-${this.day.toString().padStart(2, '0')}`;
}
// for comparisons
toInt() {
return parseInt(`${this.year}${this.month.toString().padStart(2, '0')}${this.day.toString().padStart(2, '0')}`);
}
}
module.exports.Day = Day;
@ -153,6 +158,10 @@ class Year {
this.eventsByTerm[term].push(event);
}
}
for (let term in this.eventsByTerm) {
if (!this.eventsByTerm.hasOwnProperty(term)) { continue; }
this.eventsByTerm[term].sort((a, b) => a.getDays(this.year)[0].toInt() - b.getDays(this.year)[0].toInt())
}
}
isCurrent() {