Date/time fixes: try to ensure that timestamps are always kept in GMT, with conversio...
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 30 Jun 2003 01:33:16 +0000 (01:33 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 30 Jun 2003 01:33:16 +0000 (01:33 +0000)
14 files changed:
includes/Article.php
includes/DatabaseFunctions.php
includes/GlobalFunctions.php
includes/LogPage.php
includes/OutputPage.php
includes/Skin.php
includes/SpecialBlockip.php
includes/SpecialLockdb.php
includes/SpecialRecentchanges.php
includes/SpecialRecentchangeslinked.php
includes/SpecialUpload.php
includes/SpecialWatchlist.php
languages/LanguageKo.php
languages/LanguagePl.php

index ea9e958..cf242df 100644 (file)
@@ -1528,7 +1528,8 @@ name=\"wpSummary\" maxlength=200 size=60><br>
                if(isset($wgLocaltimezone)) {
                        $oldtz = getenv("TZ"); putenv("TZ=$wgLocaltimezone");
                }
-               $d = $wgLang->timeanddate( wfTimestampNow(), false ) .
+               /* Note: this is an ugly timezone hack for the European wikis */
+               $d = $wgLang->timeanddate( date( "YmdHis" ), false ) .
                  " (" . date( "T" ) . ")";
                if(isset($wgLocaltimezone)) putenv("TZ=$oldtz");
 
index 3d93047..bcec86d 100644 (file)
@@ -107,19 +107,19 @@ function wfStrencode( $s )
 
 # Ideally we'd be using actual time fields in the db
 function wfTimestamp2Unix( $ts ) {
-       return mktime( ( (int)substr( $ts, 8, 2) ),
+       return gmmktime( ( (int)substr( $ts, 8, 2) ),
                  (int)substr( $ts, 10, 2 ), (int)substr( $ts, 12, 2 ),
                  (int)substr( $ts, 4, 2 ), (int)substr( $ts, 6, 2 ),
                  (int)substr( $ts, 0, 4 ) );
 }
 
 function wfUnix2Timestamp( $unixtime ) {
-       return date( "YmdHis", $unixtime );
+       return gmdate( "YmdHis", $unixtime );
 }
 
 function wfTimestampNow() {
        # return NOW
-       return date( "YmdHis" );
+       return gmdate( "YmdHis" );
 }
 
 # Sorting hack for MySQL 3, which doesn't use index sorts for DESC
index 124711b..2a76633 100644 (file)
@@ -386,7 +386,7 @@ function wfRecordUpload( $name, $oldver, $size, $desc )
        if ( 0 == wfNumRows( $res ) ) {
                $sql = "INSERT INTO image (img_name,img_size,img_timestamp," .
                  "img_description,img_user,img_user_text) VALUES ('" .
-                 wfStrencode( $name ) . "',{$size},'" . date( "YmdHis" ) . "','" .
+                 wfStrencode( $name ) . "',{$size},'" . wfTimestampNow() . "','" .
                  wfStrencode( $desc ) . "', '" . $wgUser->getID() .
                  "', '" . wfStrencode( $wgUser->getName() ) . "')";
                wfQuery( $sql, $fname );
@@ -432,7 +432,7 @@ function wfRecordUpload( $name, $oldver, $size, $desc )
                wfQuery( $sql, $fname );
 
                $sql = "UPDATE image SET img_size={$size}," .
-                 "img_timestamp='" . date( "YmdHis" ) . "',img_user='" .
+                 "img_timestamp='" . wfTimestampNow() . "',img_user='" .
                  $wgUser->getID() . "',img_user_text='" .
                  wfStrencode( $wgUser->getName() ) . "', img_description='" .
                  wfStrencode( $desc ) . "' WHERE img_name='" .
index 45d2d35..bd8c928 100644 (file)
@@ -104,7 +104,7 @@ class LogPage {
                } else {
                        $ul = $ut;
                }
-               $d = $wgLang->timeanddate( date( "YmdHis" ), false );
+               $d = $wgLang->timeanddate( wfTimestampNow(), false );
 
                preg_match( "/^(.*?)<ul>(.*)$/sD", $this->mContent, $m );
 
index 8aaf592..cae5c29 100644 (file)
@@ -152,14 +152,17 @@ class OutputPage {
                if( !$wgCachePages ) return;
                if( preg_match( '/MSIE ([1-4]|5\.0)/', $_SERVER["HTTP_USER_AGENT"] ) ) {
                        # IE 5.0 has probs with our caching
+                       #wfDebug( "-- bad client, not caching\n", false );
                        return;
                }
                if( $wgUser->getOption( "nocache" ) ) return;
 
                if( $_SERVER["HTTP_IF_MODIFIED_SINCE"] != "" ) {
                        $ismodsince = wfUnix2Timestamp( strtotime( $_SERVER["HTTP_IF_MODIFIED_SINCE"] ) );
+                       #wfDebug( "-- client send If-Modified-Since: " . $_SERVER["HTTP_IF_MODIFIED_SINCE"] . "\n", false );
                        $lastmod = gmdate( "D, j M Y H:i:s", wfTimestamp2Unix(
                                max( $timestamp, $wgUser->mTouched ) ) ) . " GMT";
+                       #wfDebug( "--  we might send Last-Modified : $lastmod\n", false ); 
                
                        if( ($ismodsince >= $timestamp ) and $wgUser->validateCache( $ismodsince ) ) {
                                # Make sure you're in a place you can leave when you call us!
@@ -468,7 +471,7 @@ class OutputPage {
                        if($wgUser->getId() == 0)
                                $forward .= " anon";
                        $log = sprintf( "%s\t%04.3f\t%s\n",
-                         date( "YmdHis" ), $elapsed,
+                         gmdate( "YmdHis" ), $elapsed,
                          urldecode( $HTTP_SERVER_VARS['REQUEST_URI'] . $forward ) );
                        error_log( $log . $prof, 3, $wgDebugLogFile );
                }
@@ -1063,6 +1066,8 @@ class OutputPage {
                global $wgLang;
                wfProfileIn( "OutputPage:replaceVariables" );
 
+               /* As with sigs, use server's local time --
+                  ensure this is appropriate for your audience! */
                $v = date( "m" );
                $text = str_replace( "{{CURRENTMONTH}}", $v, $text );
                $v = $wgLang->getMonthName( date( "n" ) );
@@ -1075,7 +1080,7 @@ class OutputPage {
                $text = str_replace( "{{CURRENTDAYNAME}}", $v, $text );
                $v = date( "Y" );
                $text = str_replace( "{{CURRENTYEAR}}", $v, $text );
-               $v = $wgLang->time( date( "YmdHis" ), false );
+               $v = $wgLang->time( wfTimestampNow(), false );
                $text = str_replace( "{{CURRENTTIME}}", $v, $text );
 
                if ( false !== strstr( $text, "{{NUMBEROFARTICLES}}" ) ) {
index 2525476..4022e53 100644 (file)
@@ -938,8 +938,8 @@ class Skin {
        function dateLink()
        {
                global $wgLinkCache;
-               $t1 = Title::newFromText( date( "F j" ) );
-               $t2 = Title::newFromText( date( "Y" ) );
+               $t1 = Title::newFromText( gmdate( "F j" ) );
+               $t2 = Title::newFromText( gmdate( "Y" ) );
 
                $wgLinkCache->suspend();
                $id = $t1->getArticleID();
index bc24f4d..6d1cb59 100644 (file)
@@ -74,7 +74,7 @@ class IPBlockForm {
                $sql = "INSERT INTO ipblocks (ipb_address, ipb_user, ipb_by, " .
                  "ipb_reason, ipb_timestamp ) VALUES ('{$wpBlockAddress}', 0, " .
                  $wgUser->getID() . ", '" . wfStrencode( $wpBlockReason ) . "','" .
-                 date( "YmdHis" ) . "')";
+                 wfTimestampNow() . "')";
                wfQuery( $sql, $fname );
 
                $success = wfLocalUrl( $wgLang->specialPage( "Blockip" ),
index efc75a0..f72b222 100644 (file)
@@ -73,7 +73,7 @@ class DBLockForm {
                }
                fwrite( $fp, $wpLockReason );
                fwrite( $fp, "\n<p>(by " . $wgUser->getName() . " at " .
-                 $wgLang->timeanddate( date( "YmdHis" ) ) . ")\n" );
+                 $wgLang->timeanddate( wfTimestampNow() ) . ")\n" );
                fclose( $fp );
 
                $success = wfLocalUrl( $wgLang->specialPage( "Lockdb" ),
index 7b6daec..e97c6e9 100644 (file)
@@ -25,7 +25,8 @@ function wfSpecialRecentchanges()
        }
        $days = (int)$days;
        list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
-       $cutoff = date( "YmdHis", time() - ( $days * 86400 ) );
+       $now = wfTimestampNow();
+       $cutoff = wfUnix2Timestamp( time() - ( $days * 86400 ) );
        if(preg_match('/^[0-9]{14}$/', $from) and $from > $cutoff) {
                $cutoff = $from;
        } else {
@@ -72,7 +73,6 @@ function wfSpecialRecentchanges()
 
        $note = rcDayLimitLinks( $days, $limit );
 
-       $now = date( "YmdHis" );
        $note .= "<br>\n" . wfMsg( "rclistfrom",
          $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ),
          $wgLang->timeanddate( $now, true ), "from=$now" ) );
index 6f3f8df..0f221b5 100644 (file)
@@ -25,7 +25,7 @@ function wfSpecialRecentchangeslinked()
        }
        $days = (int)$days;
        list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
-       $cutoff = date( "YmdHis", time() - ( $days * 86400 ) );
+       $cutoff = wfUnix2Timestamp( time() - ( $days * 86400 ) );
 
        if ( ! isset( $hideminor ) ) {
                $hideminor = $wgUser->getOption( "hideminor" );
index 8dcaaf4..88093f3 100644 (file)
@@ -115,7 +115,7 @@ function saveUploadedFile()
        $wgSavedFile = "{$dest}/{$wpUploadSaveName}";
 
        if ( is_file( $wgSavedFile ) ) {
-               $wgUploadOldVersion = date( "YmdHis" ) . "!{$wpUploadSaveName}";
+               $wgUploadOldVersion = gmdate( "YmdHis" ) . "!{$wpUploadSaveName}";
 
                if ( ! rename( $wgSavedFile, "${archive}/{$wgUploadOldVersion}" ) ) { 
                        $wgOut->fileRenameError( $wgSavedFile,
index 940a45a..189a5dc 100644 (file)
@@ -24,7 +24,7 @@ function wfSpecialWatchlist()
                $docutoff = '';
        } else {
                $docutoff = "cur_timestamp > '" .
-                 date( "YmdHis", time() - ( $days * 86400 ) )
+                 wfUnix2Timestamp( time() - ( $days * 86400 ) )
                  . "' AND";
        }
        if ( $limit == 0 ) {
index 2517cd7..7294029 100644 (file)
@@ -1051,10 +1051,7 @@ class LanguageKo extends LanguageUtf8 {
                return $this->date( $ts, $adj ) . " " . $this->time( $ts, $adj );
        }
 
-       function rfc1123( $ts )
-       {
-               return date( "D, d M Y H:i:s T", $ts );
-       }
+       # inherit function rfc1123( $ts )
 
        function getValidSpecialPages()
        {
index 38654f8..6986bf8 100644 (file)
@@ -1150,20 +1150,7 @@ class LanguagePl extends LanguageUtf8 {
                 return $wgWeekdayNamesPl[$key-1];
         }
 
-        function userAdjust( $ts )
-        {
-                global $wgUser;
-
-                $diff = $wgUser->getOption( "timecorrection" );
-                if ( ! $diff ) { $diff = 0; }
-                if ( 0 == $diff ) { return $ts; }
-
-                $t = mktime( ( (int)substr( $ts, 8, 2) ) + $diff,
-                  (int)substr( $ts, 10, 2 ), (int)substr( $ts, 12, 2 ),
-                  (int)substr( $ts, 4, 2 ), (int)substr( $ts, 6, 2 ),
-                  (int)substr( $ts, 0, 4 ) );
-                return date( "YmdHis", $t );
-        }
+        # inherit function userAdjust( $ts )
 
         function date( $ts, $adj = false )
         {