time-1.8.0.2: A time library

Safe Haskell | Safe
Language | Haskell2010

Data.Time.LocalTime

Contents

- Time zones
- Time of day
- Local Time

Synopsis

- data TimeZone = TimeZone {
  - timeZoneMinutes :: Int
  - timeZoneSummerOnly :: Bool
  - timeZoneName :: String
  }
- timeZoneOffsetString :: TimeZone -> String
- timeZoneOffsetString' :: Maybe Char -> TimeZone -> String
- minutesToTimeZone :: Int -> TimeZone
- hoursToTimeZone :: Int -> TimeZone
- utc :: TimeZone
- getTimeZone :: UTCTime -> IO TimeZone
- getCurrentTimeZone :: IO TimeZone
- data TimeOfDay = TimeOfDay {
  - todHour :: Int
  - todMin :: Int
  - todSec :: Pico
  }
- midnight :: TimeOfDay
- midday :: TimeOfDay
- makeTimeOfDayValid :: Int -> Int -> Pico -> Maybe TimeOfDay
- utcToLocalTimeOfDay :: TimeZone -> TimeOfDay -> (Integer, TimeOfDay)
- localToUTCTimeOfDay :: TimeZone -> TimeOfDay -> (Integer, TimeOfDay)
- timeToTimeOfDay :: DiffTime -> TimeOfDay
- timeOfDayToTime :: TimeOfDay -> DiffTime
- dayFractionToTimeOfDay :: Rational -> TimeOfDay
- timeOfDayToDayFraction :: TimeOfDay -> Rational
- data LocalTime = LocalTime {
  - localDay :: Day
  - localTimeOfDay :: TimeOfDay
  }
- utcToLocalTime :: TimeZone -> UTCTime -> LocalTime
- localTimeToUTC :: TimeZone -> LocalTime -> UTCTime
- ut1ToLocalTime :: Rational -> UniversalTime -> LocalTime
- localTimeToUT1 :: Rational -> LocalTime -> UniversalTime
- data ZonedTime = ZonedTime {
  - zonedTimeToLocalTime :: LocalTime
  - zonedTimeZone :: TimeZone
  }
- utcToZonedTime :: TimeZone -> UTCTime -> ZonedTime
- zonedTimeToUTC :: ZonedTime -> UTCTime
- getZonedTime :: IO ZonedTime
- utcToLocalZonedTime :: UTCTime -> IO ZonedTime

# Time zones

data TimeZone #

A TimeZone is a whole number of minutes offset from UTC, together with a name and a "just for summer" flag.

Constructors

TimeZone |

Fields

- timeZoneMinutes :: Int

  The number of minutes offset from UTC. Positive means local time will be later in the day than UTC.

- timeZoneSummerOnly :: Bool

  Is this time zone just persisting for the summer?

- timeZoneName :: String

  The name of the zone, typically a three- or four-letter acronym.

Instances

Eq TimeZone # |
Methods (==) :: TimeZone -> TimeZone -> Bool # (/=) :: TimeZone -> TimeZone -> Bool #
Data TimeZone # |

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TimeZone -> c TimeZone Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TimeZone Source #

toConstr :: TimeZone -> Constr Source #

dataTypeOf :: TimeZone -> DataType Source #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c TimeZone) Source #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TimeZone) Source #

gmapT :: (forall b. Data b => b -> b) -> TimeZone -> TimeZone Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TimeZone -> r Source #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TimeZone -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> TimeZone -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TimeZone -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TimeZone -> m TimeZone Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TimeZone -> m TimeZone Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TimeZone -> m TimeZone Source #

Ord TimeZone # |
Methods compare :: TimeZone -> TimeZone -> Ordering # (<) :: TimeZone -> TimeZone -> Bool # (<=) :: TimeZone -> TimeZone -> Bool # (>) :: TimeZone -> TimeZone -> Bool # (>=) :: TimeZone -> TimeZone -> Bool # max :: TimeZone -> TimeZone -> TimeZone # min :: TimeZone -> TimeZone -> TimeZone #
Show TimeZone # |
Methods showsPrec :: Int -> TimeZone -> ShowS Source # show :: TimeZone -> String Source # showList :: [TimeZone] -> ShowS Source #
NFData TimeZone # |
Methods rnf :: TimeZone -> () Source #
ParseTime TimeZone # |
Methods buildTime :: TimeLocale -> [(Char, String)] -> Maybe TimeZone #
FormatTime TimeZone # |
Methods formatCharacter :: Char -> Maybe (TimeLocale -> Maybe NumericPadOption -> Maybe Int -> TimeZone -> String) #

timeZoneOffsetString :: TimeZone -> String #

Text representing the offset of this timezone, such as "-0800" or "+0400" (like `%z` in formatTime).

timeZoneOffsetString' :: Maybe Char -> TimeZone -> String #

Text representing the offset of this timezone, such as "-0800" or "+0400" (like `%z` in formatTime), with arbitrary padding.

minutesToTimeZone :: Int -> TimeZone #

Create a nameless non-summer timezone for this number of minutes.

hoursToTimeZone :: Int -> TimeZone #

Create a nameless non-summer timezone for this number of hours.

utc :: TimeZone #

The UTC time zone.

getTimeZone :: UTCTime -> IO TimeZone #

Get the local time-zone for a given time (varying as per summertime adjustments).

getCurrentTimeZone :: IO TimeZone #

Get the current time-zone.

# Time of day

data TimeOfDay #

Time of day as represented in hour, minute and second (with picoseconds), typically used to express local time of day.

Constructors

TimeOfDay |

Fields

- todHour :: Int

  range 0 - 23

- todMin :: Int

  range 0 - 59

- todSec :: Pico

  Note that 0 <= `todSec` < 61, accomodating leap seconds. Any local minute may have a leap second, since leap seconds happen in all zones simultaneously

Instances

Eq TimeOfDay # |
Methods (==) :: TimeOfDay -> TimeOfDay -> Bool # (/=) :: TimeOfDay -> TimeOfDay -> Bool #
Data TimeOfDay # |

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> TimeOfDay -> c TimeOfDay Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TimeOfDay Source #

toConstr :: TimeOfDay -> Constr Source #

dataTypeOf :: TimeOfDay -> DataType Source #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c TimeOfDay) Source #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TimeOfDay) Source #

gmapT :: (forall b. Data b => b -> b) -> TimeOfDay -> TimeOfDay Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TimeOfDay -> r Source #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TimeOfDay -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> TimeOfDay -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> TimeOfDay -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> TimeOfDay -> m TimeOfDay Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TimeOfDay -> m TimeOfDay Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TimeOfDay -> m TimeOfDay Source #

Ord TimeOfDay # |
Methods compare :: TimeOfDay -> TimeOfDay -> Ordering # (<) :: TimeOfDay -> TimeOfDay -> Bool # (<=) :: TimeOfDay -> TimeOfDay -> Bool # (>) :: TimeOfDay -> TimeOfDay -> Bool # (>=) :: TimeOfDay -> TimeOfDay -> Bool # max :: TimeOfDay -> TimeOfDay -> TimeOfDay # min :: TimeOfDay -> TimeOfDay -> TimeOfDay #
Show TimeOfDay # |
Methods showsPrec :: Int -> TimeOfDay -> ShowS Source # show :: TimeOfDay -> String Source # showList :: [TimeOfDay] -> ShowS Source #
NFData TimeOfDay # |
Methods rnf :: TimeOfDay -> () Source #
ParseTime TimeOfDay # |
Methods buildTime :: TimeLocale -> [(Char, String)] -> Maybe TimeOfDay #
FormatTime TimeOfDay # |
Methods formatCharacter :: Char -> Maybe (TimeLocale -> Maybe NumericPadOption -> Maybe Int -> TimeOfDay -> String) #

midnight :: TimeOfDay #

Hour zero

midday :: TimeOfDay #

Hour twelve

makeTimeOfDayValid :: Int -> Int -> Pico -> Maybe TimeOfDay #

utcToLocalTimeOfDay :: TimeZone -> TimeOfDay -> (Integer, TimeOfDay) #

Convert a time of day in UTC to a time of day in some timezone, together with a day adjustment.

localToUTCTimeOfDay :: TimeZone -> TimeOfDay -> (Integer, TimeOfDay) #

Convert a time of day in some timezone to a time of day in UTC, together with a day adjustment.

timeToTimeOfDay :: DiffTime -> TimeOfDay #

Get the time of day given a time since midnight. Time more than 24h will be converted to leap-seconds.

timeOfDayToTime :: TimeOfDay -> DiffTime #

Get the time since midnight for a given time of day.

dayFractionToTimeOfDay :: Rational -> TimeOfDay #

Get the time of day given the fraction of a day since midnight.

timeOfDayToDayFraction :: TimeOfDay -> Rational #

Get the fraction of a day since midnight given a time of day.

# Local Time

data LocalTime #

A simple day and time aggregate, where the day is of the specified parameter, and the time is a TimeOfDay. Conversion of this (as local civil time) to UTC depends on the time zone. Conversion of this (as local mean time) to UT1 depends on the longitude.

Constructors

LocalTime |

Fields

- localDay :: Day
- localTimeOfDay :: TimeOfDay

Instances

Eq LocalTime # |
Methods (==) :: LocalTime -> LocalTime -> Bool # (/=) :: LocalTime -> LocalTime -> Bool #
Data LocalTime # |

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> LocalTime -> c LocalTime Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c LocalTime Source #

toConstr :: LocalTime -> Constr Source #

dataTypeOf :: LocalTime -> DataType Source #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c LocalTime) Source #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c LocalTime) Source #

gmapT :: (forall b. Data b => b -> b) -> LocalTime -> LocalTime Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> LocalTime -> r Source #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> LocalTime -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> LocalTime -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> LocalTime -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> LocalTime -> m LocalTime Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> LocalTime -> m LocalTime Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> LocalTime -> m LocalTime Source #

Ord LocalTime # |
Methods compare :: LocalTime -> LocalTime -> Ordering # (<) :: LocalTime -> LocalTime -> Bool # (<=) :: LocalTime -> LocalTime -> Bool # (>) :: LocalTime -> LocalTime -> Bool # (>=) :: LocalTime -> LocalTime -> Bool # max :: LocalTime -> LocalTime -> LocalTime # min :: LocalTime -> LocalTime -> LocalTime #
Show LocalTime # |
Methods showsPrec :: Int -> LocalTime -> ShowS Source # show :: LocalTime -> String Source # showList :: [LocalTime] -> ShowS Source #
NFData LocalTime # |
Methods rnf :: LocalTime -> () Source #
ParseTime LocalTime # |
Methods buildTime :: TimeLocale -> [(Char, String)] -> Maybe LocalTime #
FormatTime LocalTime # |
Methods formatCharacter :: Char -> Maybe (TimeLocale -> Maybe NumericPadOption -> Maybe Int -> LocalTime -> String) #

utcToLocalTime :: TimeZone -> UTCTime -> LocalTime #

Get the local time of a UTC time in a time zone.

localTimeToUTC :: TimeZone -> LocalTime -> UTCTime #

Get the UTC time of a local time in a time zone.

ut1ToLocalTime :: Rational -> UniversalTime -> LocalTime #

Get the local time of a UT1 time on a particular meridian (in degrees, positive is East).

localTimeToUT1 :: Rational -> LocalTime -> UniversalTime #

Get the UT1 time of a local time on a particular meridian (in degrees, positive is East).

data ZonedTime #

A local time together with a time zone.

Constructors

ZonedTime |

Fields

- zonedTimeToLocalTime :: LocalTime
- zonedTimeZone :: TimeZone

Instances

Data ZonedTime # |

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ZonedTime -> c ZonedTime Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ZonedTime Source #

toConstr :: ZonedTime -> Constr Source #

dataTypeOf :: ZonedTime -> DataType Source #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c ZonedTime) Source #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ZonedTime) Source #

gmapT :: (forall b. Data b => b -> b) -> ZonedTime -> ZonedTime Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ZonedTime -> r Source #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ZonedTime -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> ZonedTime -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ZonedTime -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ZonedTime -> m ZonedTime Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ZonedTime -> m ZonedTime Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ZonedTime -> m ZonedTime Source #

Show ZonedTime # |
Methods showsPrec :: Int -> ZonedTime -> ShowS Source # show :: ZonedTime -> String Source # showList :: [ZonedTime] -> ShowS Source #
NFData ZonedTime # |
Methods rnf :: ZonedTime -> () Source #
ParseTime ZonedTime # |
Methods buildTime :: TimeLocale -> [(Char, String)] -> Maybe ZonedTime #
FormatTime ZonedTime # |
Methods formatCharacter :: Char -> Maybe (TimeLocale -> Maybe NumericPadOption -> Maybe Int -> ZonedTime -> String) #

utcToZonedTime :: TimeZone -> UTCTime -> ZonedTime #

zonedTimeToUTC :: ZonedTime -> UTCTime #

getZonedTime :: IO ZonedTime #

utcToLocalZonedTime :: UTCTime -> IO ZonedTime #