0001e5fcbd5331c5e8949c182523cfc8d46ea937
[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 Data.Typeable
16 import Data.Data
17 import Control.DeepSeq
18 import Data.Time.Calendar.Days
19 import Data.Time.Clock.Internal.DiffTime
20
21
22 -- | This is the simplest representation of UTC.
23 -- It consists of the day number, and a time offset from midnight.
24 -- Note that if a day has a leap second added to it, it will have 86401 seconds.
25 data UTCTime = UTCTime {
26 -- | the day
27 utctDay :: Day,
28 -- | the time from midnight, 0 <= t < 86401s (because of leap-seconds)
29 utctDayTime :: DiffTime
30 } deriving (Data, Typeable)
31
32 instance NFData UTCTime where
33 rnf (UTCTime d t) = rnf d `seq` rnf t `seq` ()
34
35 instance Eq UTCTime where
36 (UTCTime da ta) == (UTCTime db tb) = (da == db) && (ta == tb)
37
38 instance Ord UTCTime where
39 compare (UTCTime da ta) (UTCTime db tb) = case (compare da db) of
40 EQ -> compare ta tb
41 cmp -> cmp