stevedlawrence commented on code in PR #1685:
URL: https://github.com/apache/daffodil/pull/1685#discussion_r3436337445
##########
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:
Yeah, I think IllegalArgumentException is the right thing, but we should do
it via the `invalidCalendar` function. It looks like that's that standard thing
our DFDLCalendarConversion code does when it determines a calendar string isn't
valid.
When unparsing, the IllegalArugmentException should be caught by the
NodeInfo Date/DateTime.fromXmlString stuff and eventually get converted to an
UnparseError. The XMLGregorianCalendar code path only happens on parse, so if
you create an `unparserTestCase` with a 0000 infoset it should create an
UnparserError that the TDML test can expect.
--
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]