]> granicus.if.org Git - imagemagick/commitdiff
https://github.com/ImageMagick/ImageMagick/pull/1496
authorCristy <mikayla-grace@urban-warrior.org>
Mon, 15 Apr 2019 15:46:52 +0000 (11:46 -0400)
committerCristy <mikayla-grace@urban-warrior.org>
Mon, 15 Apr 2019 15:46:52 +0000 (11:46 -0400)
ChangeLog
MagickCore/timer-private.h
MagickCore/timer.c
coders/cin.c
coders/mat.c
coders/pdf.c
coders/png.c

index 992cdb4edcbf675043f11b40aef4502bb3d04145..3243fff2d6e4c673b6b6029f092dd65b22367a87 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,8 @@
     https://imagemagick.org/discourse-server/viewforum.php?f=3).
   * Fixed a number of issues (reference
     https://github.com/ImageMagick/ImageMagick/issues).
+  * Honor SOURCE_DATE_EPOCH environment variable (reference
+    https://github.com/ImageMagick/ImageMagick/pull/1496/).
 
 2019-04-07  7.0.8-39 Cristy  <quetzlzacatenango@image...>
   * Release ImageMagick version 7.0.8-39, GIT revision 15489:6120f8bc1:20190406
index e8af5cd69245139fdc01a6cc9630bc54dcb531a8..b823cfeff30a6f0f7110874551450e4441060faf 100644 (file)
@@ -1,12 +1,12 @@
 /*
   Copyright 1999-2019 ImageMagick Studio LLC, a non-profit organization
   dedicated to making software imaging solutions freely available.
-  
+
   You may not use this file except in compliance with the License.  You may
   obtain a copy of the License at
-  
+
     https://imagemagick.org/script/license.php
-  
+
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 extern "C" {
 #endif
 
+static inline void GetUTCTime(const time_t *timep,struct tm *result)
+{
+#if defined(MAGICKCORE_HAVE_GMTIME_R)
+  (void) gmtime_r(timep,result);
+#else
+  {
+    struct tm
+      *my_time;
+
+    my_time=gmtime(timep);
+    if (my_time != (struct tm *) NULL)
+      (void) memcpy(result,my_time,sizeof(gm_time));
+  }
+#endif
+}
+
+static inline void GetLocalTime(const time_t *timep,struct tm *result)
+{
+#if defined(MAGICKCORE_HAVE_GMTIME_R)
+  (void) localtime_r(timep,result);
+#else
+  {
+    struct tm
+      *my_time;
+
+    my_time=localtime(timep);
+    if (my_time != (struct tm *) NULL)
+      (void) memcpy(result,my_time,sizeof(gm_time));
+  }
+#endif
+}
+
 extern MagickPrivate time_t
   GetMagickTime(void);
 
index 7d77d2683949b874288ab0df430b8a3115bd1a3c..57f69b04e0b1f111526947e4f1b053c966dfaba1 100644 (file)
@@ -259,36 +259,10 @@ MagickExport ssize_t FormatMagickTime(const time_t time,const size_t length,
     count;
 
   struct tm
-    gm_time,
-    local_time;
+    gm_time;
 
   assert(timestamp != (char *) NULL);
-  (void) memset(&local_time,0,sizeof(local_time));
-  (void) memset(&gm_time,0,sizeof(gm_time));
-#if defined(MAGICKCORE_HAVE_LOCALTIME_R)
-  (void) localtime_r(&time,&local_time);
-#else
-  {
-    struct tm
-      *my_time;
-
-    my_time=localtime(&time);
-    if (my_time != (struct tm *) NULL)
-      (void) memcpy(&local_time,my_time,sizeof(local_time));
-  }
-#endif
-#if defined(MAGICKCORE_HAVE_GMTIME_R)
-  (void) gmtime_r(&time,&gm_time);
-#else
-  {
-    struct tm
-      *my_time;
-
-    my_time=gmtime(&time);
-    if (my_time != (struct tm *) NULL)
-      (void) memcpy(&gm_time,my_time,sizeof(gm_time));
-  }
-#endif
+  GetUTCTime(&time,&gm_time);
   count=FormatLocaleString(timestamp,length,
     "%04d-%02d-%02dT%02d:%02d:%02d%+03d:00",gm_time.tm_year+1900,
     gm_time.tm_mon+1,gm_time.tm_mday,gm_time.tm_hour,gm_time.tm_min,
index d79f1c3bffe3001829c8c3dff66251854aa05be4..202f8973043479004c187baed1a9a49a705a6e8c 100644 (file)
@@ -992,13 +992,9 @@ static MagickBooleanType WriteCINImage(const ImageInfo *image_info,Image *image,
   offset+=WriteBlob(image,sizeof(cin.file.filename),(unsigned char *)
     cin.file.filename);
   seconds=GetMagickTime();
-#if defined(MAGICKCORE_HAVE_LOCALTIME_R)
-  (void) localtime_r(&seconds,&local_time);
-#else
-  (void) memcpy(&local_time,localtime(&seconds),sizeof(local_time));
-#endif
+  GetUTCTime(&seconds,&local_time);
   (void) memset(timestamp,0,sizeof(timestamp));
-  (void) strftime(timestamp,MagickPathExtent,"%Y:%m:%d:%H:%M:%S%Z",&local_time);
+  (void) strftime(timestamp,MaxTextExtent,"%Y:%m:%d:%H:%M:%SUTC",&local_time);
   (void) memset(cin.file.create_date,0,sizeof(cin.file.create_date));
   (void) CopyMagickString(cin.file.create_date,timestamp,11);
   offset+=WriteBlob(image,sizeof(cin.file.create_date),(unsigned char *)
index 3eb4571e2ed9bed28268719e1ba4fc1959497fd7..7c71fa643f8269ce7a3172a9c7c067bb1cc0addf 100644 (file)
@@ -1607,11 +1607,7 @@ static MagickBooleanType WriteMATImage(const ImageInfo *image_info,Image *image,
   image->depth=8;
 
   current_time=GetMagickTime();
-#if defined(MAGICKCORE_HAVE_LOCALTIME_R)
-  (void) localtime_r(&current_time,&local_time);
-#else
-  (void) memcpy(&local_time,localtime(&current_time),sizeof(local_time));
-#endif
+  GetUTCTime(&current_time,&local_time);
   (void) memset(MATLAB_HDR,' ',MagickMin(sizeof(MATLAB_HDR),124));
   FormatLocaleString(MATLAB_HDR,sizeof(MATLAB_HDR),
     "MATLAB 5.0 MAT-file, Platform: %s, Created on: %s %s %2d %2d:%2d:%2d %d",
index 26938afe2a371629e7ec4826d58c80b2fef09a25..5a5750f944f0f5a230a6950fd9dfaf59d5383a27 100644 (file)
@@ -3009,11 +3009,7 @@ RestoreMSCWarning
     }
   (void) WriteBlobString(image,buffer);
   seconds=GetMagickTime();
-#if defined(MAGICKCORE_HAVE_LOCALTIME_R)
-  (void) localtime_r(&seconds,&local_time);
-#else
-  (void) memcpy(&local_time,localtime(&seconds),sizeof(local_time));
-#endif
+  GetUTCTime(&seconds,&local_time);
   (void) FormatLocaleString(date,MagickPathExtent,"D:%04d%02d%02d%02d%02d%02d",
     local_time.tm_year+1900,local_time.tm_mon+1,local_time.tm_mday,
     local_time.tm_hour,local_time.tm_min,local_time.tm_sec);
index c3e5221849211f8c412a13d45ac3478ac7e38c22..84b95c234fc012a3cf6700a226c600e9597481d5 100644 (file)
@@ -87,6 +87,7 @@
 #include "MagickCore/statistic.h"
 #include "MagickCore/string_.h"
 #include "MagickCore/string-private.h"
+#include "MagickCore/timer-private.h"
 #include "MagickCore/transform.h"
 #include "MagickCore/utility.h"
 #if defined(MAGICKCORE_PNG_DELEGATE)
@@ -8366,7 +8367,7 @@ static void write_tIME_chunk(Image *image,png_struct *ping,png_info *info,
   ptime.hour = hour;
   ptime.minute = minute;
   ptime.second = second;
-
+  png_convert_from_time_t(&ptime,GetMagickTime());
   LogMagickEvent(CoderEvent,GetMagickModule(),
       "      png_set_tIME: y=%d, m=%d, d=%d, h=%d, m=%d, s=%d, ah=%d, am=%d",
       ptime.year, ptime.month, ptime.day, ptime.hour, ptime.minute,