Make WordPress Core

Ticket #35655: 35655.diff

File 35655.diff, 1.3 KB (added by pento, 6 years ago)
  • src/wp-includes/formatting.php

    diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php
    index 334806b9e0..757eb07103 100644
    a b function human_time_diff( $from, $to = '' ) { 
    36203620
    36213621        $diff = (int) abs( $to - $from );
    36223622
    3623         if ( $diff < HOUR_IN_SECONDS ) {
     3623        if ( $diff < MINUTE_IN_SECONDS ) {
     3624                $secs = $diff;
     3625                if ( $secs <= 1 ) {
     3626                        $secs = 1;
     3627                }
     3628                /* translators: Time difference between two dates, in seconds. %s: Number of seconds */
     3629                $since = sprintf( _n( '%s second', '%s seconds', $secs ), $secs );
     3630        } elseif ( $diff < HOUR_IN_SECONDS && $diff >= MINUTE_IN_SECONDS ) {
    36243631                $mins = round( $diff / MINUTE_IN_SECONDS );
    36253632                if ( $mins <= 1 ) {
    36263633                        $mins = 1;
  • tests/phpunit/tests/formatting/HumanTimeDiff.php

    diff --git a/tests/phpunit/tests/formatting/HumanTimeDiff.php b/tests/phpunit/tests/formatting/HumanTimeDiff.php
    index da1ad2dcfc..473f5325d3 100644
    a b class Tests_Formatting_HumanTimeDiff extends WP_UnitTestCase { 
    1919        // Data for test_human_time_diff.
    2020        function data_test_human_time_diff() {
    2121                return array(
     22                        array(
     23                                '37 seconds',
     24                                new DateTime( '2016-01-01 12:00:37' ),
     25                                'Test a difference of 37 seconds.',
     26                        ),
    2227                        array(
    2328                                '5 mins',
    2429                                new DateTime( '2016-01-01 12:05:00' ),