translateBlockExpiry: Duration is block expiry minus current time
authorZhuyifei1999 <zhuyifei1999@gmail.com>
Fri, 27 Jan 2017 08:51:06 +0000 (08:51 +0000)
committerBartosz Dziewoński <matma.rex@gmail.com>
Sat, 28 Jan 2017 07:22:00 +0000 (07:22 +0000)
commit0effd172ce2d3b690814dd1b1af3e39e89550154
tree78ee4257215df17f95ca02b31a9beb2e1267c9d6
parent2221c33612f31470796a4ab31b3ff9e80940c6f6
translateBlockExpiry: Duration is block expiry minus current time

For relative timestamps in $str, strtotime( $str, $now ) returns an
absolute Unix timestamp $str since $now, and this timestamp is given
to $time. However, Language::formatDuration expects a time duration,
not an absolute timestamp. We obtain this duration from the difference
between $time, the absolute timestamp of block expiry, and $now, the
absolute timestamp of the time in which the block action happened.

Tests have been added to test both this patch and 01936fa, the patch
that caused this regression.

Bug: T156453
Change-Id: I6fd8c02dc3c6456067fe25cb9f33f5b4c78332aa
languages/Language.php
tests/phpunit/languages/LanguageTest.php