// The lrm is needed to make sure that the number
// is shown on the correct side of the tooltip text.
$durationTooltip = '‎' . htmlspecialchars( $params[4] );
- $params[4] = Message::rawParam( "<span class='blockExpiry' title='$durationTooltip'>" .
- $this->context->getLanguage()->translateBlockExpiry( $params[4],
- $this->context->getUser() ) . '</span>' );
+ $params[4] = Message::rawParam(
+ "<span class='blockExpiry' title='$durationTooltip'>" .
+ $this->context->getLanguage()->translateBlockExpiry(
+ $params[4],
+ $this->context->getUser(),
+ wfTimestamp( TS_UNIX, $this->entry->getTimestamp() )
+ ) .
+ '</span>'
+ );
$params[5] = isset( $params[5] ) ?
self::formatBlockFlags( $params[5], $this->context->getLanguage() ) : '';
}
$rawDuration = $parameters['5::duration'];
$rawFlags = $parameters['6::flags'];
}
- $duration = $wgContLang->translateBlockExpiry( $rawDuration );
+ $duration = $wgContLang->translateBlockExpiry(
+ $rawDuration,
+ null,
+ wfTimestamp( TS_UNIX, $entry->getTimestamp() )
+ );
$flags = BlockLogFormatter::formatBlockFlags( $rawFlags, $wgContLang );
$text = wfMessage( 'blocklogentry' )
->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
->rawParams( $target )->inContentLanguage()->escaped();
break;
case 'reblock':
- $duration = $wgContLang->translateBlockExpiry( $parameters['5::duration'] );
+ $duration = $wgContLang->translateBlockExpiry(
+ $parameters['5::duration'],
+ null,
+ wfTimestamp( TS_UNIX, $entry->getTimestamp() )
+ );
$flags = BlockLogFormatter::formatBlockFlags( $parameters['6::flags'], $wgContLang );
$text = wfMessage( 'reblock-logentry' )
->rawParams( $target, $duration, $flags )->inContentLanguage()->escaped();
*
* @param string $str The validated block duration in English
* @param User $user User object to use timezone from or null for $wgUser
+ * @param int $now Current timestamp, for formatting relative block durations
* @return string Somehow translated block duration
* @see LanguageFi.php for example implementation
*/
- function translateBlockExpiry( $str, User $user = null ) {
+ function translateBlockExpiry( $str, User $user = null, $now = 0 ) {
$duration = SpecialBlock::getSuggestedDurations( $this );
foreach ( $duration as $show => $value ) {
if ( strcmp( $str, $value ) == 0 ) {
}
// If all else fails, return a standard duration or timestamp description.
- $time = strtotime( $str, 0 );
+ $time = strtotime( $str, $now );
if ( $time === false ) { // Unknown format. Return it as-is in case.
return $str;
- } elseif ( $time !== strtotime( $str, 1 ) ) { // It's a relative timestamp.
- // $time is relative to 0 so it's a duration length.
+ } elseif ( $time !== strtotime( $str, $now + 1 ) ) { // It's a relative timestamp.
+ // The result differs based on current time, so it's a duration length.
return $this->formatDuration( $time );
} else { // It's an absolute timestamp.
if ( $time === 0 ) {
/**
* @param string $str
* @param User $user User object to use timezone from or null for $wgUser
+ * @param int $now Current timestamp, for formatting relative block durations
* @return string
*/
- function translateBlockExpiry( $str, User $user = null ) {
+ function translateBlockExpiry( $str, User $user = null, $now = 0 ) {
/*
'ago', 'now', 'today', 'this', 'next',
'first', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth',