appdb/include util.php

WineHQ wineowner at wine.codeweavers.com
Thu Mar 15 18:45:50 CDT 2007


ChangeSet ID:	30973
CVSROOT:	/opt/cvs-commit
Module name:	appdb
Changes by:	wineowner at winehq.org	2007/03/15 18:45:49

Modified files:
	include        : util.php 

Log message:
	Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
	Parse MySQL timestamps according to the MySQL version

Patch: http://cvs.winehq.org/patch.py?id=30973

Old revision  New revision  Changes     Path
 1.83          1.84          +24 -7      appdb/include/util.php

Index: appdb/include/util.php
diff -u -p appdb/include/util.php:1.83 appdb/include/util.php:1.84
--- appdb/include/util.php:1.83	15 Mar 2007 23:45:49 -0000
+++ appdb/include/util.php	15 Mar 2007 23:45:49 -0000
@@ -77,13 +77,30 @@ function print_short_date($sTimestamp)
 
 function mysqltimestamp_to_unixtimestamp($sTimestamp)
 {
-  $d = substr($sTimestamp,6,2); // day
-  $m = substr($sTimestamp,4,2); // month
-  $y = substr($sTimestamp,0,4); // year
-  $hours = substr($sTimestamp,8,2); // year
-  $minutes = substr($sTimestamp,10,2); // year
-  $seconds = substr($sTimestamp,12,2); // year
-  return mktime($hours,$minutes,$seconds,$m, $d, $y);
+    $sResult = mysql_get_server_info();
+    $fVersion = substr($sResult, 0, 3);
+
+    /* This differs between MySQL versions, newer ones are in the form
+       yyyy-mm-dd hh:mm:ss */
+    if($fVersion >= 4.1)
+    {
+        $iDay = substr($sTimestamp, 8, 2);
+        $iMonth = substr($sTimestamp, 5, 2);
+        $iYear = substr($sTimestamp, 0, 4);
+        $iHours = substr($sTimestamp, 11, 2);
+        $iMinutes = substr($sTimestamp, 14, 2);
+        $iSeconds = substr($sTimestamp, 17, 2);
+    } else
+    /* The old ones are in the form yyyymmddhhmmss */
+    {
+        $iDay = substr($sTimestamp,6,2);
+        $iMonth = substr($sTimestamp,4,2);
+        $iYear = substr($sTimestamp,0,4);
+        $iHours = substr($sTimestamp,8,2);
+        $iMinutes = substr($sTimestamp,10,2);
+        $iSeconds = substr($sTimestamp,12,2);
+    }
+    return mktime($iHours, $iMinutes, $iSeconds, $iMonth, $iDay, $iYear);
 }
 
 function mysqldatetime_to_unixtimestamp($sDatetime)



More information about the wine-cvs mailing list