Closed (fixed)
Project:
Office Hours
Version:
8.x-1.6
Component:
Code - formatter
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
29 Sep 2016 at 20:16 UTC
Updated:
9 Jul 2022 at 12:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
silvi.addweb commentedYou can use attach attached patch file for your purpose ONLY.
Comment #3
silvi.addweb commentedComment #4
swhitters commentedAwesome--It worked! Thank you!
(The final period after "a.m." and "p.m." was missing, but I added it in and it displayed exactly how I wanted)
Comment #5
swhitters commentedComment #6
silvi.addweb commentedThanks for the comments.. would waiting for credit!
Comment #7
johnvI'll keep this open, perhaps it'll make into the module as an extra option.
Comment #8
swhitters commentedSo... This actually doesn't work quite as well as I thought.
The hours are displayed correctly on the published version of the page, but when you go to edit the page, the "am/pm" dropdown for each day defaults to a blank space, which gives you a bunch of "Closing hours are earlier than Opening hours" error message when you try to save the page.
If you go back and re-add the "am/pm"s and save, it works, but then the whole problem starts all over again the next time you click edit.
Any ideas?
Comment #9
swhitters commentedComment #10
daiwik.addweb commented@swhitters: Please apply following patch to make things work "format_dates_with-2808909-10.patch".
@johnv: Will provide a generalize patch for the same soon.
Comment #11
daiwik.addweb commentedComment #12
daiwik.addweb commented@johnv here is the generalized patch for the same format_dates_with-2808909-12.patch.
I have added new display format for the same.
Comment #13
swhitters commentedAwesome, thanks! It works and I'm not getting any more error messages.
Unfortunately I'm not sure I will be able to credit either of you (I applied the patch manually--we don't use Git)... but just let me know if there's some other way I am supposed to be assigning credit.
Thanks.
Comment #14
daiwik.addweb commented@swhitters: I am glad it worked for you. No worries! You would not be able to provide credit, thats the work of Maintainer :)
@johnv: You are the maintainer for this project. Can you please do the needful?
Comment #16
johnvI am not too happy with this patch, since this request was never there in the history of this module. I added the settings for the widget, too.
Comment #17
johnvComment #18
johnvI will not add this to v8. But the HMS field project implements a hook_hms_format_alter() . Perhaps we can copy that idea.
Comment #19
johnvAccording to A.M., P.M., a.m., p.m.: What Is the Correct Time?, the correct format is '4:15 p.m.'.
And according to PHP Time Formats, PHP supports a lot more options than provided by Office Hours.
[EDIT] Above page describes the formats that can be parsed by PHP, not generated. :-(
Comment #20
johnvComment #21
johnvComment #22
johnvPlease see #3063213: Time format: Add hook for custom format (D7/D8) for an alternative solution.
Comment #23
johnvComment #24
johnvThis is now in upcoming D8.1-1.7 version, as per [3063213-14].
The patch adds an alter_hook hook_office_hours_time_format_alter(string &$formatted_time) .
Using this hook, you can change the time format, and/or insert a translatable text, as documented in office_hours.api.php file.