gdesrosiers1805 commented on code in PR #1685:
URL: https://github.com/apache/daffodil/pull/1685#discussion_r3421413122


##########
daffodil-core/src/main/scala/org/apache/daffodil/lib/calendar/DFDLCalendar.scala:
##########
@@ -170,8 +197,11 @@ trait ToDateMixin { self: DFDLCalendar =>
   def toDate(): DFDLDate = DFDLDate(calendar.clone().asInstanceOf[Calendar], 
self.hasTimeZone)
 }
 
-case class DFDLDate(calendar: Calendar, override val hasTimeZone: Boolean)
-  extends DFDLCalendar
+case class DFDLDate(
+  calendar: Calendar,
+  override val hasTimeZone: Boolean,
+  prolepticBCE: Boolean = false

Review Comment:
   So the prolepticBCE flag is not recording the ERA. It looks at which pattern 
is used, which is why it checks that the pattern does not contain a G. No G 
means there is no explicit era designator, so for a BCE value the era was 
carried by the sign and the year was parsed astronomically (the uuuu form). If 
it is BCE but the pattern contains G, the era is named explicitly and ICU 
parses it correctly, so the flag stays false and nothing is adjusted. But if it 
is BCE and the pattern has no G, the date is represented astronomically which 
has a year zero and so is off by one from XSD 1.0 for BCE, and the flag is set 
true to mark that the read-out needs an adjustment to match XSD 1.0. Perhaps a 
better name for that flag would have been astronomicalYear? 
   
   The need for that flag stemmed from the fact that I changed EXTENDED_YEAR to 
YEAR + ERA (for the most part, other than where special logic was needed to 
help correct the astronomical representation of BCE dates), but still kept the 
uuuu pattern as the default/implicit pattern. So if we change the default 
pattern to yyyy, it eliminates the need for that. The only issue, as you 
already mentioned, is that we won't be able to represent BCE years without the 
G marker, which seems to be the correct thing to do. So I'll update any BCE 
tests that previously used the implicit uuuu pattern to explicitly use a yyyy 
pattern with a G marker and era-worded input (e.g. BC), since negative years 
won't parse under yyyy on their own. This should simplify things — it removes 
the flag, the read-side and unparse adjustments, and the EXTENDED_YEAR/uuuu 
references.



-- 
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]

Reply via email to