From a73fa72764afd97197dc1a2aef8ed539691fd137 Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 22 Aug 2022 16:03:40 -0600 Subject: [PATCH] Calendar: Fix incorrect week view header --- calendar/js/View.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/calendar/js/View.ts b/calendar/js/View.ts index 89da50f8cc..273da2723e 100644 --- a/calendar/js/View.ts +++ b/calendar/js/View.ts @@ -247,15 +247,25 @@ export class week extends View { public static header(state) { - var end_date = state.last; + let start_date = state.first; + let end_date = state.last; if(!week.show_weekend(state)) { + start_date = new Date(state.first); + while([0, 6].indexOf(start_date.getUTCDay()) != -1) + { + start_date.setUTCDate(start_date.getUTCDate() + 1); + } + end_date = new Date(state.last); - end_date.setUTCDate(end_date.getUTCDate() - 2); + while([0, 6].indexOf(end_date.getUTCDay()) != -1) + { + end_date.setUTCDate(end_date.getUTCDate() - 1); + } } return super._owner(state) + app.calendar.egw.lang('Week') + ' ' + - app.calendar.date.week_number(state.first) + ': ' + - app.calendar.date.long_date(state.first, end_date); + app.calendar.date.week_number(start_date) + ': ' + + app.calendar.date.long_date(start_date, end_date); } public static start_date(state)