This issue comes up when editing an event with the time set to be 12:00 AM (midnight) to 12:59 AM. After hitting preview, the am/pm input widget gets set to pm. This is because expand_event sets ampm to "pm" for anything with an hour value above 11. A patch is attached to change that to 12, but I don't know if it could have any side effects.

Setting minor because so few people schedule events for midnight that this hasn't been noticed, and I don't get invited to those kinds of events anyway =)

CommentFileSizeAuthor
event_expand_midnight[1].diff453 bytesdturover

Comments

killes@www.drop.org’s picture

Can someone who actually uses the am/pm format comment on this? I am not comfortable with its ideosyncracies...

marc delay’s picture

There is no such thing as 12 Ante Meridiem or 12 Post Meridiem. there is a 12 noon and a 12 midnight, and maybe those times should be represented as 12n (for noon) and 12m (for midnight).

A solution for people who refuse to accept this central tenet of time keeping would be to switch to a 24 hour clock.

As for the patch included it would make all times from 12 noon to 12:59 pm appear as am, just a reversal of the current situation and probably a pain for more people then the midnight problem.

graper’s picture

While I understand that 12:00 and 00:00 are not post or ante meridian as they are the meridian for a 12h clock system. The problem is with countries that use a 12 our system just understand that 12pm is 12:00 and that 12am is 00:00.

The code that is being patched is effectively doing that conversion so that anything that is 12:00 hours and after is pm in a 12hour system.

I don't believe this patch should be used because IMHO it needs to be expanded to also test if the time being set was already in 12hr format. The current module code make an assumption that the format will always be in 24hr format, which is not always the case. i.e. if what is being submitted is in 12hr format then why try to convert it to 12hr format, which changed this 12am hour value to 12pm because it converted it when it shouldn't have.

Granville

dturover’s picture

Status: Needs review » Needs work

It seems there are different 12-hour conventions in different countries. In the USA where I am, midnight is recorded as "12:00 AM" and noon is recorded as "12:00 PM". There is no "0:00" except in 24-hour military time.

This code should work in those cases where "12" and "AM" are both specified, without damaging noon to 12:59 times that were input in 24-hour format:

    if ($element['#value']['hour'] > 11
    && !($element['#value']['hour'] == 12 && $element['#value']['ampm'] == 'am')
    ){

Then again, wouldn't 24-hour inputs be filtered out by variable_get('event_ampm') returning zero? I presume not or else the whole branch would not be needed since it exists to convert 24h times to 12h.

I also recommend delaying committing any patch for this until we are absolutely sure it would not affect different date configurations, since such things do happen unexpectedly and this is such a rare and unimportant issue.

japerry’s picture

Status: Needs work » Closed (outdated)

Event for Drupal 8 is unrelated to older versions. If an issue similar to this one exists, please open a new issue with the 8.x branch.