Opened 11 years ago
Closed 10 years ago
#27271 closed enhancement (fixed)
Add a filter to human_time_diff()
Reported by: | slimndap | Owned by: | |
---|---|---|---|
Milestone: | 4.0 | Priority: | normal |
Severity: | normal | Version: | 3.8.1 |
Component: | Formatting | Keywords: | has-patch commit |
Focuses: | template | Cc: |
Description
The human_time_diff function lacks a filter.
It would be useful to add extra formatting options.
Currently, if the difference is 2 hours and 40 minutes the result of human_time_diff is '2 hours'.
With a filter you could change it to be more specific: 2 hours, 40 mins.
The filter could look like this:
return apply_filters( 'human_time_diff', $since, $diff );
Attachments (4)
Change History (16)
#2
follow-up:
↓ 4
@
11 years ago
- Keywords needs-docs added
Any new hook will need accompanying hook docs.
#4
in reply to:
↑ 2
@
11 years ago
Replying to DrewAPicture:
Any new hook will need accompanying hook docs.
I uploaded a patch with documentation for the new hook.
#5
in reply to:
↑ 3
;
follow-up:
↓ 7
@
11 years ago
Replying to SergeyBiryukov:
$from
and$to
should probably be passed to the filter as well.
I added $from and $to to the new filter.
#7
in reply to:
↑ 5
@
11 years ago
- Keywords needs-docs removed
Replying to slimndap:
Replying to SergeyBiryukov:
$from
and$to
should probably be passed to the filter as well.
I added $from and $to to the new filter.
At a glance, the hook docs look good. Thanks.
Protip: Make sure to pass --no-prefix
when you generate the diff so you don't get all of the extra information attached to it like in your latest patch.
#8
follow-up:
↓ 9
@
11 years ago
- Keywords needs-refresh added
The patch also includes unrelated change from [27558].
@
11 years ago
Added $from and $to to apply_filters. Added documentation for the hook. This time without unrelated change from another commit.
#9
in reply to:
↑ 8
@
11 years ago
Replying to SergeyBiryukov:
The patch also includes unrelated change from [27558].
I removed the unrelated change and uploaded a new patch.
#10
@
11 years ago
The latest patch is "backwards" (it's suggesting to remove what isn't there and add what is).
git diff --no-prefix
should handle this in the proper order.
Add filter and brackets