esotalk / esoTalk

Fat-free forum software.
GNU General Public License v2.0
1.47k stars 239 forks source link

Yesterday is actually the day before #389

Closed tvb closed 9 years ago

tvb commented 9 years ago

I noticed the following scenario. 2 post boths posted yesterday according to esoTalk: screen shot 2014-11-26 at 15 03 48

However the first one is posted on the 24th so should say posted 2 days ago screen shot 2014-11-26 at 15 05 51

the second one is posted on the 25th, so should indeed say yesterday. screen shot 2014-11-26 at 15 05 56

tvb commented 9 years ago

Found it. It should be a round() and not a floor():

    // If this happened over a day ago, return "x days ago".
    elseif ($ago >= ($period = 60 * 60 * 24)) {
        $days = floor($ago / $period);
        return Ts("%d day ago", "%d days ago", $days);
    }

to

    // If this happened over a day ago, return "x days ago".
    elseif ($ago >= ($period = 60 * 60 * 24)) {
        $days = round($ago / $period);
        return Ts("%d day ago", "%d days ago", $days);
    }

I've changed all floor references in the relativeTime() function and it looks good now!

jgknight commented 9 years ago

@tvb nice find. Go ahead and issue a pull request if you'd like and I'll merge it in.

tvb commented 9 years ago

I'll submit a pull request asap.

olivierlambert commented 9 years ago

No pull request yet?

I confirm this, but not only for days, same stuff for the rest: replacing all the floor() by round() fixed the issue.

All of this in the core/lib/functions.general.php file.

olivierlambert commented 9 years ago

@jgknight if you want a pull request, I can create one.

tvb commented 9 years ago

@olivierlambert go ahead. I have not found the time to sumbit a pull request yet and probably will not find it in the coming weeks. Thanks!

olivierlambert commented 9 years ago

Will do :)

olivierlambert commented 9 years ago

Done! https://github.com/esotalk/esoTalk/pull/394