[commit: packages/time] master, wip/travis: instance Show UTCTime (c03ad77)

git at git.haskell.org git at git.haskell.org
Sat May 7 06:42:24 UTC 2016


Repository : ssh://git@git.haskell.org/time

On branches: master,wip/travis
Link       : http://git.haskell.org/packages/time.git/commitdiff/c03ad77480823c2e9c4cc919192a65052448ee57

>---------------------------------------------------------------

commit c03ad77480823c2e9c4cc919192a65052448ee57
Author: Ashley Yakeley <ashley at semantic.org>
Date:   Tue Nov 1 23:48:56 2005 -0800

    instance Show UTCTime
    
    darcs-hash:20051102074856-ac6dd-034566ea08d12d2e6bbd34390e1a7cfd7a69cac4


>---------------------------------------------------------------

c03ad77480823c2e9c4cc919192a65052448ee57
 Data/Time/LocalTime/LocalTime.hs | 3 +++
 test/TestParseDAT.hs             | 7 ++-----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/Data/Time/LocalTime/LocalTime.hs b/Data/Time/LocalTime/LocalTime.hs
index 9d718ee..1ac0f1f 100644
--- a/Data/Time/LocalTime/LocalTime.hs
+++ b/Data/Time/LocalTime/LocalTime.hs
@@ -65,6 +65,9 @@ ztUTC (ZonedTime t zone) = localTimeToUTC zone t
 instance Show ZonedTime where
 	show (ZonedTime t zone) = show t ++ " " ++ show zone
 
+instance Show UTCTime where
+	show t = show (zonedTimeFromUTC utc t)
+
 getZonedTime :: IO ZonedTime
 getZonedTime = do
 	t <- getCurrentTime
diff --git a/test/TestParseDAT.hs b/test/TestParseDAT.hs
index 48104ca..2f53fab 100644
--- a/test/TestParseDAT.hs
+++ b/test/TestParseDAT.hs
@@ -46,9 +46,6 @@ times =
 	fmap (LocalTime (fromGregorian 1999 01 01)) tods ++
 	fmap (LocalTime (fromGregorian 1999 01 02)) tods
 
-showUTC :: UTCTime -> String
-showUTC t = show (zonedTimeFromUTC utc t)
-
 main :: IO ()
 main = do
 	h <- openFile "tai-utc.dat" ReadMode
@@ -60,6 +57,6 @@ main = do
 		let taiTime = utcToTAITime lst utcTime
 		let utcTime' = taiToUTCTime lst taiTime
 		if utcTime == utcTime'
-		 then putStrLn ((showUTC utcTime) ++ " == " ++ (show taiTime))
-		 else putStrLn ("correction: " ++ (showUTC utcTime) ++ " -> " ++ (show taiTime) ++ " -> " ++ (showUTC utcTime'))
+		 then putStrLn ((show utcTime) ++ " == " ++ (show taiTime))
+		 else putStrLn ("correction: " ++ (show utcTime) ++ " -> " ++ (show taiTime) ++ " -> " ++ (show utcTime'))
 		) times



More information about the ghc-commits mailing list