From 69be5e3f08698f9d48d943f2ed48e70b79dde533 Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Thu, 3 Aug 2017 22:32:19 -0400 Subject: [PATCH] handle short months in PNG tIME chunk generation --- coders/png.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/coders/png.c b/coders/png.c index 0a5a60455..150e0f0aa 100644 --- a/coders/png.c +++ b/coders/png.c @@ -8193,8 +8193,10 @@ static void write_tIME_chunk(Image *image,png_struct *ping,png_info *info, { ptime.hour = 0; ptime.day ++; - /* To do: fix this for short months */ - if (ptime.day > 31) + /* To do: fix this for leap years */ + if (ptime.day > 31 || (ptime.month == 2 && ptime.day > 28) || + ((ptime.month == 4 || ptime.month == 6 || ptime.month == 9 || + ptime.month == 11) && ptime.day > 30)) { ptime.day = 1; ptime.month++; -- 2.50.1