refactor(views/calendar): use specific API for date notes for performance

This commit is contained in:
Elian Doran
2025-02-22 10:56:10 +02:00
parent 43f79ca813
commit a9cebe312f
2 changed files with 104 additions and 40 deletions

View File

@@ -30,6 +30,27 @@ function parseDate(str: string) {
}
}
// Source: https://stackoverflow.com/a/30465299/4898894
function getMonthsInDateRange(startDate: string, endDate: string) {
const start = startDate.split('-');
const end = endDate.split('-');
const startYear = parseInt(start[0]);
const endYear = parseInt(end[0]);
const dates = [];
for (let i = startYear; i <= endYear; i++) {
const endMonth = i != endYear ? 11 : parseInt(end[1]) - 1;
const startMon = i === startYear ? parseInt(start[1])-1 : 0;
for(let j = startMon; j <= endMonth; j = j > 12 ? j % 12 || 11 : j+1) {
const month = j+1;
const displayMonth = month < 10 ? '0'+month : month;
dates.push([i, displayMonth].join('-'));
}
}
return dates;
}
function padNum(num: number) {
return `${num <= 9 ? "0" : ""}${num}`;
}
@@ -621,6 +642,7 @@ export default {
reloadFrontendApp,
reloadTray,
parseDate,
getMonthsInDateRange,
formatDateISO,
formatDateTime,
formatTimeInterval,