[commit: packages/time] master: instance Show UniversalTime (7b06a35)
git at git.haskell.org
git at git.haskell.org
Sun Dec 20 07:56:12 UTC 2015
Repository : ssh://git@git.haskell.org/time
On branch : master
Link : http://git.haskell.org/packages/time.git/commitdiff/7b06a35f56e85fc2c1d2929fa2e174432d319211
>---------------------------------------------------------------
commit 7b06a35f56e85fc2c1d2929fa2e174432d319211
Author: Ashley Yakeley <ashley at yakeley.org>
Date: Sat Feb 21 02:34:10 2015 -0800
instance Show UniversalTime
>---------------------------------------------------------------
7b06a35f56e85fc2c1d2929fa2e174432d319211
lib/Data/Time/Clock/Scale.hs | 3 +++
lib/Data/Time/LocalTime/LocalTime.hs | 4 ++++
2 files changed, 7 insertions(+)
diff --git a/lib/Data/Time/Clock/Scale.hs b/lib/Data/Time/Clock/Scale.hs
index 5838b4d..c511829 100644
--- a/lib/Data/Time/Clock/Scale.hs
+++ b/lib/Data/Time/Clock/Scale.hs
@@ -23,6 +23,9 @@ import Data.Data
-- | The Modified Julian Date is the day with the fraction of the day, measured from UT midnight.
-- It's used to represent UT1, which is time as measured by the earth's rotation, adjusted for various wobbles.
+--
+-- For the 'Show' instance of 'UniversalTime',
+-- import "Data.Time" or "Data.Time.LocalTime".
newtype UniversalTime = ModJulianDate {getModJulianDate :: Rational} deriving (Eq,Ord
#if LANGUAGE_DeriveDataTypeable
#if LANGUAGE_Rank2Types
diff --git a/lib/Data/Time/LocalTime/LocalTime.hs b/lib/Data/Time/LocalTime/LocalTime.hs
index d653fb5..360a2c6 100644
--- a/lib/Data/Time/LocalTime/LocalTime.hs
+++ b/lib/Data/Time/LocalTime/LocalTime.hs
@@ -70,6 +70,10 @@ ut1ToLocalTime long (ModJulianDate date) = LocalTime (ModifiedJulianDay localMJD
localTimeToUT1 :: Rational -> LocalTime -> UniversalTime
localTimeToUT1 long (LocalTime (ModifiedJulianDay localMJD) tod) = ModJulianDate ((fromIntegral localMJD) + (timeOfDayToDayFraction tod) - (long / 360))
+-- orphan instance
+instance Show UniversalTime where
+ show t = show (ut1ToLocalTime 0 t)
+
-- | A local time together with a TimeZone.
--
-- For the 'Read' instance of 'ZonedTime',
More information about the ghc-commits
mailing list