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_r190862837
 
 

 ##########
 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)) {
 
 Review comment:
   Instead of having this conditional, and using epochCal.add vs 
epochCal.setTimeInMillis, could you just always use epochCal.setTimeInMillis, 
andwhen binCalRep is binarySecond, multiply the value by 1000? That would also 
mean you only need to pass in epochCal.getTimeInMillis to this method instead 
of the full cal.

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