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:
Office hours module field configuration

Proposed resolution

Remaining tasks

User interface changes

Here is the displayed incorrect office hours

Incorrectly displayed office hours

API changes

Data model changes

CommentFileSizeAuthor
incorrectOfficeHours.png19.82 KBalaverde
officehours.png106.4 KBalaverde
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

alaverde created an issue. See original summary.

alaverde’s picture

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

johnv’s picture

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?

johnv’s picture

Status: Active » Postponed (maintainer needs more info)

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

ghaya’s picture

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.

johnv’s picture

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

johnv’s picture

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'?

ghaya’s picture

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)

ghaya’s picture

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.

artis’s picture

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.

artis’s picture

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.

johnv’s picture

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

artis’s picture

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.

johnv’s picture

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...

johnv’s picture

Title: Displaying hours incorrectly » Views display has hours incorrect, when having multiple office_hours fields per row
Status: Postponed (maintainer needs more info) » Active

@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?

artis’s picture

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...
johnv’s picture

Version: 8.x-1.23 » 8.x-1.26
Component: User interface » Code - formatter
Status: Active » Fixed

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.

Status: Fixed » Closed (fixed)

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