Yaron Koren has submitted this change and it was merged.

Change subject: Fix for display of year-only dates
......................................................................


Fix for display of year-only dates

It showed values one year too low, for some years.

Change-Id: I04672ff511c87560bb5fb08d4217c0d81e071f9b
---
M CargoQueryDisplayer.php
1 file changed, 7 insertions(+), 1 deletion(-)

Approvals:
  Yaron Koren: Checked; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/CargoQueryDisplayer.php b/CargoQueryDisplayer.php
index 0a63ef9..282dd47 100644
--- a/CargoQueryDisplayer.php
+++ b/CargoQueryDisplayer.php
@@ -184,7 +184,13 @@
                if ( $datePrecision == CargoStore::YEAR_ONLY ) {
                        // 'o' is better than 'Y' because it does not add
                        // leading zeroes to years with fewer than four digits.
-                       return date( 'o', $seconds );
+                       // For some reason, this fails for some years -
+                       // returning one year lower than it's supposed to -
+                       // unless you add the equivalent of 3 days or more
+                       // to the number of seconds. Is that a leap day thing?
+                       // Weird PHP bug? Who knows. Anyway, it's easy to get
+                       // around.
+                       return date( 'o', $seconds + 300000 );
                } elseif ( $datePrecision == CargoStore::MONTH_ONLY ) {
                        return CargoDrilldownUtils::monthToString( date( 'm', 
$seconds ) ) .
                                ' ' . date( 'o', $seconds );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I04672ff511c87560bb5fb08d4217c0d81e071f9b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cargo
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren <[email protected]>
Gerrit-Reviewer: Yaron Koren <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to