get working with stack 2
[packages/time.git] / lib / Data / Time / Clock / Internal / UTCTime.hs
1 module Data.Time.Clock.Internal.UTCTime
2 (
3 -- * UTC
4 -- | UTC is time as measured by a clock, corrected to keep pace with the earth by adding or removing
5 -- occasional seconds, known as \"leap seconds\".
6 -- These corrections are not predictable and are announced with six month's notice.
7 -- No table of these corrections is provided, as any program compiled with it would become
8 -- out of date in six months.
9 --
10 -- If you don't care about leap seconds, use 'UTCTime' and 'NominalDiffTime' for your clock calculations,
11 -- and you'll be fine.
12 UTCTime(..)
13 ) where
14
15 import Control.DeepSeq
16 import Data.Data
17 import Data.Time.Calendar.Days
18 import Data.Time.Clock.Internal.DiffTime
19
20 -- | This is the simplest representation of UTC.
21 -- It consists of the day number, and a time offset from midnight.
22 -- Note that if a day has a leap second added to it, it will have 86401 seconds.
23 data UTCTime = UTCTime
24 { utctDay :: Day -- ^ the day
25 , utctDayTime :: DiffTime -- ^ the time from midnight, 0 <= t < 86401s (because of leap-seconds)
26 } deriving (Data, Typeable)
27
28 instance NFData UTCTime where
29 rnf (UTCTime d t) = rnf d `seq` rnf t `seq` ()
30
31 instance Eq UTCTime where
32 (UTCTime da ta) == (UTCTime db tb) = (da == db) && (ta == tb)
33
34 instance Ord UTCTime where
35 compare (UTCTime da ta) (UTCTime db tb) =
36 case (compare da db) of
37 EQ -> compare ta tb
38 cmp -> cmp