]> granicus.if.org Git - imagemagick/commitdiff
handle end-of-day wraparound in tIME chunk calculation. To do: handle short months.
authorGlenn Randers-Pehrson <glennrp@gmail.com>
Fri, 4 Aug 2017 02:25:02 +0000 (22:25 -0400)
committerGlenn Randers-Pehrson <glennrp@gmail.com>
Fri, 4 Aug 2017 02:25:02 +0000 (22:25 -0400)
coders/png.c

index ece03b1914d578534e200c431a2e187180c83e86..0a5a6045596f94466fee47c33fdbd1e36a36a58a 100644 (file)
@@ -8189,6 +8189,22 @@ static void write_tIME_chunk(Image *image,png_struct *ping,png_info *info,
    if (ptime.minute > 60)
    {
       ptime.hour++;
+      if (ptime.hour > 24)
+      {
+         ptime.hour = 0;
+         ptime.day ++;
+         /* To do: fix this for short months */
+         if (ptime.day > 31)
+         {
+            ptime.day = 1;
+            ptime.month++;
+            if (ptime.month > 12)
+            {
+               ptime.month=1;
+               ptime.year++;
+            }
+         }
+      }
       ptime.minute=+60;
    }
    ptime.second=(png_byte) second;