Removed arbitrary change in timestamp formats between MySQL and PostgreSQL, moved...
authorTim Starling <tstarling@users.mediawiki.org>
Tue, 29 Jun 2004 12:23:59 +0000 (12:23 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Tue, 29 Jun 2004 12:23:59 +0000 (12:23 +0000)
includes/Database.php
includes/DatabasePostgreSQL.php
includes/EditPage.php
includes/GlobalFunctions.php

index 080d372..3cb22ea 100644 (file)
@@ -465,8 +465,7 @@ class Database {
        function stopTimer()
        {
        }
-
-}
+} 
 
 #------------------------------------------------------------------------------
 # Global functions
@@ -526,34 +525,9 @@ function wfStrencode( $s )
        return addslashes( $s );
 }
 
-# Ideally we'd be using actual time fields in the db
-function wfTimestamp2Unix( $ts ) {
-       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 gmdate( "YmdHis", $unixtime );
-}
-
-function wfTimestampNow() {
-       # return NOW
-       return gmdate( "YmdHis" );
-}
-
-# Sorting hack for MySQL 3, which doesn't use index sorts for DESC
-function wfInvertTimestamp( $ts ) {
-       return strtr(
-               $ts,
-               "0123456789",
-               "9876543210"
-       );
-}
-
 function wfLimitResult( $limit, $offset ) {
        return " LIMIT ".(is_numeric($offset)?"{$offset},":"")."{$limit} ";
 }
 
+
 ?>
index f9add19..2b3ba25 100644 (file)
@@ -515,33 +515,6 @@ function wfStrencode( $s )
        return pg_escape_string( $s );
 }
 
-# Use PostgreSQL timestamp without timezone data type
-function wfTimestamp2Unix( $ts ) {
-       return gmmktime( ( (int)substr( $ts, 11, 2) ),
-                  (int)substr( $ts, 14, 2 ), (int)substr( $ts, 17, 2 ),
-                  (int)substr( $ts, 5, 2 ), (int)substr( $ts, 8, 2 ),
-                  (int)substr( $ts, 0, 4 ) );
-}
-
-function wfUnix2Timestamp( $unixtime ) {
-       return gmdate( "Y-m-d H:i:s", $unixtime );
-}
-
-function wfTimestampNow() {
-       # return NOW
-       return gmdate( "Y-m-d H:i:s" );
-}
-
-# Sorting hack for MySQL 3, which doesn't use index sorts for DESC
-function wfInvertTimestamp( $ts ) {
-       $ts=preg_replace("/\D/","",$ts);
-       return strtr(
-               $ts,
-               "0123456789",
-               "9876543210"
-       );
-}
-
 function wfLimitResult( $limit, $offset ) {
         return " LIMIT $limit ".(is_numeric($offset)?" OFFSET {$offset} ":"");
 }
index 2d779ac..b2e0171 100644 (file)
@@ -62,7 +62,6 @@ class EditPage {
        }
 
        function importFormData( &$request ) {
-               global $wgIsMySQL, $wgIsPg;
                # These fields need to be checked for encoding.
                # Also remove trailing whitespace, but don't remove _initial_
                # whitespace from the text boxes. This may be significant formatting.
@@ -71,12 +70,7 @@ class EditPage {
                $this->summary = trim( $request->getText( "wpSummary" ) );
 
                $this->edittime = $request->getVal( 'wpEdittime' );
-               if ($wgIsMySQL) 
-                       if( !preg_match( '/^\d{14}$/', $this->edittime )) $this->edittime = "";
-               if ($wgIsPg)
-                       if ( !preg_match( '/^\d{4}-\d\d-\d\d \d\d:\d\d:\d\d$/', 
-                               $this->edittime ))
-                               $this->edittime = "";
+               if( !preg_match( '/^\d{14}$/', $this->edittime )) $this->edittime = "";
 
                $this->preview = $request->getCheck( 'wpPreview' );
                $this->save = $request->wasPosted() && !$this->preview;
index 0ae7fdc..a37e1dc 100644 (file)
@@ -972,4 +972,32 @@ function wfIsWindows() {
        }
 }
 
+
+# Ideally we'd be using actual time fields in the db
+function wfTimestamp2Unix( $ts ) {
+       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 gmdate( "YmdHis", $unixtime );
+}
+
+function wfTimestampNow() {
+       # return NOW
+       return gmdate( "YmdHis" );
+}
+
+# Sorting hack for MySQL 3, which doesn't use index sorts for DESC
+function wfInvertTimestamp( $ts ) {
+       return strtr(
+               $ts,
+               "0123456789",
+               "9876543210"
+       );
+}
+
+
 ?>