"Start week with" setting can lead to wrong current date

Created on 27 March 2023, about 2 years ago
Updated 12 September 2023, over 1 year ago

Problem/Motivation

Selecting "Saturday" as the day to start the displayed week with leads to the current week displayed being basically one week off if the week date is before that day in the week.

The current implementation modifies the week start date in "build_table" with "{{ selected_day }} this week" which is potentially in the future.

Steps to reproduce

Select "Saturday" as the first day of the week in the views settings using the new "Calendar by week" display. Set the default value for the week date to "now".

Proposed resolution

I think something like the following is necessary to account for the current time being a somewhat conditional switch.

    if ($counter_date->format("w") != $selected_day) {
      $counter_date->modify('previous ' . $weekdays[$selected_day]);
    }

If my line of thinking is correct, I can provide a patch.

🐛 Bug report
Status

Fixed

Version

2.1

Component

Code

Created by

🇦🇹Austria archnode Linz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @archnode
  • Status changed to Postponed: needs info about 2 years ago
  • Thank you very much for reporting this issue.

    can you give me the week number/date where this is happening?

  • Status changed to Active about 2 years ago
  • 🇦🇹Austria archnode Linz

    With the default date set to 'now' this happens e.g. today: week 13, 27th march 2023 and displays the calendar default starting with 1st april 2023 to 7th april 2023.

    Thank you for taking the time to respond. Please tell if you need anything else.

  • Status changed to Needs review about 2 years ago
  • I have reproduced the issue and it is (hopefully) fixed by the latest commit referenced above.

    It's on 2.0.x dev branch only for now.

    Looking forward to reading you.

  • Status changed to Needs work about 2 years ago
  • 🇦🇹Austria attisan Vienna

    @matthieuscarset your commit 46ed0545 actually breaks (forward) week navigation starting from the "current" week (I have weeks starting with Monday). With commit 46ed0545 included, all future weeks are off by one week.

  • confirm what @attisan said, it breaks the navigation of the week view, needed to remove it from my project.

  • 🇧🇪Belgium svendecabooter Gent

    I can confirm this commit causes indeed an issue with moving forward in week view. My starting day is set to monday.
    Since this is now in the 2.1.2 release, I am attaching a patch to remove this functionality from that release, in order not to break my installation.

    Hopefully a solution for this issue can be provided that does not break the navigation as reported.

  • Status changed to Needs review over 1 year ago
  • Thank you all for reporting the issue and please forgive the inconvenience.

    I think I might found the issue with the navigation by week when the first day of the week is saturday.

    Here's a quickfix committed on 2.1.x for now.

    Could you please test and let me know if it fix the situation?

    I've tested myself and the pager by week of my calendar by week starting on Saturday works correctly (see attached screenshot).

    Looking forward to hearing from you.

  • Status changed to Fixed over 1 year ago
  • Marking as fixed because of some testing done in direct messages on Slack.

    Making a new release right now to unblock the situation for current users.

    Feel free to comment and reopen if you still find an issue.

  • 🇧🇪Belgium svendecabooter Gent

    Thanks for the quick fix

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024