Skip to content

Commit

Permalink
Correctly handle BCE leap years in call to GregorianCalendar isLeapYe…
Browse files Browse the repository at this point in the history
…ar(), according to XSD 1.0 Second Edition spec
  • Loading branch information
ryanfb committed Oct 8, 2015
1 parent 3309ae6 commit 8f2b022
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ private static Date createDate(GregorianCalendar cal, int tzOffset, boolean nega
month -= 1;
cal.set(year, month, day, hours, minutes, seconds);
cal.set(Calendar.MILLISECOND, milliseconds);
if (negative) {
year = -(year - 1);
}
checkDate(cal.isLeapYear(year), month, day); // for GCJ
return cal.getTime();
}
Expand Down
6 changes: 6 additions & 0 deletions mod/xsd-datatype/test/xsdtest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@
<datatype name="date">
<valid>1886-12-01</valid>
<valid>1886-12-01Z</valid>
<valid>0004-02-29</valid>
<valid>-0001-02-29</valid>
<valid>-0257-02-29</valid>
<invalid>0003-02-29</invalid>
<invalid>-0257-02-30</invalid>
<invalid>-0258-02-29</invalid>
<lessThan>
<value>1066-12-31</value>
<value>1900-01-01</value>
Expand Down

0 comments on commit 8f2b022

Please sign in to comment.