git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GitHub] stevedlawrence commented on a change in pull request #70: Adding property binaryCalendarRep with values "binarySeconds" and "bi…


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_r190861129
 
 

 ##########
 File path: daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/PrimitivesDateTime.scala
 ##########
 @@ -191,3 +185,46 @@ case class ConvertTextDateTimePrim(e: ElementBase) extends ConvertTextCalendarPr
   protected override val implicitPattern = "uuuu-MM-dd'T'HH:mm:ss"
   protected override val validFormatCharacters = "adDeEFGhHkKmMsSuwWvVyXxYzZ".toSeq
 }
+
+abstract class ConvertBinaryCalendarPrimBase(e: ElementBase, guard: Boolean, lengthInBits: Long)
+  extends ConvertCalendarPrimBase(e, guard) {
+
+  lazy val epochCalendar: Calendar = {
+    val cal = Calendar.getInstance
+    val sdf = new SimpleDateFormat("uuuu-MM-dd'T'HH:mm:ss", ULocale.ENGLISH)
+
+    val tz = {
+        // If 'no time zone', then use UNKNOWN_ZONE
+        //
+        // UNKNOWN_ZONE behaves just like GMT/UTC and will
+        // preserve the Date/Time values.
+        //
+        if (calendarTz.isDefined) calendarTz.get else TimeZone.UNKNOWN_ZONE
+      }
+    sdf.setTimeZone(tz)
+    cal.setTimeZone(tz)
+    cal.setLenient(false)
+    cal.setTime(sdf.parse(e.binaryCalendarEpoch))
+    cal
+  }
+
+  override lazy val parser = new ConvertBinaryCalendarParser(
+    e.elementRuntimeData,
+    (calendarTz.isDefined),
 
 Review comment:
   Remove parens.

----------------------------------------------------------------
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:
users@xxxxxxxxxxxxxxxx


With regards,
Apache Git Services