diff mgtool.php @ 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 c803235bd0f9
children f825d644cf7a
line wrap: on
line diff
--- 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"]);