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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

swhitters created an issue. See original summary.

dev16.addweb’s picture

You can use attach attached patch file for your purpose ONLY.

dev16.addweb’s picture

Status: Active » Needs review
swhitters’s picture

Awesome--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)

swhitters’s picture

Status: Needs review » Fixed
dev16.addweb’s picture

Thanks for the comments.. would waiting for credit!

johnv’s picture

Status: Fixed » Needs review

I'll keep this open, perhaps it'll make into the module as an extra option.

swhitters’s picture

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

swhitters’s picture

Status: Needs review » Needs work
RoshniPatel.addweb’s picture

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

RoshniPatel.addweb’s picture

Status: Needs work » Needs review
RoshniPatel.addweb’s picture

@johnv here is the generalized patch for the same format_dates_with-2808909-12.patch.

I have added new display format for the same.

swhitters’s picture

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

RoshniPatel.addweb’s picture

Status: Needs review » Reviewed & tested by the community

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

  • johnv committed 842d2d8 on 7.x-1.x authored by Roshni Patel
    Issue #2808909 by Roshni Patel, tejal.patel: Format dates with periods (...
johnv’s picture

Status: Reviewed & tested by the community » Fixed

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

johnv’s picture

Version: 7.x-1.4 » 8.x-1.x-dev
Status: Fixed » Patch (to be ported)
johnv’s picture

I will not add this to v8. But the HMS field project implements a hook_hms_format_alter() . Perhaps we can copy that idea.

johnv’s picture

Issue summary: View changes

According 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. :-(

johnv’s picture

Component: Code » Code - formatter
johnv’s picture

Title: Format dates with periods (a.m. and p.m.) » Format hours with periods (a.m. and p.m.)
johnv’s picture

johnv’s picture

Title: Format hours with periods (a.m. and p.m.) » Time Format: ampm with periods (a.m. and p.m.)
johnv’s picture

Version: 8.x-1.x-dev » 8.x-1.6
Status: Patch (to be ported) » Fixed

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

Status: Fixed » Closed (fixed)

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