Files
wekan/models/lib/dueDateShortcuts.js
T
Lauri Ojansivu e40532b9f6 Add previous-week and next-month due-date shortcuts
Use local calendar boundaries and the user's week start, refresh active shortcuts with the shared clock, and release the subscription on switching or clearing. Cover month-end and year rollover plus actual sidebar boundaries.

Thanks to neooleg, Creanimo and xet7 !
2026-09-28 18:23:09 +03:00

18 lines
739 B
JavaScript

import { weekRange } from './weekStart.js';
// Calendar periods in the viewer's timezone, not fixed 7/30-day durations.
export function dueDateShortcut(state, at, firstDay = 1) {
if (!(at instanceof Date) || !Number.isFinite(at.getTime())) return null;
if (state === 'previousweek') {
const { start, end } = weekRange(at, firstDay, -1);
return { $type: 9, $gte: start, $lte: end };
}
if (state === 'nextmonth') {
const start = new Date(at.getTime()), end = new Date(at.getTime());
start.setDate(1); start.setMonth(start.getMonth() + 1); start.setHours(0, 0, 0, 0);
end.setDate(1); end.setMonth(end.getMonth() + 2); end.setHours(0, 0, 0, 0);
return { $type: 9, $gte: start, $lt: end };
}
return null;
}