mirror of
https://github.com/ccxvii/mujs.git
synced 2026-02-06 01:41:37 +08:00
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.
This commit is contained in:
2
jsdate.c
2
jsdate.c
@@ -217,7 +217,7 @@ static double MakeDay(double y, double m, double date)
|
|||||||
return NAN;
|
return NAN;
|
||||||
|
|
||||||
yd = floor(TimeFromYear(y) / msPerDay);
|
yd = floor(TimeFromYear(y) / msPerDay);
|
||||||
md = firstDayOfMonth[InLeapYear(y)][im];
|
md = firstDayOfMonth[DaysInYear(y) == 366][im];
|
||||||
|
|
||||||
return yd + md + date - 1;
|
return yd + md + date - 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user