- Issue created by @LordBarnhill
- 🇳🇱Netherlands johnv
I guess the (strange) problem is in the widget, not the formatter. Correct?
So, in 'Manage display', it does not matter how the time notation is?
In 'Field settings', your time notation is '12 hours'.
How about your 'time element type'? On my Windows test system:
- the HTML5 type does not give an ampm input field.
- the SelectList type is properly configurated: you can set 12:12pm, but not 13:13pm. Only 01:13pm is allowedSo you problem is that your ampm input allows number 13-24. Correct?
Not sure why this would only occur between 13:00 (that I understand) and 17:40 (that I do NOT understand).It helps if you give me a screen dump of the widget.
I never tested on Apple, Android. - 🇳🇱Netherlands johnv
This post How can I get an "am" or "pm" indicator to display with the HTML5 time input element? contains some valuable info:
Seems like some people are stuck with 24 hours and others 12 hours with AM/PM. Here's what I found out. For me, I was stuck on a 24 hour mode and changing the Operating system's date format didn't work for me (at least not right away probably due to chrome previously installed). So I went in google chrome's settings -> Show Advanced Settings -> Languages -> Language and input settings... Then I switched to English (United States), restart Chrome and Voilà, 12 hour mode selection and able to select AM or PM. So it is probably designed so you don't have to worry about it and that it will be displayed to the user's date/time format preferences. I do not think it is possible AT THE MOMENT to force how it will render as described in this answer Is there any way to change input type="date" format?.
The format displayed by the user interface control and accepted as user input. Browser vendors are encouraged to follow the user's preferences selection. For example, on Mac OS with the region "United States" selected in the Language & Text preferences pane, Chrome 20 uses the format "m/d/yy".
Sorry for the delay in responding.
So, in 'Manage display', it does not matter how the time notation is?
Correct, this happens no matter what the time notation setting is in "Manage display."
So you problem is that your ampm input allows number 13-24. Correct?
Not sure why this would only occur between 13:00 (that I understand) and 17:40 (that I do NOT understand).No, that isn't it. What is happening is this: if the start time for a day is set to any time between 12:01pm and 12:59pm and the end time is set to a time between 1:00pm and 7:40pm an error will be thrown when you try to save the node. An error that reads, "The Day: Closing hours are earlier than Opening hours," will display at the top of the page for each day that has start and end times within the those ranges. The start and end times set in my case were 12:15pm and 5:45pm. I looked for that error in the module code and found it in
OfficeHoursBaseSlot.php
on lines 279-281. I then found the two variables the conditional was comparing ($start and $end, located on lines 251 and 252) and then printed the value of those variables to the screen (withdpm()
). The value for$start
was 1940 when it should be 1215 and the value for$end
was 1745 which is correct (the times are converted in the code it seems). If I change the start time to any time that is not in the previously mentioned range then$start
has a value that correctly equates to the time. For example, if I change the start time to 1:30pm then the value in$start
will be 1330 as it should be and if I set the time to 12:00pm the value in$start
will be 1200 like it should be.The value in
$end
will also be 1940 if the end time for a day is set to a time between 12:01pm and 12:59pm. Not an issue in this particular instance but still an issue as well.Here is a screenshot of the field settings:
Here is a screenshot of the widget on the edit page:
And here is an image of the Error at the top of the edit page after trying to save:
- 🇳🇱Netherlands johnv
Thank you.
I see you use the 'datelist' element (not the datetime HTML5 element). That is important.
In OfficeHoursBaseSlot::processOfficeHoursSlot(), also $value is wrong. In my case '1212pm' is converted to '140', so it is a bit different.
It seems that the data is saved and loaded correctly with value '1212'.
So, there is no functional problem. It is only displayed with the option 'validate hours.'Need to investigate more.
- Status changed to Needs review
about 1 year ago 3:11pm 23 October 2023 - last update
about 1 year ago Patch Failed to Apply - 🇳🇱Netherlands johnv
Please test attached patch. You only need to apply the part in fie src/OfficeHoursDateHelper.php
Applying the
src/OfficeHoursDateHelper.php
part of the patch did fix the problem on the site I was testing on.- Status changed to RTBC
about 1 year ago 9:27am 25 October 2023 - Status changed to Fixed
about 1 year ago 7:56am 1 November 2023 Automatically closed - issue fixed for 2 weeks with no activity.