devongovett / exif-reader

A small EXIF image metadata reader
MIT License
145 stars 22 forks source link

DateTime?? or MoidyDate sometimes illegal value when the parsing day is 31st #7

Closed tpishi closed 7 years ago

tpishi commented 7 years ago

Hi.

In the function parseDate, date.setUTCMonth() is called after new Date() (means current local time). But, if the current date is 31st and the parsing value is like "2016:09:17 09:36:23", then date.setUTCMonth('09'-1) cannot change the month to September but October since the day has been set to 31st in the constructor. So, the parsed day is "Mon Oct 17 2016 18:36:23"

I think if the value date is initialized not new date(), but something fix day time like new Date(2001,0,2,0,0,0,0); (Jan, 2nd 2001 00:00:00 in the local time), this illegal value will not be occurred.

You can easily reproduce if new Date() changes to new Date(2016,11,31,23,59,59,0); for example.