, ":"
, case properFraction second :: (Int, Pico) of
(int, 0 ) -> show2 int
- (int, frac) -> show2 int ++ tail (show frac)
+ (int, frac) -> show2 int ++ tail (showFixed True frac)
, showTZ tz
]
Nothing -> convError ("No " ++ name ++ " information in the given value") a
Just b -> return b
+instance Convertible W3CDateTime W3CDateTime where
+ safeConvert = return
+
instance Convertible Day W3CDateTime where
safeConvert day
= case toGregorian day of
--- /dev/null
+module ConversionTest
+ ( testData
+ )
+ where
+
+import Data.Convertible
+import Data.Time
+import Data.Time.W3C
+import Test.HUnit
+
+
+instance Eq ZonedTime where
+ a == b
+ = zonedTimeToUTC a == zonedTimeToUTC b
+
+
+testData :: [Test]
+testData = [ convert (W3CDateTime 2010 (Just 1) (Just 2) Nothing Nothing Nothing Nothing)
+ ~?=
+ fromGregorian 2010 1 2
+
+ , convert (W3CDateTime 2010 (Just 1) (Just 2) (Just 3) (Just 4) (Just 5.666666) (Just utc))
+ ~?=
+ ZonedTime {
+ zonedTimeToLocalTime = let day = fromGregorian 2010 1 2
+ tod = TimeOfDay 3 4 5.666666
+ in
+ LocalTime day tod
+ , zonedTimeZone = utc
+ }
+
+ , convert (fromGregorian 2010 1 2)
+ ~?=
+ W3CDateTime 2010 (Just 1) (Just 2) Nothing Nothing Nothing Nothing
+
+ , convert ZonedTime {
+ zonedTimeToLocalTime = let day = fromGregorian 2010 1 2
+ tod = TimeOfDay 3 4 5.666666
+ in
+ LocalTime day tod
+ , zonedTimeZone = utc
+ }
+ ~?=
+ W3CDateTime 2010 (Just 1) (Just 2) (Just 3) (Just 4) (Just 5.666666) (Just utc)
+ ]
--- /dev/null
+module FormatterTest
+ ( testData
+ )
+ where
+
+import Data.Time
+import Data.Time.W3C
+import Test.HUnit
+
+
+testData :: [Test]
+testData = [ format (W3CDateTime 2010 Nothing Nothing Nothing Nothing Nothing Nothing)
+ ~?=
+ "2010"
+
+ , format (W3CDateTime 2010 (Just 12) Nothing Nothing Nothing Nothing Nothing)
+ ~?=
+ "2010-12"
+
+ , format (W3CDateTime 2010 (Just 12) (Just 31) Nothing Nothing Nothing Nothing)
+ ~?=
+ "2010-12-31"
+
+ , format (W3CDateTime 2010 (Just 12) (Just 31) (Just 1) (Just 23) Nothing (Just utc))
+ ~?=
+ "2010-12-31T01:23Z"
+
+ , format (W3CDateTime 2010 (Just 12) (Just 31) (Just 1) (Just 23) (Just 45) (Just (hoursToTimeZone 9)))
+ ~?=
+ "2010-12-31T01:23:45+09:00"
+
+ , format (W3CDateTime 2010 (Just 12) (Just 31) (Just 1) (Just 23) (Just 45.666666) (Just (hoursToTimeZone 9)))
+ ~?=
+ "2010-12-31T01:23:45.666666+09:00"
+ ]
import Test.HUnit
+import qualified ConversionTest
+import qualified FormatterTest
import qualified ParsecParserTest
main :: IO ()
-main = runTestTT (test testData) >> return ()
+main = do runTestTT (test testData) >> return ()
testData :: [Test]
-testData = ParsecParserTest.testData
\ No newline at end of file
+testData = [ "conversion" ~: ConversionTest.testData
+ , "parser" ~: ParsecParserTest.testData
+ , "formatter" ~: FormatterTest.testData
+ ]
., tests
Other-Modules:
+ ConversionTest
+ FormatterTest
ParsecParserTest
Extensions: