time-1.4.2: A time library

Safe Haskell | Safe-Inferred
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' :: NumericPadOption -> 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 |
Data TimeZone |
Ord TimeZone |
Read TimeZone |
Show TimeZone |
NFData TimeZone |
ParseTime TimeZone |
FormatTime TimeZone |
Typeable * TimeZone |

timeZoneOffsetString :: TimeZone -> String

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

timeZoneOffsetString' :: NumericPadOption -> 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 |
Data TimeOfDay |
Ord TimeOfDay |
Read TimeOfDay |
Show TimeOfDay |
NFData TimeOfDay |
ParseTime TimeOfDay |
FormatTime TimeOfDay |
Typeable * TimeOfDay |

midnight :: TimeOfDay

Hour zero

midday :: TimeOfDay

Hour twelve

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

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

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

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

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

timeToTimeOfDay :: DiffTime -> TimeOfDay

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

timeOfDayToTime :: TimeOfDay -> DiffTime

Find out how much time since midnight a given TimeOfDay is.

dayFractionToTimeOfDay :: Rational -> TimeOfDay

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

timeOfDayToDayFraction :: TimeOfDay -> Rational

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

# 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 |
Data LocalTime |
Ord LocalTime |
Read LocalTime |
Show LocalTime |
NFData LocalTime |
ParseTime LocalTime |
FormatTime LocalTime |
Typeable * LocalTime |

utcToLocalTime :: TimeZone -> UTCTime -> LocalTime

show a UTC time in a given time zone as a LocalTime

localTimeToUTC :: TimeZone -> LocalTime -> UTCTime

find out what UTC time a given LocalTime in a given time zone is

ut1ToLocalTime :: Rational -> UniversalTime -> LocalTime

1st arg is observation meridian in degrees, positive is East

localTimeToUT1 :: Rational -> LocalTime -> UniversalTime

1st arg is observation meridian in degrees, positive is East

data ZonedTime

A local time together with a TimeZone.

Constructors

ZonedTime |
Fields zonedTimeToLocalTime :: LocalTime zonedTimeZone :: TimeZone

Instances

Data ZonedTime |
Read ZonedTime |
Show ZonedTime |
NFData ZonedTime |
ParseTime ZonedTime |
FormatTime ZonedTime |
Typeable * ZonedTime |

utcToZonedTime :: TimeZone -> UTCTime -> ZonedTime

zonedTimeToUTC :: ZonedTime -> UTCTime

getZonedTime :: IO ZonedTime

utcToLocalZonedTime :: UTCTime -> IO ZonedTime