Krinkle has submitted this change and it was merged.

Change subject: Fix regression: Timestamps wrongly use current time
......................................................................


Fix regression: Timestamps wrongly use current time

Follows-up beb5d5b. The timestamps worked until I changed
use of DateTime objects back to integers. Should've stuck
with DateTime objects in the first place.

Bug: T97756
Change-Id: Id45cb1aea9fcc5df2176c63180f781344044d54a
---
M app.php
M lb/wikicontribs.php
2 files changed, 8 insertions(+), 11 deletions(-)

Approvals:
  Krinkle: Verified; Looks good to me, approved



diff --git a/app.php b/app.php
index 5756365..180d5d5 100644
--- a/app.php
+++ b/app.php
@@ -109,9 +109,9 @@
     /**
      * Take a mediawiki timestamp and returns a unix timestamp
      * @param string $tstime
-     * @return int UNIX timestamp
+     * @return DateTime
      */
-    public function TsToUnixTime($tstime) {
+    public function parseMwDate($tstime) {
         // Based on MWTimestamp::setTimestamp for TS_MW
         $da = array();
         preg_match( '/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/D', $tstime, $da 
);
@@ -120,10 +120,7 @@
         $da[0] = '%04d-%02d-%02dT%02d:%02d:%02d.00+00:00';
         $strtime = call_user_func_array( 'sprintf', $da );
 
-        #$date = new DateTime( $strtime, new DateTimeZone( 'GMT' ) );
-        #return $date->format($timeformat);
-
-        return strtotime($strtime);
+        return new DateTime( $strtime, new DateTimeZone( 'GMT' ) );
     }
 
     /**
@@ -131,12 +128,12 @@
      * @param string $tstime
      * @return string
      */
-    public function TStoUserTime($tstime, $timeformat = 'H:i, d M Y') {
+    public function formatMwDate($tstime, $timeformat = 'H:i, d M Y') {
         if ($tstime === 'infinity') {
             return $tstime;
         }
-        $time = $this->TsToUnixTime($tstime);
-        return date($timeformat);
+        $date = $this->parseMwDate($tstime);
+        return $date->format($timeformat);
     }
 
     /**
diff --git a/lb/wikicontribs.php b/lb/wikicontribs.php
index c151b17..7e381b9 100644
--- a/lb/wikicontribs.php
+++ b/lb/wikicontribs.php
@@ -285,7 +285,7 @@
         }
         $userinfo[] = $this->wiki->_editcount . ' edits';
         if ($this->centralAuth) {
-            $userinfo[] = 'SUL: Account attached at 
'.$this->app->TStoUserTime($this->centralAuth->lu_attached_timestamp);
+            $userinfo[] = 'SUL: Account attached at 
'.$this->app->formatMwDate($this->centralAuth->lu_attached_timestamp);
         }
         if ($this->markAsNotUnified()) {
             $userinfo[] = 'SUL: Account not attached.';
@@ -304,7 +304,7 @@
                 ;
 
             // Date
-            $item[] = $this->app->TStoUserTime($rc->rev_timestamp);
+            $item[] = $this->app->formatMwDate($rc->rev_timestamp);
 
             // Patterns may yield different users for different edits,
             // provide basic tools for each entry.

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id45cb1aea9fcc5df2176c63180f781344044d54a
Gerrit-PatchSet: 1
Gerrit-Project: labs/tools/guc
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>

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

Reply via email to