shithub: libmujs

Download patch

ref: fe71080c59b400c8d9020c4eeb1065e8b1ae9508
parent: 8ee595bee72dac79d3ee4d3fe06358088ccd1e95
author: Tor Andersson <tor.andersson@artifex.com>
date: Fri Jan 10 06:16:14 EST 2020

Bug 698496: Handle leap years correctly in the Date constructor.

InLeapYear expects the parameter to be a timestamp and not a year.
Use DaysInYear instead.

Thanks to Robert Rosendahl for spotting this.

--- a/jsdate.c
+++ b/jsdate.c
@@ -217,7 +217,7 @@
 		return NAN;
 
 	yd = floor(TimeFromYear(y) / msPerDay);
-	md = firstDayOfMonth[InLeapYear(y)][im];
+	md = firstDayOfMonth[DaysInYear(y) == 366][im];
 
 	return yd + md + date - 1;
 }