Tobias Gritschacher has uploaded a new change for review. https://gerrit.wikimedia.org/r/118711
Change subject: Fix HtmlTimeFormatter ...................................................................... Fix HtmlTimeFormatter HtmlTimeFormatter::calendarNameNeeded was using a wrong approach to parse the year from the ISO string. That resulted in the calendarmodel-hint always shown for dates like e.g. 2014-10-10 where it is not necessary to show the hint. Change-Id: Iaba698ed4cfb91c7452b144f28446947b9ab2c1a --- M lib/includes/formatters/HtmlTimeFormatter.php M lib/tests/phpunit/formatters/HtmlTimeFormatterTest.php 2 files changed, 9 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/11/118711/1 diff --git a/lib/includes/formatters/HtmlTimeFormatter.php b/lib/includes/formatters/HtmlTimeFormatter.php index 445fd17..08478e7 100644 --- a/lib/includes/formatters/HtmlTimeFormatter.php +++ b/lib/includes/formatters/HtmlTimeFormatter.php @@ -71,7 +71,7 @@ } private function calendarNameNeeded( TimeValue $value ) { - $date = date_parse( $value->getTime() ); + $date = date_parse_from_format( 'Y+', $value->getTime() ); $year = $date['year']; $calendar = $this->getCalendarKey( $value->getCalendarModel() ); diff --git a/lib/tests/phpunit/formatters/HtmlTimeFormatterTest.php b/lib/tests/phpunit/formatters/HtmlTimeFormatterTest.php index a7f8951..7939796 100644 --- a/lib/tests/phpunit/formatters/HtmlTimeFormatterTest.php +++ b/lib/tests/phpunit/formatters/HtmlTimeFormatterTest.php @@ -83,6 +83,14 @@ TimeFormatter::CALENDAR_JULIAN ), new FormatterOptions(), '/^MOCKDATE <sup class="wb-calendar-name">Julian<\/sup>$/' + ), + '2014-10-10' => array( + new TimeValue( '+2014-10-10T00:00:00Z', + 1 * 60 * 60, 0, 0, + TimeValue::PRECISION_DAY, + TimeFormatter::CALENDAR_GREGORIAN ), + new FormatterOptions(), + '/^MOCKDATE$/' ) ); } -- To view, visit https://gerrit.wikimedia.org/r/118711 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iaba698ed4cfb91c7452b144f28446947b9ab2c1a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits