Umherirrender has uploaded a new change for review. https://gerrit.wikimedia.org/r/281692
Change subject: Show absolute block expiry in user timezone on block logs ...................................................................... Show absolute block expiry in user timezone on block logs For this add an user parameter to Language::translateBlockExpiry. This allows the function to display the absolute block expiry in the user's time zone. Use this when formatting block log entries. This also avoids the user of $wgUser Change-Id: If0a1d3c88bb4242a016eb9b2df115413de786149 --- M includes/logging/BlockLogFormatter.php M languages/Language.php 2 files changed, 9 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/92/281692/1 diff --git a/includes/logging/BlockLogFormatter.php b/includes/logging/BlockLogFormatter.php index aa90d1d..21e40ec 100644 --- a/includes/logging/BlockLogFormatter.php +++ b/includes/logging/BlockLogFormatter.php @@ -58,7 +58,8 @@ // 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] ) . '</span>' ); + $this->context->getLanguage()->translateBlockExpiry( $params[4], + $this->context->getUser() ) . '</span>' ); $params[5] = isset( $params[5] ) ? self::formatBlockFlags( $params[5], $this->context->getLanguage() ) : ''; } diff --git a/languages/Language.php b/languages/Language.php index f13f9d6..4af4830 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -3966,10 +3966,11 @@ * match up with it. * * @param string $str The validated block duration in English + * @param User $user User object to use timezone from or null for $wgUser * @return string Somehow translated block duration * @see LanguageFi.php for example implementation */ - function translateBlockExpiry( $str ) { + function translateBlockExpiry( $str, User $user = null ) { $duration = SpecialBlock::getSuggestedDurations( $this ); foreach ( $duration as $show => $value ) { if ( strcmp( $str, $value ) == 0 ) { @@ -3995,10 +3996,12 @@ } else { // It's an absolute timestamp. if ( $time === 0 ) { // wfTimestamp() handles 0 as current time instead of epoch. - return $this->timeanddate( '19700101000000' ); - } else { - return $this->timeanddate( $time ); + $time = '19700101000000'; } + if ( $user ) { + return $this->userTimeAndDate( $time, $user ); + } + return $this->timeanddate( $time ); } } -- To view, visit https://gerrit.wikimedia.org/r/281692 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If0a1d3c88bb4242a016eb9b2df115413de786149 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Umherirrender <umherirrender_de...@web.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits