Add Postgres timestamp stuff, from the patch at bug 6632 by Robert Treat.
authorGreg Sabino Mullane <greg@users.mediawiki.org>
Tue, 18 Jul 2006 01:40:38 +0000 (01:40 +0000)
committerGreg Sabino Mullane <greg@users.mediawiki.org>
Tue, 18 Jul 2006 01:40:38 +0000 (01:40 +0000)
includes/DatabasePostgres.php
includes/GlobalFunctions.php

index b0dfb74..eba6cb1 100644 (file)
@@ -530,9 +530,8 @@ class DatabasePostgres extends Database {
                return false;
        }
 
-       # Return DB-style timestamp used for MySQL schema
        function timestamp( $ts=0 ) {
-               return wfTimestamp(TS_DB,$ts);
+               return wfTimestamp(TS_POSTGRES,$ts);
        }
 
        /**
index a50e3e1..dc35e82 100644 (file)
@@ -1293,6 +1293,11 @@ define('TS_EXIF', 5);
  */
 define('TS_ORACLE', 6);
 
+/**
+ * Postgres format time.
+ */
+define('TS_POSTGRES', 7);
+
 /**
  * @param mixed $outputtype A timestamp in one of the supported formats, the
  *                          function will autodetect which format is supplied
@@ -1327,6 +1332,10 @@ function wfTimestamp($outputtype=TS_UNIX,$ts=0) {
                # TS_ISO_8601
                $uts=gmmktime((int)$da[4],(int)$da[5],(int)$da[6],
                        (int)$da[2],(int)$da[3],(int)$da[1]);
+       } elseif (preg_match("/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)[\+\- ](\d\d)$/",$ts,$da)) {
+               # TS_POSTGRES
+               $uts=gmmktime((int)$da[4],(int)$da[5],(int)$da[6],
+               (int)$da[2],(int)$da[3],(int)$da[1]);
        } else {
                # Bogus value; fall back to the epoch...
                wfDebug("wfTimestamp() fed bogus time value: $outputtype; $ts\n");
@@ -1350,6 +1359,8 @@ function wfTimestamp($outputtype=TS_UNIX,$ts=0) {
                        return gmdate( 'D, d M Y H:i:s', $uts ) . ' GMT';
                case TS_ORACLE:
                        return gmdate( 'd-M-y h.i.s A', $uts) . ' +00:00';
+               case TS_POSTGRES:
+                       return gmdate( 'Y-m-d H:i:s', $uts) . ' GMT';
                default:
                        throw new MWException( 'wfTimestamp() called with illegal output type.');
        }