changeset 124:eac2cf04261a

Change how date timestamps are stored and handled. This breaks cache file backward/forward compatibility.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 31 Jul 2017 14:48:09 +0300
parents 956cafa61b91
children 379a8cd3bb2c
files mgallery.inc.php mgallery.php mgtool.php
diffstat 3 files changed, 21 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/mgallery.inc.php	Wed May 10 20:12:40 2017 +0300
+++ b/mgallery.inc.php	Mon Jul 31 14:48:09 2017 +0300
@@ -27,6 +27,7 @@
 define("MG_DVA", 3);
 define("MG_BOOL", 4);
 define("MG_FLAGS", 5);
+define("MG_DATE", 6);
 
 
 define("yes", 1);
--- a/mgallery.php	Wed May 10 20:12:40 2017 +0300
+++ b/mgallery.php	Mon Jul 31 14:48:09 2017 +0300
@@ -376,10 +376,10 @@
 }
 
 
-function mgTimeStr($str)
+function mgTimeStr($stamp)
 {
-  $tmp = date_create_from_format("Y:m:d H:i:s", $str);
-  return date_format($tmp, "d M Y (H:i:s)");
+//  return date_format($stamp, "d M Y (H:i:s)");
+  return date("d M Y (H:i:s)", $stamp);
 }
 
 
--- a/mgtool.php	Wed May 10 20:12:40 2017 +0300
+++ b/mgtool.php	Mon Jul 31 14:48:09 2017 +0300
@@ -14,19 +14,19 @@
 //
 $galExifConversions =
 [
-  [ MG_STR, "caption"     , "ImageDescription" ],
-  [ MG_STR, "copyright"   , "Copyright" ],
-  [ MG_STR, "model"       , "Model" ],
-  [ MG_INT, "width"       , ["COMPUTED", "Width"] ],
-  [ MG_INT, "height"      , ["COMPUTED", "Height"] ],
-  [ MG_DVA, "fnumber"     , "FNumber" ],
-  [ MG_DVA, "exposure"    , "ExposureTime" ],
-  [ MG_INT, "iso"         , "ISOSpeedRatings" ],
-  [ MG_STR, "lensmodel"   , "UndefinedTag:0xA434" ],
-  [ MG_DVA, "focallength" , "FocalLength" ],
-  [ MG_STR, "datetime"    , "DateTimeOriginal" ],
-  [ MG_STR, "datetime"    , "DateTimeDigitized" ],
-  [ MG_INT, "filesize"    , "FileSize" ],
+  [ MG_STR,   "caption"     , "ImageDescription" ],
+  [ MG_STR,   "copyright"   , "Copyright" ],
+  [ MG_STR,   "model"       , "Model" ],
+  [ MG_INT,   "width"       , ["COMPUTED", "Width"] ],
+  [ MG_INT,   "height"      , ["COMPUTED", "Height"] ],
+  [ MG_DVA,   "fnumber"     , "FNumber" ],
+  [ MG_DVA,   "exposure"    , "ExposureTime" ],
+  [ MG_INT,   "iso"         , "ISOSpeedRatings" ],
+  [ MG_STR,   "lensmodel"   , "UndefinedTag:0xA434" ],
+  [ MG_DVA,   "focallength" , "FocalLength" ],
+  [ MG_DATE,  "datetime"    , "DateTimeOriginal" ],
+  [ MG_DATE,  "datetime"    , "DateTimeDigitized" ],
+  [ MG_INT,   "filesize"    , "FileSize" ],
 ];
 
 define("GCMD_UPDATE"      , 1);
@@ -146,6 +146,9 @@
       else
         return $val;
 
+    case MG_DATE:
+      return date_timestamp_get(date_create_from_format("Y:m:d H:i:s", $val));
+
     default:
       return $val;
   }
@@ -356,7 +359,7 @@
 function mgSortFunc($a, $b)
 {
   if (isset($a["datetime"]) && isset($b["datetime"]))
-    return strcmp($b["datetime"], $a["datetime"]);
+    return $b["datetime"] - $a["datetime"];
   else
   if (isset($a["base"]) && isset($b["base"]))
     return strcmp($b["base"], $a["base"]);