Daniel Kinzler has submitted this change and it was merged. Change subject: Reuse existing date formats in MwTimeIsoFormatter ......................................................................
Reuse existing date formats in MwTimeIsoFormatter This is an alternative approach for the suggested change in Ic7a5797. Warning, this requires I232fd3b to be merged first! Change-Id: Id09e26e78e6733d7de63e5dbadebe8821a9f4556 --- M lib/includes/formatters/MwTimeIsoFormatter.php M lib/tests/phpunit/formatters/MwTimeIsoFormatterTest.php 2 files changed, 17 insertions(+), 3 deletions(-) Approvals: WikidataJenkins: Verified Daniel Kinzler: Looks good to me, approved jenkins-bot: Checked diff --git a/lib/includes/formatters/MwTimeIsoFormatter.php b/lib/includes/formatters/MwTimeIsoFormatter.php index 2c71732..e6d0fcd 100644 --- a/lib/includes/formatters/MwTimeIsoFormatter.php +++ b/lib/includes/formatters/MwTimeIsoFormatter.php @@ -123,10 +123,12 @@ } if ( $precision === TimeValue::PRECISION_MONTH ) { - return 'F Y'; + $format = $this->language->getDateFormatString( 'monthonly', 'dmy' ); + return $format ?: 'F Y'; } - return 'j F Y'; + $format = $this->language->getDateFormatString( 'date', 'dmy' ); + return $format ?: 'j F Y'; } /** diff --git a/lib/tests/phpunit/formatters/MwTimeIsoFormatterTest.php b/lib/tests/phpunit/formatters/MwTimeIsoFormatterTest.php index c5c831f..a0a849b 100644 --- a/lib/tests/phpunit/formatters/MwTimeIsoFormatterTest.php +++ b/lib/tests/phpunit/formatters/MwTimeIsoFormatterTest.php @@ -265,6 +265,15 @@ '13 billion years BCE', ), + // Some languages default to genitive month names + array( + '+2013-08-16T00:00:00Z', TimeValue::PRECISION_DAY, + // Nominative is "Augustus", genitive is "Augusti". + '16 Augusti 2013', + true, + 'la' + ), + // Valid values with day, month and/or year zero array( '+00000001995-00-00T00:00:00Z', TimeValue::PRECISION_YEAR, @@ -354,7 +363,8 @@ $argLists[] = array( isset( $args[2] ) ? $args[2] : $args[0], $timeValue, - isset( $args[3] ) + isset( $args[3] ), + isset( $args[4] ) ? $args[4] : 'en' ); } @@ -363,8 +373,10 @@ 'ar', //replaces all numbers and separators 'bo', //replaces only numbers 'de', //switches separators + 'la', //defaults to genitive month names 'or', //replaces all numbers and separators ); + foreach ( $languageCodes as $languageCode ) { $argLists[] = array( '3333', -- To view, visit https://gerrit.wikimedia.org/r/148641 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id09e26e78e6733d7de63e5dbadebe8821a9f4556 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Eranroz <eranro...@gmail.com> Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: WikidataJenkins <wikidata-servi...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits