Thiemo Mättig (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/191641

Change subject: Use actual minus sign for timestamp in DateTime diffs
......................................................................

Use actual minus sign for timestamp in DateTime diffs

Warning, this currently does not round-trip. You can not copy-paste
this value any more because the current parser requires the Z in the
end and does not accept the actual minus sign. I will change this to
allow for a full round-trip, see https://github.com/DataValues/Time/pull/27

Change-Id: Icf9bfc6dddd1c26651e01d7e8b65295275f995a2
---
M lib/includes/formatters/TimeDetailsFormatter.php
M lib/tests/phpunit/formatters/TimeDetailsFormatterTest.php
2 files changed, 4 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/41/191641/1

diff --git a/lib/includes/formatters/TimeDetailsFormatter.php 
b/lib/includes/formatters/TimeDetailsFormatter.php
index c733ac2..c2fcfe2 100644
--- a/lib/includes/formatters/TimeDetailsFormatter.php
+++ b/lib/includes/formatters/TimeDetailsFormatter.php
@@ -106,9 +106,11 @@
                        return $time;
                }
 
+               // Actual MINUS SIGN (U+2212) instead of HYPHEN-MINUS (U+002D)
+               $sign = $matches[1] !== '+' ? "\xE2\x88\x92" : '+';
                // Warning, never cast the year to integer to not run into 
32-bit integer overflows!
                $year = ltrim( $matches[2], '0' );
-               return $matches[1] . str_pad( $year, 4, '0', STR_PAD_LEFT ) . 
$matches[3];
+               return $sign . str_pad( $year, 4, '0', STR_PAD_LEFT ) . 
$matches[3];
        }
 
        /**
diff --git a/lib/tests/phpunit/formatters/TimeDetailsFormatterTest.php 
b/lib/tests/phpunit/formatters/TimeDetailsFormatterTest.php
index 2cd60e1..d148440 100644
--- a/lib/tests/phpunit/formatters/TimeDetailsFormatterTest.php
+++ b/lib/tests/phpunit/formatters/TimeDetailsFormatterTest.php
@@ -61,7 +61,7 @@
                        ),
                        array(
                                new TimeValue( '-099999-01-01T00:00:00Z', 0, 0, 
0, $day, $gregorian ),
-                               
'@.*<td[^<>]*isotime">-99999-01-01T00:00:00</td>.*@s'
+                               
'@.*<td[^<>]*isotime">\xE2\x88\x9299999-01-01T00:00:00</td>.*@s'
                        ),
                        array(
                                new TimeValue( '+2001-01-01T00:00:00Z', 0, 0, 
0, $day, TimeFormatter::CALENDAR_JULIAN ),

-- 
To view, visit https://gerrit.wikimedia.org/r/191641
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icf9bfc6dddd1c26651e01d7e8b65295275f995a2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to