/usr/lib/hugs/packages/time/Data/Time/Clock/UTC.hs is in libhugs-time-bundled 98.200609.21-5.3ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | {-# OPTIONS -Wall -Werror #-}
-- #hide
module Data.Time.Clock.UTC
(
-- * UTC
-- | UTC is time as measured by a clock, corrected to keep pace with the earth by adding or removing
-- occasional seconds, known as \"leap seconds\".
-- These corrections are not predictable and are announced with six month's notice.
-- No table of these corrections is provided, as any program compiled with it would become
-- out of date in six months.
--
-- If you don't care about leap seconds, use UTCTime and NominalDiffTime for your clock calculations,
-- and you'll be fine.
UTCTime(..),NominalDiffTime
) where
import Data.Time.Calendar.Days
import Data.Time.Clock.Scale
import Data.Fixed
-- | This is the simplest representation of UTC.
-- It consists of the day number, and a time offset from midnight.
-- Note that if a day has a leap second added to it, it will have 86401 seconds.
data UTCTime = UTCTime {
-- | the day
utctDay :: Day,
-- | the time from midnight, 0 <= t < 86401s (because of leap-seconds)
utctDayTime :: DiffTime
}
instance Eq UTCTime where
(UTCTime da ta) == (UTCTime db tb) = (da == db) && (ta == tb)
instance Ord UTCTime where
compare (UTCTime da ta) (UTCTime db tb) = case (compare da db) of
EQ -> compare ta tb
cmp -> cmp
-- | This is a length of time, as measured by UTC.
-- Conversion functions will treat it as seconds.
-- It has an accuracy of 10^-12 s.
-- It ignores leap-seconds, so it's not necessarily a fixed amount of clock time.
-- For instance, 23:00 UTC + 2 hours of NominalDiffTime = 01:00 UTC (+ 1 day),
-- regardless of whether a leap-second intervened.
newtype NominalDiffTime = MkNominalDiffTime Pico deriving (Eq,Ord)
instance Enum NominalDiffTime where
succ (MkNominalDiffTime a) = MkNominalDiffTime (succ a)
pred (MkNominalDiffTime a) = MkNominalDiffTime (pred a)
toEnum = MkNominalDiffTime . toEnum
fromEnum (MkNominalDiffTime a) = fromEnum a
enumFrom (MkNominalDiffTime a) = fmap MkNominalDiffTime (enumFrom a)
enumFromThen (MkNominalDiffTime a) (MkNominalDiffTime b) = fmap MkNominalDiffTime (enumFromThen a b)
enumFromTo (MkNominalDiffTime a) (MkNominalDiffTime b) = fmap MkNominalDiffTime (enumFromTo a b)
enumFromThenTo (MkNominalDiffTime a) (MkNominalDiffTime b) (MkNominalDiffTime c) = fmap MkNominalDiffTime (enumFromThenTo a b c)
instance Show NominalDiffTime where
show (MkNominalDiffTime t) = (showFixed True t) ++ "s"
-- necessary because H98 doesn't have "cunning newtype" derivation
instance Num NominalDiffTime where
(MkNominalDiffTime a) + (MkNominalDiffTime b) = MkNominalDiffTime (a + b)
(MkNominalDiffTime a) - (MkNominalDiffTime b) = MkNominalDiffTime (a - b)
(MkNominalDiffTime a) * (MkNominalDiffTime b) = MkNominalDiffTime (a * b)
negate (MkNominalDiffTime a) = MkNominalDiffTime (negate a)
abs (MkNominalDiffTime a) = MkNominalDiffTime (abs a)
signum (MkNominalDiffTime a) = MkNominalDiffTime (signum a)
fromInteger i = MkNominalDiffTime (fromInteger i)
-- necessary because H98 doesn't have "cunning newtype" derivation
instance Real NominalDiffTime where
toRational (MkNominalDiffTime a) = toRational a
-- necessary because H98 doesn't have "cunning newtype" derivation
instance Fractional NominalDiffTime where
(MkNominalDiffTime a) / (MkNominalDiffTime b) = MkNominalDiffTime (a / b)
recip (MkNominalDiffTime a) = MkNominalDiffTime (recip a)
fromRational r = MkNominalDiffTime (fromRational r)
-- necessary because H98 doesn't have "cunning newtype" derivation
instance RealFrac NominalDiffTime where
properFraction (MkNominalDiffTime a) = (i,MkNominalDiffTime f) where
(i,f) = properFraction a
truncate (MkNominalDiffTime a) = truncate a
round (MkNominalDiffTime a) = round a
ceiling (MkNominalDiffTime a) = ceiling a
floor (MkNominalDiffTime a) = floor a
|