stevedlawrence commented on a change in pull request #70: Adding property 
binaryCalendarRep with values "binarySeconds" and "bi…
URL: https://github.com/apache/incubator-daffodil/pull/70#discussion_r190863436
 
 

 ##########
 File path: 
daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/PrimitivesDateTime1.scala
 ##########
 @@ -188,3 +169,37 @@ object TextCalendarConstants {
     }
   }
 }
+
+case class ConvertBinaryCalendarParser(
+  override val context: ElementRuntimeData,
+  hasTZ: Boolean,
+  binCalRep: BinaryCalendarRep,
+  epochCal: Calendar,
+  lengthInBits: Int)
+  extends PrimParser {
+
+  override lazy val runtimeDependencies = Nil
+
+  def parse(start: PState): Unit = {
+
+    val dis = start.dataInputStream
+    val slong: Long = dis.getSignedLong(lengthInBits, start)
+
+    if (binCalRep.eq(BinaryCalendarRep.BinarySeconds)) {
+      epochCal.add(Calendar.SECOND, slong.intValue())
+    } else if (binCalRep.eq(BinaryCalendarRep.BinaryMilliseconds)) {
+      val newTime = epochCal.getTimeInMillis + slong
+      try {
+        epochCal.setTimeInMillis(newTime)
+      } catch {
+        case e: IllegalArgumentException => {
+          PE(start, "Adding %s to the binaryCalendarEpoch: %s.", slong, 
e.getMessage())
 
 Review comment:
   Using the word "adding" feels like something a developer would like to see 
rather than a user. Maybe something instead like "%s milliseconds from the 
binaryCalendarEpoch is out of range of valid values".

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to