[wp-trac] [WordPress Trac] #29849: Better human_time_diff()
WordPress Trac
noreply at wordpress.org
Thu May 15 22:40:59 UTC 2025
#29849: Better human_time_diff()
-------------------------------------------------+-------------------------
Reporter: kovshenin | Owner: audrasjb
Type: enhancement | Status: reviewing
Priority: normal | Milestone: 6.9
Component: Date/Time | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests needs- | Focuses:
test-info |
-------------------------------------------------+-------------------------
Changes (by SirLouen):
* keywords: has-patch has-unit-tests needs-testing needs-test-info => has-
patch has-unit-tests needs-test-info
Comment:
@pbearne I was trying to deploy
[https://make.wordpress.org/test/2025/05/15/building-the-testing-use-case
/#back-end-enhancements-and-new-features simple testing use-case] to push
this report forward, but I've found some elements that I would like to
have clearer to proceed and some extra insights that could improve code:
1. First, one edit in the file naming
From: `tests/phpunit/tests/formatting/WpNaturalTime/WpNaturalTime.php`
To: `tests/phpunit/tests/formatting/wpNaturalTime.php`
2. I've noticed that there are a ton of other places to make substitutions
(48 results over the ones modified). So I wondered: the current
substitutions have been chosen at random?
3. I'm having difficulties understanding this logic, not getting these two
assert:
{{{
$this->assertEquals( '1 year from now', wp_natural_time(
$this->ts['now1y1m'], $this->ts['now'], 2 ) );
$this->assertEquals( '1 year from now', wp_natural_time(
$this->ts['now1y1d'], $this->ts['now'], 2 ) );
}}}
Given that they both have 2 limit, shouldn't they be respectively:
{{{
1 year, 1 month from now
1 year, 1 day from now
}}}
Or I'm missing some logic?
4. Finally, instead of having two `apply_filters` in `wp_natural_time`,
wouldn't it make more sense to have just one and document it? (I attach a
patch to showcase what I mean)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29849#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list