stevedlawrence commented on code in PR #1685:
URL: https://github.com/apache/daffodil/pull/1685#discussion_r3435358561
##########
daffodil-core/src/main/scala/org/apache/daffodil/lib/calendar/DFDLCalendarConversion.scala:
##########
@@ -95,7 +98,16 @@ object DFDLCalendarConversion {
val d = string.substring(endYear + 4, endYear + 6)
try {
- calendar.set(Calendar.EXTENDED_YEAR, Integer.parseInt(y))
+ // Use YEAR + ERA rather than EXTENDED_YEAR to match XSD 1.0 numbering:
+ // a negative lexical year is BCE, stored as ERA=BC with positive YEAR.
+ val yInt = Integer.parseInt(y)
+ if (yInt < 0) {
Review Comment:
This isn't correct. The fromXMLString functions are used to read date/time
values from the infoset when unparsing. Even though parse will never create an
infoset with year 0000, someone could modify/create a year 0000, which would
hit this code path.
To verify, you could create a unparserTestCase that has a year 0000 in the
infoset.
Note that you're right that the TDML runner will not use this code path, but
that logic only happens after a parser. In unparser tests we do not hit the
XMLGregorian code path because that's only used for comparing infosets, which
we don't do on unparse.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]