From 6bc98630b7b6675ba3cbe74db8e9f2ed1f5e0a11 Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Thu, 3 Aug 2017 22:25:02 -0400 Subject: [PATCH] handle end-of-day wraparound in tIME chunk calculation. To do: handle short months. --- coders/png.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/coders/png.c b/coders/png.c index ece03b191..0a5a60455 100644 --- a/coders/png.c +++ b/coders/png.c @@ -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; -- 2.40.0