minute,
month,
second,
- year,
+ year;
+
+ int
addhours=0,
addminutes=0;
addminutes=0;
ret=sscanf(timestamp,"%d-%d-%dT%d:%d:%d%d:%d",&year,&month,&day,&hour,
&minute, &second, &addhours, &addminutes);
+ LogMagickEvent(CoderEvent,GetMagickModule(),
+ " Date format specified for png:tIME=%60s" ,timestamp);
+ LogMagickEvent(CoderEvent,GetMagickModule(),
+ " ret=%d,y=%d, m=%d, d=%d, h=%d, m=%d, s=%d, ah=%d, as=%d",
+ ret,year,month,day,hour,minute,second,addhours,addminutes);
if (ret < 6)
{
+ LogMagickEvent(CoderEvent,GetMagickModule(),
+ " Invalid date, ret=%d",ret);
(void) ThrowMagickException(exception,GetMagickModule(),CoderError,
- "Invalid date format specified for png:tIME","`%s'",
- image->filename);
+ "Invalid date format specified for png:tIME","`%s' (ret=%d)",
+ image->filename,ret);
return;
}
ptime.year=(png_uint_16) year;
ptime.month=(png_byte) month;
ptime.day=(png_byte) day;
+ if (addhours < 0)
+ {
+ addhours+=24;
+ ptime.hour=(png_byte) hour+addhours;
+ ptime.day--;
+ if (ptime.day == 0)
+ {
+ /* wrong for short months */
+ ptime.month--;
+ ptime.day=31;
+ }
+ if (ptime.month == 0)
+ {
+ ptime.month++;
+ ptime.year--;
+ }
+ }
ptime.hour=(png_byte) hour+addhours;
ptime.minute=(png_byte) minute+addminutes;
ptime.second=(png_byte) second;
ptime.day ++;
ptime.hour -=24;
}
+ if (ptime.hour < 0)
+ {
+ ptime.day --;
+ ptime.hour +=24;
+ }
/* 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.year++;
ptime.month=1;
}
+
+ 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,
+ ptime.second, addhours, addminutes);
png_set_tIME(ping,info,&ptime);
}
#endif