fix: synchronize calendar month input and add month navigation
This commit is contained in:
@@ -86,3 +86,10 @@ export function calendarAgenda(tenders, now=new Date()) {
|
||||
undated.sort(compare);
|
||||
return {days,undated};
|
||||
}
|
||||
export function shiftCalendarMonth(month,delta) {
|
||||
if(!/^\d{4}-(0[1-9]|1[0-2])$/.test(month) || !Number.isInteger(delta))return null;
|
||||
const [year,m]=month.split('-').map(Number),index=year*12+m-1+delta;
|
||||
const nextYear=Math.floor(index/12),nextMonth=index%12+1;
|
||||
if(nextYear<1 || nextYear>9999)return null;
|
||||
return `${String(nextYear).padStart(4,'0')}-${String(nextMonth).padStart(2,'0')}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user