Skip to content
Snippets Groups Projects
Commit 7b06a35f authored by Ashley Yakeley's avatar Ashley Yakeley
Browse files

instance Show UniversalTime

parent 1749892e
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,9 @@ import Data.Data ...@@ -23,6 +23,9 @@ import Data.Data
-- | The Modified Julian Date is the day with the fraction of the day, measured from UT midnight. -- | 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. -- 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 newtype UniversalTime = ModJulianDate {getModJulianDate :: Rational} deriving (Eq,Ord
#if LANGUAGE_DeriveDataTypeable #if LANGUAGE_DeriveDataTypeable
#if LANGUAGE_Rank2Types #if LANGUAGE_Rank2Types
......
...@@ -70,6 +70,10 @@ ut1ToLocalTime long (ModJulianDate date) = LocalTime (ModifiedJulianDay localMJD ...@@ -70,6 +70,10 @@ ut1ToLocalTime long (ModJulianDate date) = LocalTime (ModifiedJulianDay localMJD
localTimeToUT1 :: Rational -> LocalTime -> UniversalTime localTimeToUT1 :: Rational -> LocalTime -> UniversalTime
localTimeToUT1 long (LocalTime (ModifiedJulianDay localMJD) tod) = ModJulianDate ((fromIntegral localMJD) + (timeOfDayToDayFraction tod) - (long / 360)) 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. -- | A local time together with a TimeZone.
-- --
-- For the 'Read' instance of 'ZonedTime', -- For the 'Read' instance of 'ZonedTime',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment