Data.Time.Clock

time-1.9.3: A time library

Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.Time.Clock

Contents

- Universal Time
- Absolute intervals
- UTC

Description

Types and functions for UTC and UT1

Synopsis

- newtype UniversalTime = ModJulianDate {
  - getModJulianDate :: Rational
  }
- data DiffTime
- secondsToDiffTime :: Integer -> DiffTime
- picosecondsToDiffTime :: Integer -> DiffTime
- diffTimeToPicoseconds :: DiffTime -> Integer
- data UTCTime = UTCTime {
  - utctDay :: Day
  - utctDayTime :: DiffTime
  }
- data NominalDiffTime
- secondsToNominalDiffTime :: Pico -> NominalDiffTime
- nominalDiffTimeToSeconds :: NominalDiffTime -> Pico
- nominalDay :: NominalDiffTime
- addUTCTime :: NominalDiffTime -> UTCTime -> UTCTime
- diffUTCTime :: UTCTime -> UTCTime -> NominalDiffTime
- getCurrentTime :: IO UTCTime
- getTime_resolution :: DiffTime

# Universal Time

Time as measured by the Earth.

newtype UniversalTime Source #

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.

Constructors

ModJulianDate |
Fields getModJulianDate :: Rational

#### Instances

Instances details

Data UniversalTime Source # |
Instance details Defined in Data.Time.Clock.Internal.UniversalTime Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> UniversalTime -> c UniversalTime Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c UniversalTime Source # toConstr :: UniversalTime -> Constr Source # dataTypeOf :: UniversalTime -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c UniversalTime) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UniversalTime) Source # gmapT :: (forall b. Data b => b -> b) -> UniversalTime -> UniversalTime Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> UniversalTime -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> UniversalTime -> r Source # gmapQ :: (forall d. Data d => d -> u) -> UniversalTime -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> UniversalTime -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> UniversalTime -> m UniversalTime Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> UniversalTime -> m UniversalTime Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> UniversalTime -> m UniversalTime Source #
Read UniversalTime Source # |
Instance details Defined in Data.Time.Format.Parse Methods readsPrec :: Int -> ReadS UniversalTime Source # readList :: ReadS [UniversalTime] Source # readPrec :: ReadPrec UniversalTime Source # readListPrec :: ReadPrec [UniversalTime] Source #
Show UniversalTime Source # |
Instance details Defined in Data.Time.LocalTime.Internal.LocalTime Methods showsPrec :: Int -> UniversalTime -> ShowS Source # show :: UniversalTime -> String Source # showList :: [UniversalTime] -> ShowS Source #
NFData UniversalTime Source # |
Instance details Defined in Data.Time.Clock.Internal.UniversalTime Methods rnf :: UniversalTime -> () Source #
Eq UniversalTime Source # |
Instance details Defined in Data.Time.Clock.Internal.UniversalTime Methods (==) :: UniversalTime -> UniversalTime -> Bool # (/=) :: UniversalTime -> UniversalTime -> Bool #
Ord UniversalTime Source # |
Instance details Defined in Data.Time.Clock.Internal.UniversalTime Methods compare :: UniversalTime -> UniversalTime -> Ordering # (<) :: UniversalTime -> UniversalTime -> Bool # (<=) :: UniversalTime -> UniversalTime -> Bool # (>) :: UniversalTime -> UniversalTime -> Bool # (>=) :: UniversalTime -> UniversalTime -> Bool # max :: UniversalTime -> UniversalTime -> UniversalTime # min :: UniversalTime -> UniversalTime -> UniversalTime #
FormatTime UniversalTime Source # |
Instance details Defined in Data.Time.Format.Format.Instances Methods formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> UniversalTime -> String) Source #
ParseTime UniversalTime Source # |
Instance details Defined in Data.Time.Format.Parse.Instances Methods substituteTimeSpecifier :: proxy UniversalTime -> TimeLocale -> Char -> Maybe String Source # parseTimeSpecifier :: proxy UniversalTime -> TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP String Source # buildTime :: TimeLocale -> [(Char, String)] -> Maybe UniversalTime Source #

# Absolute intervals

data DiffTime Source #

This is a length of time, as measured by a clock. Conversion functions will treat it as seconds. It has a precision of 10^-12 s.

#### Instances

Instances details

Data DiffTime Source # |
Instance details Defined in Data.Time.Clock.Internal.DiffTime Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> DiffTime -> c DiffTime Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c DiffTime Source # toConstr :: DiffTime -> Constr Source # dataTypeOf :: DiffTime -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c DiffTime) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DiffTime) Source # gmapT :: (forall b. Data b => b -> b) -> DiffTime -> DiffTime Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DiffTime -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DiffTime -> r Source # gmapQ :: (forall d. Data d => d -> u) -> DiffTime -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> DiffTime -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> DiffTime -> m DiffTime Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DiffTime -> m DiffTime Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DiffTime -> m DiffTime Source #
Enum DiffTime Source # |
Instance details Defined in Data.Time.Clock.Internal.DiffTime Methods succ :: DiffTime -> DiffTime Source # pred :: DiffTime -> DiffTime Source # toEnum :: Int -> DiffTime Source # fromEnum :: DiffTime -> Int Source # enumFrom :: DiffTime -> [DiffTime] Source # enumFromThen :: DiffTime -> DiffTime -> [DiffTime] Source # enumFromTo :: DiffTime -> DiffTime -> [DiffTime] Source # enumFromThenTo :: DiffTime -> DiffTime -> DiffTime -> [DiffTime] Source #
Num DiffTime Source # |
Instance details Defined in Data.Time.Clock.Internal.DiffTime Methods (+) :: DiffTime -> DiffTime -> DiffTime Source # (-) :: DiffTime -> DiffTime -> DiffTime Source # (*) :: DiffTime -> DiffTime -> DiffTime Source # negate :: DiffTime -> DiffTime Source # abs :: DiffTime -> DiffTime Source # signum :: DiffTime -> DiffTime Source # fromInteger :: Integer -> DiffTime Source #
Fractional DiffTime Source # |
Instance details Defined in Data.Time.Clock.Internal.DiffTime Methods (/) :: DiffTime -> DiffTime -> DiffTime Source # recip :: DiffTime -> DiffTime Source # fromRational :: Rational -> DiffTime Source #
Real DiffTime Source # |
Instance details Defined in Data.Time.Clock.Internal.DiffTime Methods toRational :: DiffTime -> Rational Source #
RealFrac DiffTime Source # |
Instance details Defined in Data.Time.Clock.Internal.DiffTime Methods properFraction :: Integral b => DiffTime -> (b, DiffTime) Source # truncate :: Integral b => DiffTime -> b Source # round :: Integral b => DiffTime -> b Source # ceiling :: Integral b => DiffTime -> b Source # floor :: Integral b => DiffTime -> b Source #
Show DiffTime Source # |
Instance details Defined in Data.Time.Clock.Internal.DiffTime Methods showsPrec :: Int -> DiffTime -> ShowS Source # show :: DiffTime -> String Source # showList :: [DiffTime] -> ShowS Source #
NFData DiffTime Source # |
Instance details Defined in Data.Time.Clock.Internal.DiffTime Methods rnf :: DiffTime -> () Source #
Eq DiffTime Source # |
Instance details Defined in Data.Time.Clock.Internal.DiffTime Methods (==) :: DiffTime -> DiffTime -> Bool # (/=) :: DiffTime -> DiffTime -> Bool #
Ord DiffTime Source # |
Instance details Defined in Data.Time.Clock.Internal.DiffTime Methods compare :: DiffTime -> DiffTime -> Ordering # (<) :: DiffTime -> DiffTime -> Bool # (<=) :: DiffTime -> DiffTime -> Bool # (>) :: DiffTime -> DiffTime -> Bool # (>=) :: DiffTime -> DiffTime -> Bool # max :: DiffTime -> DiffTime -> DiffTime # min :: DiffTime -> DiffTime -> DiffTime #
FormatTime DiffTime Source # |
Instance details Defined in Data.Time.Format.Format.Instances Methods formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> DiffTime -> String) Source #
ParseTime DiffTime Source # |
Instance details Defined in Data.Time.Format.Parse.Instances Methods substituteTimeSpecifier :: proxy DiffTime -> TimeLocale -> Char -> Maybe String Source # parseTimeSpecifier :: proxy DiffTime -> TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP String Source # buildTime :: TimeLocale -> [(Char, String)] -> Maybe DiffTime Source #

secondsToDiffTime :: Integer -> DiffTime Source #

Create a `DiffTime` which represents an integral number of seconds.

picosecondsToDiffTime :: Integer -> DiffTime Source #

Create a `DiffTime` from a number of picoseconds.

diffTimeToPicoseconds :: DiffTime -> Integer Source #

Get the number of picoseconds in a `DiffTime`.

# 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.

data UTCTime Source #

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.

Constructors

UTCTime |
Fields utctDay :: Day the day utctDayTime :: DiffTime the time from midnight, 0 <= t < 86401s (because of leap-seconds)

#### Instances

Instances details

Data UTCTime Source # |
Instance details Defined in Data.Time.Clock.Internal.UTCTime Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> UTCTime -> c UTCTime Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c UTCTime Source # toConstr :: UTCTime -> Constr Source # dataTypeOf :: UTCTime -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c UTCTime) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c UTCTime) Source # gmapT :: (forall b. Data b => b -> b) -> UTCTime -> UTCTime Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> UTCTime -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> UTCTime -> r Source # gmapQ :: (forall d. Data d => d -> u) -> UTCTime -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> UTCTime -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> UTCTime -> m UTCTime Source #
Read UTCTime Source # |
Instance details Defined in Data.Time.Format.Parse Methods readsPrec :: Int -> ReadS UTCTime Source # readList :: ReadS [UTCTime] Source # readPrec :: ReadPrec UTCTime Source # readListPrec :: ReadPrec [UTCTime] Source #
Show UTCTime Source # |
Instance details Defined in Data.Time.LocalTime.Internal.ZonedTime Methods showsPrec :: Int -> UTCTime -> ShowS Source # show :: UTCTime -> String Source # showList :: [UTCTime] -> ShowS Source #
NFData UTCTime Source # |
Instance details Defined in Data.Time.Clock.Internal.UTCTime Methods rnf :: UTCTime -> () Source #
Eq UTCTime Source # |
Instance details Defined in Data.Time.Clock.Internal.UTCTime Methods (==) :: UTCTime -> UTCTime -> Bool # (/=) :: UTCTime -> UTCTime -> Bool #
Ord UTCTime Source # |
Instance details Defined in Data.Time.Clock.Internal.UTCTime Methods compare :: UTCTime -> UTCTime -> Ordering # (<) :: UTCTime -> UTCTime -> Bool # (<=) :: UTCTime -> UTCTime -> Bool # (>) :: UTCTime -> UTCTime -> Bool # (>=) :: UTCTime -> UTCTime -> Bool # max :: UTCTime -> UTCTime -> UTCTime # min :: UTCTime -> UTCTime -> UTCTime #
FormatTime UTCTime Source # |
Instance details Defined in Data.Time.Format.Format.Instances Methods formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> UTCTime -> String) Source #
ISO8601 UTCTime Source # | `yyyy-mm-ddThh:mm:ss[.sss]Z` (ISO 8601:2004(E) sec. 4.3.2 extended format)
Instance details Defined in Data.Time.Format.ISO8601 Methods iso8601Format :: Format UTCTime Source #
ParseTime UTCTime Source # |
Instance details Defined in Data.Time.Format.Parse.Instances Methods substituteTimeSpecifier :: proxy UTCTime -> TimeLocale -> Char -> Maybe String Source # parseTimeSpecifier :: proxy UTCTime -> TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP String Source # buildTime :: TimeLocale -> [(Char, String)] -> Maybe UTCTime Source #

data NominalDiffTime Source #

This is a length of time, as measured by UTC. It has a precision of 10^-12 s.

Conversion functions will treat it as seconds. For example, `(0.010 :: NominalDiffTime)` corresponds to 10 milliseconds.

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.

#### Instances

Instances details

Data NominalDiffTime Source # |
Instance details Defined in Data.Time.Clock.Internal.NominalDiffTime Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NominalDiffTime -> c NominalDiffTime Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c NominalDiffTime Source # toConstr :: NominalDiffTime -> Constr Source # dataTypeOf :: NominalDiffTime -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c NominalDiffTime) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NominalDiffTime) Source # gmapT :: (forall b. Data b => b -> b) -> NominalDiffTime -> NominalDiffTime Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NominalDiffTime -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NominalDiffTime -> r Source # gmapQ :: (forall d. Data d => d -> u) -> NominalDiffTime -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> NominalDiffTime -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> NominalDiffTime -> m NominalDiffTime Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NominalDiffTime -> m NominalDiffTime Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NominalDiffTime -> m NominalDiffTime Source #
Enum NominalDiffTime Source # |
Instance details Defined in Data.Time.Clock.Internal.NominalDiffTime Methods succ :: NominalDiffTime -> NominalDiffTime Source # pred :: NominalDiffTime -> NominalDiffTime Source # toEnum :: Int -> NominalDiffTime Source # fromEnum :: NominalDiffTime -> Int Source # enumFrom :: NominalDiffTime -> [NominalDiffTime] Source # enumFromThen :: NominalDiffTime -> NominalDiffTime -> [NominalDiffTime] Source # enumFromTo :: NominalDiffTime -> NominalDiffTime -> [NominalDiffTime] Source # enumFromThenTo :: NominalDiffTime -> NominalDiffTime -> NominalDiffTime -> [NominalDiffTime] Source #
Num NominalDiffTime Source # |
Instance details Defined in Data.Time.Clock.Internal.NominalDiffTime Methods (+) :: NominalDiffTime -> NominalDiffTime -> NominalDiffTime Source # (-) :: NominalDiffTime -> NominalDiffTime -> NominalDiffTime Source # (*) :: NominalDiffTime -> NominalDiffTime -> NominalDiffTime Source # negate :: NominalDiffTime -> NominalDiffTime Source # abs :: NominalDiffTime -> NominalDiffTime Source # signum :: NominalDiffTime -> NominalDiffTime Source # fromInteger :: Integer -> NominalDiffTime Source #
Fractional NominalDiffTime Source # |
Instance details Defined in Data.Time.Clock.Internal.NominalDiffTime Methods (/) :: NominalDiffTime -> NominalDiffTime -> NominalDiffTime Source # recip :: NominalDiffTime -> NominalDiffTime Source # fromRational :: Rational -> NominalDiffTime Source #
Real NominalDiffTime Source # |
Instance details Defined in Data.Time.Clock.Internal.NominalDiffTime Methods toRational :: NominalDiffTime -> Rational Source #
RealFrac NominalDiffTime Source # |
Instance details Defined in Data.Time.Clock.Internal.NominalDiffTime Methods properFraction :: Integral b => NominalDiffTime -> (b, NominalDiffTime) Source # truncate :: Integral b => NominalDiffTime -> b Source # round :: Integral b => NominalDiffTime -> b Source # ceiling :: Integral b => NominalDiffTime -> b Source # floor :: Integral b => NominalDiffTime -> b Source #
Show NominalDiffTime Source # |
Instance details Defined in Data.Time.Clock.Internal.NominalDiffTime Methods showsPrec :: Int -> NominalDiffTime -> ShowS Source # show :: NominalDiffTime -> String Source # showList :: [NominalDiffTime] -> ShowS Source #
NFData NominalDiffTime Source # |
Instance details Defined in Data.Time.Clock.Internal.NominalDiffTime Methods rnf :: NominalDiffTime -> () Source #
Eq NominalDiffTime Source # |
Instance details Defined in Data.Time.Clock.Internal.NominalDiffTime Methods (==) :: NominalDiffTime -> NominalDiffTime -> Bool # (/=) :: NominalDiffTime -> NominalDiffTime -> Bool #
Ord NominalDiffTime Source # |
Instance details Defined in Data.Time.Clock.Internal.NominalDiffTime Methods compare :: NominalDiffTime -> NominalDiffTime -> Ordering # (<) :: NominalDiffTime -> NominalDiffTime -> Bool # (<=) :: NominalDiffTime -> NominalDiffTime -> Bool # (>) :: NominalDiffTime -> NominalDiffTime -> Bool # (>=) :: NominalDiffTime -> NominalDiffTime -> Bool # max :: NominalDiffTime -> NominalDiffTime -> NominalDiffTime # min :: NominalDiffTime -> NominalDiffTime -> NominalDiffTime #
FormatTime NominalDiffTime Source # |
Instance details Defined in Data.Time.Format.Format.Instances Methods formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> NominalDiffTime -> String) Source #
ParseTime NominalDiffTime Source # |
Instance details Defined in Data.Time.Format.Parse.Instances Methods substituteTimeSpecifier :: proxy NominalDiffTime -> TimeLocale -> Char -> Maybe String Source # parseTimeSpecifier :: proxy NominalDiffTime -> TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP String Source # buildTime :: TimeLocale -> [(Char, String)] -> Maybe NominalDiffTime Source #

secondsToNominalDiffTime :: Pico -> NominalDiffTime Source #

Create a `NominalDiffTime` from a number of seconds.

Since: time-1.9.1

nominalDiffTimeToSeconds :: NominalDiffTime -> Pico Source #

Get the seconds in a `NominalDiffTime`.

Since: time-1.9.1

nominalDay :: NominalDiffTime Source #

One day in `NominalDiffTime`.

addUTCTime :: NominalDiffTime -> UTCTime -> UTCTime Source #

addUTCTime a b = a + b

diffUTCTime :: UTCTime -> UTCTime -> NominalDiffTime Source #

diffUTCTime a b = a - b

getCurrentTime :: IO UTCTime Source #

Get the current `UTCTime` from the system clock.

getTime_resolution :: DiffTime Source #

The resolution of `getSystemTime`, `getCurrentTime`, `getPOSIXTime`