[terminology][calendar] sort events
This commit is contained in:
parent
f5ab02dca2
commit
61cab320d0
|
@ -23,6 +23,11 @@ class Day {
|
||||||
toString() {
|
toString() {
|
||||||
return `${this.year}-${this.month.toString().padStart(2, '0')}-${this.day.toString().padStart(2, '0')}`;
|
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;
|
module.exports.Day = Day;
|
||||||
|
|
||||||
|
@ -153,6 +158,10 @@ class Year {
|
||||||
this.eventsByTerm[term].push(event);
|
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() {
|
isCurrent() {
|
||||||
|
|
Reference in New Issue