From: Greg Sabino Mullane Date: Tue, 18 Jul 2006 01:40:38 +0000 (+0000) Subject: Add Postgres timestamp stuff, from the patch at bug 6632 by Robert Treat. X-Git-Tag: 1.31.0-rc.0~56187 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=ef047e87e26ec5a6018ddcef6eea2527a2c9d438;p=lhc%2Fweb%2Fwiklou.git Add Postgres timestamp stuff, from the patch at bug 6632 by Robert Treat. --- diff --git a/includes/DatabasePostgres.php b/includes/DatabasePostgres.php index b0dfb7437a..eba6cb1504 100644 --- a/includes/DatabasePostgres.php +++ b/includes/DatabasePostgres.php @@ -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); } /** diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index a50e3e1da5..dc35e828dc 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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.'); }