Problem/Motivation

When formatting the time for output, the minutes are only shown if it's the top of the hour, when it should be the opposite. E.g., if it's 9:32 am, "9 a.m." is output. If it's 9:00 am, "9:00 am" is output.

This is due to the logic here which is reversed:

          if ($date->format('i')) {
            // Don't display the minutes if it's the top of the hour.
            $ap_time_string = $date->format('g a');
          }
          else {
            $ap_time_string = $date->format('g:i a');
          }

Steps to reproduce

  1. Setup a content type with a date field and configure it to use the AP Style Date formatter
  2. Add a node and set that date field to a time that is NOT the top of the hour
  3. View the node and observe that the minutes are not shown, when they should be

Proposed resolution

Fix the logic.

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

bkosborne created an issue. See original summary.

shelane made their first commit to this issue’s fork.

  • shelane committed a7c860f on 8.x-1.x authored by bkosborne
    Issue #3224269 by bkosborne: Minutes are not displayed unless it's the...
shelane’s picture

Status: Active » Fixed
bkosborne’s picture

Status: Fixed » Needs review
StatusFileSize
new488 bytes
new480 bytes

Thanks for the quick commit, but looks like I made an error! It should be '00' and not '0'. Sorry about that. I tried creating another merge request, but for some reason the new branch is not up to date with 8.x-1.x, so here's a traditional patch to fix 8.x-1.x that should be committed, and here's another patch that fixes version 1.2 (for those that want to use the patch with 1.2).

  • shelane committed b8758d3 on 8.x-1.x authored by bkosborne
    Issue #3224269 by bkosborne: Minutes are not displayed unless it's the...
shelane’s picture

Status: Needs review » Fixed

I've committed it, but you know that you are still a maintainer on the project. ;-)

bkosborne’s picture

hah! forgot about that. thanks!

Status: Fixed » Closed (fixed)

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