On the 31st the number of the next month is calculated incorrectly

Created on 6 April 2025, 3 months ago

Please note, this issue is not duplicate for https://www.drupal.org/project/date_pager/issues/3517131 πŸ› Date is considered after noon (12:00), but it should be after midnight (after 00:00) Active

Problem/Motivation

On the 31st the number of the next month is calculated incorrectly

Steps to reproduce

There are 2 events on the site with dates in 2025:
1: March 28th (or any day of Marth)
2: April 4th (or any day of April)

Pager options
Default time: current
Granularity: Month (or Day)

The time is not specified in the date field. Only the day.

If today is March 30th, the pager is displayed correctly.
When Granularity: Month is specified, the pager is displayed like this:

When Granularity: Day is specified, the pager is displayed like this:

If today is March 31st, the pager is displayed incorrectly.

In the following screenshots, the month is specified as "05". Although April should be displayed as "04".

When Granularity: Month is specified, the pager is displayed like this:

When Granularity: Day is specified, the pager is displayed like this:

πŸ› Bug report
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine vasyok

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

Merge Requests

Comments & Activities

  • Issue created by @vasyok
  • πŸ‡©πŸ‡ͺGermany sleitner

    I think this is also UTC / local time zone related

  • πŸ‡ΊπŸ‡¦Ukraine vasyok
  • πŸ‡ΊπŸ‡¦Ukraine vasyok

    I don't think that its timezone problem. I change topic. Now in pager 3 dates. If today is March 31st, then 5th month displayed twice.

  • πŸ‡©πŸ‡ͺGermany sleitner

    Could you reproduce this on a new Drupal installation, e.g. on simplytest.me ? Do you patch something in date_pager? Or Javascript changing content in frontend? What is the URL in the false 05 link?
    I couldn't reproduce it with the steps given above on simplytest.me.

  • πŸ‡ΊπŸ‡¦Ukraine vasyok

    Can simplytest.me choose "current" date?
    No, i don't patch date_pager.
    Same trouble in Claro or Olivero theme. Screenshot:

    Both 05 links linked to May i.e. /view-url?date=2025-05.
    On March 31st it's also possible to come in to April i.e. to /view-url?date=2025-04, but this 04 link is missing in pager.

  • πŸ‡©πŸ‡ͺGermany sleitner

    I could reproduce it locally. It was a problem on top of the timezone problem with the mapping of the current date to the dates in the pager. Please test and review πŸ› Paging seems to be done using UTC and not local time zone. Active

  • Status changed to Closed: duplicate 19 days ago
  • πŸ‡ΊπŸ‡¦Ukraine vasyok

    Installed the latest version 2.1.1-beta1 . The problem is still there.

  • πŸ‡ΊπŸ‡¦Ukraine vasyok
  • πŸ‡©πŸ‡ͺGermany sleitner

    @vasyok : I cannot reproduce this issue, if I set the time manually to 31.3.2025. Which system timezone and user timezone are you using? Which field type is your date field?

  • πŸ‡ΊπŸ‡¦Ukraine vasyok

    I don't know why, but the results now are different from the results of my last answer. Sorry if I messed something up.

    List of events is the same as before:

    View is also the same:

    System timezone and user timezone

    /admin/config/regional/settings

    Default country: Germany (If I switch it to "Ukraine" nothing changes)
    Default time zone: UTC
    Users may set their own time zone OFF

    I wrote a function that defines 3 variables

    • site_time
    • site_timezone
    • server_time

    MYTHEME.libraries.yml

    function MYTHEME_preprocess_views_view(array &$variables) {
      $date = new \DateTime('now', new \DateTimeZone(\Drupal::config('system.date')->get('timezone.default')));
      $variables['site_time'] = $date->format('Y-m-d H:i:s');
      $variables['site_timezone'] = $date->getTimezone()->getName();
    
      $server_time = new \DateTime();
      $variables['server_time'] = $server_time->format('Y-m-d H:i:s');
    }

    ... and displayed these variables in the view page

    views-view--MYVIEW--page-3.html.twig

    Current site time: {{ site_time }}
    Site time zone: {{ site_timezone }}
    Server time: {{ server_time }}
    

    Results

    2.1.1-alpha2 without patches

    If today is March 30th, the pager on /test-page is displayed correctly:

    If today is March 31st, MaΠ½ is displayed twice:

    2.1.1-beta1

    If today is March 30th or 31st - May is not displayed:

  • πŸ‡©πŸ‡ͺGermany sleitner

    Users may set their own time zone OFF does not mean that the website timezone is used, the users simply cannot change the settings via UI. I assume there was a different timezone set. Now the user time zone defaults to website timezone if user timezone is not configurable. Please review MR

Production build 0.71.5 2024