Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I desperately need to use the "a.m." and "p.m." format as consistent with our style guide and found that there was no option for display other than AM/PM or am/pm. I know this is an issue in the date/time format of the underlying PHP itself, but is there any way to get around this with a string replace function or something like the example below?
http://stackoverflow.com/questions/17798398/php-time-format-am-and-pm-wi...
Comment | File | Size | Author |
---|---|---|---|
#12 | Before_applied_patch.png | 36.07 KB | RoshniPatel.addweb |
#12 | After_applied_patch.png | 39.31 KB | RoshniPatel.addweb |
#12 | format_dates_with-2808909-12.patch | 1.27 KB | RoshniPatel.addweb |
#10 | format_dates_with-2808909-10.patch | 344 bytes | RoshniPatel.addweb |
#2 | Before_applied_patch.png | 8.62 KB | dev16.addweb |
Comments
Comment #2
dev16.addweb CreditAttribution: dev16.addweb at AddWeb Solution Pvt. Ltd. commentedYou can use attach attached patch file for your purpose ONLY.
Comment #3
dev16.addweb CreditAttribution: dev16.addweb at AddWeb Solution Pvt. Ltd. commentedComment #4
swhitters CreditAttribution: swhitters as a volunteer 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 CreditAttribution: swhitters as a volunteer commentedComment #6
dev16.addweb CreditAttribution: dev16.addweb at AddWeb Solution Pvt. Ltd. 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 CreditAttribution: swhitters as a volunteer 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 CreditAttribution: swhitters as a volunteer commentedComment #10
RoshniPatel.addweb CreditAttribution: RoshniPatel.addweb at AddWeb Solution Pvt. Ltd. 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
RoshniPatel.addweb CreditAttribution: RoshniPatel.addweb at AddWeb Solution Pvt. Ltd. commentedComment #12
RoshniPatel.addweb CreditAttribution: RoshniPatel.addweb at AddWeb Solution Pvt. Ltd. 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 CreditAttribution: swhitters as a volunteer 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
RoshniPatel.addweb CreditAttribution: RoshniPatel.addweb at AddWeb Solution Pvt. Ltd. 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.