Add "Week" grouping option to reporting

This commit is contained in:
Andrew Herron
2026-08-05 12:22:02 +10:00
committed by Gregor Vostrak
parent 97fd882878
commit dfe3206614
8 changed files with 388 additions and 19 deletions

View File

@@ -236,6 +236,15 @@ export function formatWeek(date: string | null): string {
return 'Week ' + getDayJsInstance()(date).week();
}
/*
* Returns the range covered by the week starting on the given day.
* @param date - first day of a week, in the format of 'YYYY-MM-DD'
*/
export function formatWeekRange(date: string, format?: DateFormat): string {
const end = getDayJsInstance()(date).add(6, 'day').format('YYYY-MM-DD');
return `${formatDate(date, format)} - ${formatDate(end, format)}`;
}
/*
* Returns a human readable date format.
* @param date - date in the format of 'YYYY-MM-DD'