Displaying hours incorrectly

Created on 20 March 2025, 18 days ago
Updated 21 March 2025, 17 days ago

Problem/Motivation

We have a field with the office hours module for the footer of some pages. It is starting to display the hours in an incorrect manner now.

The hours it should display are:

Monday - Friday: 8:30-4:30
Saturday - Sunday: Closed

However, this is what is displayed:

Sunday: Closed
Monday: 8:30-4:30, 8:30-4:30
Tuesday - Thursday: 8:30-4:30
Friday - Saturday: Closed

Steps to reproduce

These are the times being inputted in our field:

Proposed resolution

Remaining tasks

User interface changes

Here is the displayed incorrect office hours

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

1.23

Component

User interface

Created by

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • A roll back to version 1.21 was able to stabilize the issue and made it work as intended.

  • πŸ‡³πŸ‡±Netherlands johnv

    Please specify all your Field 'Manage display' settings.

    I tested with latest dev version (I was about to release this as new release, but will wait for your response) :
    - Number of days to show = Show all days
    - First day of week = - system's Regional settings - = Sunday
    - Group consecutive days with same hours into one set = YES

    This gives the following results:
    Sun: Closed
    Mon - Fri: 8:30-4:30
    Sat: Closed

    When changing First day of week to Tuesday, i get the following results.
    Mon - Fri: 8:30-4:30
    Sat - Sun: Closed

    So, I cannot reproduce. Which version are/were you using?

  • πŸ‡³πŸ‡±Netherlands johnv

    Please check new release 1.25 (to be released within hours)

  • πŸ‡ΈπŸ‡ͺSweden ghaya

    Hi,

    I am getting the exact same error using the weekly view with the version 8.126 of Office Hours. The output on my site looks identical to the original posters with the hours appearing twice, separated by a comma.

  • πŸ‡³πŸ‡±Netherlands johnv

    Are your hours through midnight?
    And if you press 'Add time slot' on the Monday, the second slot is not hidden there?

  • πŸ‡³πŸ‡±Netherlands johnv

    Please specify all settings for 'Manage display' of the field (only the ones that are directly visible - no matter the ones hidden in a field set).
    Where do you specify the 'first day of week'? in the field, or in 'Regional settings'?

  • πŸ‡ΈπŸ‡ͺSweden ghaya

    1. Our hours do not go over midnight

    2. when I add additional hours for a day, the extra timespan is shown and replaces the duplicate time for the day. So it becomes correct output if we add the second time range for the day.

    It has worked as expected earlier, this problem has just come up with a recent update of the module and/or drupal core.

    These are our settings for the weekly view where the problem occurs:

    Number of days to show: Show All Days

    First day of week: Systems regional settings

    Day Notation: 3-letter weekday abbreviation

    Time Notation: 24 hour time

    Gorup consecutive days into one set (checked)

  • πŸ‡ΈπŸ‡ͺSweden ghaya

    To specify the problem in our case, the problem occurs when we "group consecutive days", the first day in the series is listen separately from the rest and hours are presented twice for that day. If I take away the group consecutive days option, the hours are shown correctly.

  • πŸ‡ΊπŸ‡ΈUnited States artis

    I'm seeing the same issue. Turning off the "group consective days" only works if the first day of the week is also set to Sunday. If it's Monday then the day prior to the first "closed" day will also show as "closed". It's very strange behavior that we've spent many hours trying to work around.

  • πŸ‡ΊπŸ‡ΈUnited States artis

    Correction: setting the starting day of the week has no impact.

    But enabling "Replace weekday time slots with exception dates" fixed it for me. Seems like the Seasons output is correct but the regular output is not. The days immediately proceeding and following the empty hour days have issues with how they display.

  • πŸ‡³πŸ‡±Netherlands johnv

    Thanks fot your detailed reply.
    I still cannot reproduce.have you Upgrade to v1. 26?

  • πŸ‡ΊπŸ‡ΈUnited States artis

    Yes I upgraded.

    I set up this staging so you can see what's happening: https://goodwill.txcsites.com/locations?location_type=donation

    I've noticed that the location that the hours that match the location_type parameter from the url are the ones that are in error. If you change the filter to a different type then the error follows to that type.

  • πŸ‡³πŸ‡±Netherlands johnv

    OK, thanks, now i understand.
    It was not clear to me that the problem happens in a Views display.
    The hours are displayed correctly n a node list, but not in a Views Display. Strange...

  • πŸ‡³πŸ‡±Netherlands johnv

    @artis, That is a nice page, BTW.
    In my dev environment, I can only reproduce the error if the View does not only contains the normal 'Office Hours' formatter, but also the 'timeslot' field. There is no problem when adding the 'status' field, en did not test the 'season' field, yet. Probably, adding the normal formatter twice would generate the problem, too.
    I did find how it happens, but am not sure yet why, or how to avoid it - working on that.

    Your view does not have the 'timeslot' added. Do you have multiple office_hours fields in a resutl row?

  • πŸ‡ΊπŸ‡ΈUnited States artis

    Thanks @johnv!

    Yes we have multiple office_hours fields in a single results row in the view.

    The view is outputting the 'location' content type which has a paragraph containing the office hours field. We're allowing the view to output the rendered formatter for the paragraph which is rendering the "rendered entity" formatter of the paragraph.

    If it would be helpful I could provide you with credentials to access the view on the staging link I sent. You can find me in Drupal Slack under @artis

    • johnv β†’ committed 500c74ee on 8.x-1.x
      Issue #3514516: Views display has hours incorrect - move cloning of...
    • johnv β†’ committed de6043ac on 8.x-1.x
      Issue #3514516: Views display has hours incorrect - rationalize...
    • johnv β†’ committed f66796e4 on 8.x-1.x
      Issue #3514516: Views display has hours incorrect - rationalize...
  • πŸ‡³πŸ‡±Netherlands johnv

    No need for access, thank you.
    The above should fix the problem.
    The 'groupDays' messes around with the items. Not sure yet how that influences the other formatters, but moving the cloning of the items does the trick. Please check new version. I will release a stable release soon.

Production build 0.71.5 2024