Tobias Gritschacher has uploaded a new change for review. https://gerrit.wikimedia.org/r/118679
Change subject: Don't use '-' as separator in dates in the time parser ...................................................................... Don't use '-' as separator in dates in the time parser - added testcases for dates that did not work correctly when replacing spaces with a '-' in the time parser - require 0.4 version of date-values/time Change-Id: I09a632cb745d256ed8ac8c43db3759c9db960576 --- M composer.json M lib/includes/parsers/DateTimeParser.php M lib/tests/phpunit/parsers/DateTimeParserTest.php 3 files changed, 6 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/79/118679/1 diff --git a/composer.json b/composer.json index c9e48f7..caf6107 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "data-values/common": "~0.2.0", "data-values/geo": "~0.1.0", "data-values/number": "~0.3.0", - "data-values/time": "~0.3.0", + "data-values/time": "~0.4.0", "data-values/validators": "~0.1.0", "data-values/data-types": "~0.1.0", "data-values/serialization": "~0.1.0", diff --git a/lib/includes/parsers/DateTimeParser.php b/lib/includes/parsers/DateTimeParser.php index 04b95a5..af6e420 100644 --- a/lib/includes/parsers/DateTimeParser.php +++ b/lib/includes/parsers/DateTimeParser.php @@ -53,7 +53,7 @@ //WTF PHP FAIL: Apparently PHP doesn't like spaces as separators in dates, so replace with a '-' // See http://de1.php.net/manual/en/datetime.formats.date.php - $value = preg_replace( '/\s+/', '-', trim( $value ) ); + $value = preg_replace( '/\s+/', '.', trim( $value ) ); //Parse using the DateTime object (this will allow us to format the date in a nicer way) //TODO try to match and remove BCE etc. before putting the value into the DateTime object to get - dates! diff --git a/lib/tests/phpunit/parsers/DateTimeParserTest.php b/lib/tests/phpunit/parsers/DateTimeParserTest.php index b91cf21..67e6503 100644 --- a/lib/tests/phpunit/parsers/DateTimeParserTest.php +++ b/lib/tests/phpunit/parsers/DateTimeParserTest.php @@ -67,6 +67,10 @@ array( '+0000000000002009-01-09T00:00:00Z', 0 , 0 , 0 , TimeValue::PRECISION_DAY , TimeFormatter::CALENDAR_GREGORIAN ), '2009-01-09' => array( '+0000000000002009-01-09T00:00:00Z', 0 , 0 , 0 , TimeValue::PRECISION_DAY , TimeFormatter::CALENDAR_GREGORIAN ), + 'January 9 1920' => + array( '+0000000000001920-01-09T00:00:00Z', 0 , 0 , 0 , TimeValue::PRECISION_DAY , TimeFormatter::CALENDAR_GREGORIAN ), + 'Feb 11 1930' => + array( '+0000000000001930-02-11T00:00:00Z', 0 , 0 , 0 , TimeValue::PRECISION_DAY , TimeFormatter::CALENDAR_GREGORIAN ), '1st July 2013' => array( '+0000000000002013-07-01T00:00:00Z', 0 , 0 , 0 , TimeValue::PRECISION_DAY , TimeFormatter::CALENDAR_GREGORIAN ), '2nd July 2013' => -- To view, visit https://gerrit.wikimedia.org/r/118679 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I09a632cb745d256ed8ac8c43db3759c9db960576 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