ISO 8601: more tests (#40)
authorAshley Yakeley <ashley@semantic.org>
Thu, 25 Jan 2018 04:02:08 +0000 (20:02 -0800)
committerAshley Yakeley <ashley@semantic.org>
Thu, 25 Jan 2018 04:02:08 +0000 (20:02 -0800)
test/main/Test/Format/ISO8601.hs

index 2687b80..356b79d 100644 (file)
@@ -117,7 +117,13 @@ testShowFormats = nameTest "show format"
         testShowFormat "durationTimeFormat" durationTimeFormat "P7Y10MT2H1M18.77634S" $ CalendarDiffTime 94 $ 7278.77634,
         testShowFormat "durationTimeFormat" durationTimeFormat "P8YT2H1M18.77634S" $ CalendarDiffTime 96 $ 7278.77634,
         testShowFormat "alternativeDurationDaysFormat" (alternativeDurationDaysFormat ExtendedFormat) "P0001-00-00" $ CalendarDiffDays 12 0,
+        testShowFormat "alternativeDurationDaysFormat" (alternativeDurationDaysFormat ExtendedFormat) "P0002-03-29" $ CalendarDiffDays 27 29,
+        testShowFormat "alternativeDurationDaysFormat" (alternativeDurationDaysFormat ExtendedFormat) "P0561-08-29" $ CalendarDiffDays (561 * 12 + 8) 29,
         testShowFormat "alternativeDurationTimeFormat" (alternativeDurationTimeFormat ExtendedFormat) "P0000-00-01T00:00:00" $ CalendarDiffTime 0 86400,
+        testShowFormat "alternativeDurationTimeFormat" (alternativeDurationTimeFormat ExtendedFormat) "P0007-10-05T02:01:18.77634" $ CalendarDiffTime 94 $ 5 * nominalDay + 7278.77634,
+        testShowFormat "alternativeDurationTimeFormat" (alternativeDurationTimeFormat ExtendedFormat) "P4271-10-05T02:01:18.77634" $ CalendarDiffTime (12 * 4271 + 10) $ 5 * nominalDay + 7278.77634,
+        testShowFormat "centuryFormat" centuryFormat "02" 2,
+        testShowFormat "centuryFormat" centuryFormat "21" 21,
         testShowFormat "intervalFormat etc."
             (intervalFormat (localTimeFormat (calendarFormat ExtendedFormat) (timeOfDayFormat ExtendedFormat)) durationTimeFormat)
             "2015-06-13T21:13:56/P1Y2M7DT5H33M2.34S"
@@ -166,6 +172,14 @@ testShowFormats = nameTest "show format"
             (timeOffsetFormat BasicFormat)
             "-0135"
             (minutesToTimeZone (-95)),
+        testShowFormat "timeOffsetFormat"
+            (timeOffsetFormat BasicFormat)
+            "-1100"
+            (minutesToTimeZone $ negate $ 11 * 60),
+        testShowFormat "timeOffsetFormat"
+            (timeOffsetFormat BasicFormat)
+            "+1015"
+            (minutesToTimeZone $ 615),
         testShowFormat "zonedTimeFormat"
             iso8601Format
             "2024-07-06T08:45:56.553-06:30"
@@ -237,7 +251,35 @@ testShowFormats = nameTest "show format"
         testShowFormat "ordinalDateFormat"
             (expandedOrdinalDateFormat 5 ExtendedFormat)
             "+01846-235"
-            (fromGregorian 1846 8 23)
+            (fromGregorian 1846 8 23),
+        testShowFormat "hourMinuteFormat"
+            (hourMinuteFormat ExtendedFormat)
+            "13:17.25"
+            (TimeOfDay 13 17 15),
+        testShowFormat "hourMinuteFormat"
+            (hourMinuteFormat ExtendedFormat)
+            "01:12.4"
+            (TimeOfDay 1 12 24),
+        testShowFormat "hourMinuteFormat"
+            (hourMinuteFormat BasicFormat)
+            "1317.25"
+            (TimeOfDay 13 17 15),
+        testShowFormat "hourMinuteFormat"
+            (hourMinuteFormat BasicFormat)
+            "0112.4"
+            (TimeOfDay 1 12 24),
+        testShowFormat "hourFormat"
+            hourFormat
+            "22"
+            (TimeOfDay 22 0 0),
+        testShowFormat "hourFormat"
+            hourFormat
+            "06"
+            (TimeOfDay 6 0 0),
+        testShowFormat "hourFormat"
+            hourFormat
+            "18.9475"
+            (TimeOfDay 18 56 51)
     ]
 
 testISO8601 :: TestTree