Thiemo Mättig (WMDE) has uploaded a new change for review.
https://gerrit.wikimedia.org/r/191634
Change subject: Do not display meaningless Z in DateTime diffs
......................................................................
Do not display meaningless Z in DateTime diffs
The Z is there for a single reason: To make the string a "valid"
ISO timestamp. But the Z is meaningless and *must* be ignored.
We store the actual time zone in a separate field.
When we display it people get confused for no reason.
Change-Id: I27861d40a776c60db6aa2a1f9013fb122ae5c9ca
---
M lib/includes/formatters/TimeDetailsFormatter.php
M lib/tests/phpunit/formatters/TimeDetailsFormatterTest.php
2 files changed, 19 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/34/191634/1
diff --git a/lib/includes/formatters/TimeDetailsFormatter.php
b/lib/includes/formatters/TimeDetailsFormatter.php
index ac53e32..95d9538 100644
--- a/lib/includes/formatters/TimeDetailsFormatter.php
+++ b/lib/includes/formatters/TimeDetailsFormatter.php
@@ -66,7 +66,7 @@
$html .= $this->renderLabelValuePair(
'isotime',
- htmlspecialchars( $value->getTime() )
+ $this->getTimeHtml( $value->getTime() )
);
$html .= $this->renderLabelValuePair(
'timezone',
@@ -96,6 +96,15 @@
}
/**
+ * @param string $time
+ *
+ * @return string HTML
+ */
+ private function getTimeHtml( $time ) {
+ return preg_replace( '/(?<=\d)Z$/i', '', $time );
+ }
+
+ /**
* @param int $timezone
*
* @return string HTML
diff --git a/lib/tests/phpunit/formatters/TimeDetailsFormatterTest.php
b/lib/tests/phpunit/formatters/TimeDetailsFormatterTest.php
index 725dc41..b522815 100644
--- a/lib/tests/phpunit/formatters/TimeDetailsFormatterTest.php
+++ b/lib/tests/phpunit/formatters/TimeDetailsFormatterTest.php
@@ -46,7 +46,7 @@
'@' . implode( '.*',
array(
'<h4[^<>]*>[^<>]*2001[^<>]*</h4>',
-
'<td[^<>]*>\+0*2001-01-01T00:00:00Z</td>',
+
'<td[^<>]*>\+0*2001-01-01T00:00:00</td>',
'<td[^<>]*>\+01:00</td>',
'<td[^<>]*>\(valueview-expert-timevalue-calendar-gregorian\)</td>',
'<td[^<>]*>\(months: 1\)</td>',
@@ -56,6 +56,14 @@
) . '@s'
),
array(
+ new TimeValue( '+999-01-01T00:00:00Z', 0, 0, 0,
$day, $gregorian ),
+
'@.*<td[^<>]*isotime">\+999-01-01T00:00:00</td>.*@s'
+ ),
+ array(
+ new TimeValue( '+099999-01-01T00:00:00Z', 0, 0,
0, $day, $gregorian ),
+
'@.*<td[^<>]*isotime">\+099999-01-01T00:00:00</td>.*@s'
+ ),
+ array(
new TimeValue( '+2001-01-01T00:00:00Z', 0, 0,
0, $day, TimeFormatter::CALENDAR_JULIAN ),
'@.*<td[^<>]*calendar">\(valueview-expert-timevalue-calendar-julian\)</td>.*@s'
),
--
To view, visit https://gerrit.wikimedia.org/r/191634
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I27861d40a776c60db6aa2a1f9013fb122ae5c9ca
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