Skip to content
Snippets Groups Projects
Commit e8ce2c6e authored by Moritz Strohm's avatar Moritz Strohm
Browse files

allow day 7 as sunday in getWeekday function, fixes #4801

Closes #4801

Merge request !3592
parent d9066bbe
No related branches found
No related tags found
No related merge requests found
...@@ -30,10 +30,10 @@ require_once 'lib/calendar_functions.inc.php'; ...@@ -30,10 +30,10 @@ require_once 'lib/calendar_functions.inc.php';
*/ */
function getWeekday(int $day_num, bool $short = true): string function getWeekday(int $day_num, bool $short = true): string
{ {
if ($day_num < 0 || $day_num > 6) { if ($day_num < 0 || $day_num > 7) {
throw new Exception('Invalid day number'); throw new Exception('Invalid day number');
} }
return match($day_num) { return match($day_num % 7) {
0 => $short ? _('So') : _('Sonntag'), 0 => $short ? _('So') : _('Sonntag'),
1 => $short ? _('Mo') : _('Montag'), 1 => $short ? _('Mo') : _('Montag'),
2 => $short ? _('Di') : _('Dienstag'), 2 => $short ? _('Di') : _('Dienstag'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment