From b5a8175656b99ced69244b3ce593c00fb61ab825 Mon Sep 17 00:00:00 2001
From: Joe Lapp <joe.lapp@pobox.com>
Date: Sat, 3 Sep 2005 14:57:36 +0200
Subject: [PATCH] Patch for JpegMeta.php

This patch allows a user to enter a datetime into the media editor
in what ever format they please, and yet still have it formatted
properly in the JPEG.  Strictly speaking, JpegMeta will store what
ever string you provide, but I'm guessing Google and other EXIF
readers may require the standard format.

darcs-hash:20050903125736-46f60-da93b57da8c2ce7ac5f5e1c24c195783b46730e5.gz
---
 inc/JpegMeta.php | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/inc/JpegMeta.php b/inc/JpegMeta.php
index 957d03671..af7d27f96 100644
--- a/inc/JpegMeta.php
+++ b/inc/JpegMeta.php
@@ -339,6 +339,7 @@ class JpegMeta
      * Set an EXIF field
      *
      * @author Sebastian Delmont <sdelmont@zonageek.com>
+     * @author Joe Lapp <joe.lapp@pobox.com>
      */
     function setExifField($field, $value)
     {
@@ -354,6 +355,13 @@ class JpegMeta
             $this->_info['exif'] = array();
         }
 
+        // make sure datetimes are in correct format
+        if(strlen($field) >= 8 && strtolower(substr($field, 0, 8)) == 'datetime') {
+            if(strlen($value) < 8 || $value{4} != ':' || $value{7} != ':') {
+                $value = date('Y:m:d H:i:s', strtotime($value));
+            }
+        }
+
         $this->_info['exif'][$field] = $value;
 
         return true;
-- 
GitLab