Haskell Hierarchical Libraries (base package)ContentsIndex
System.Time
Portabilityportable
Stabilityprovisional
Maintainerlibraries@haskell.org
Contents
Clock times
Time differences
Calendar times
Description
The standard Time library, providing standard functionality for clock times, including timezone information (i.e, the functionality of "time.h", adapted to the Haskell environment). It follows RFC 1129 in its use of Coordinated Universal Time (UTC).
Synopsis
data ClockTime = TOD Integer Integer
getClockTime :: IO ClockTime
data TimeDiff = TimeDiff {
tdYear :: Int
tdMonth :: Int
tdDay :: Int
tdHour :: Int
tdMin :: Int
tdSec :: Int
tdPicosec :: Integer
}
noTimeDiff :: TimeDiff
diffClockTimes :: ClockTime -> ClockTime -> TimeDiff
addToClockTime :: TimeDiff -> ClockTime -> ClockTime
normalizeTimeDiff :: TimeDiff -> TimeDiff
timeDiffToString :: TimeDiff -> String
formatTimeDiff :: TimeLocale -> String -> TimeDiff -> String
data CalendarTime = CalendarTime {
ctYear :: Int
ctMonth :: Month
ctDay :: Int
ctHour :: Int
ctMin :: Int
ctSec :: Int
ctPicosec :: Integer
ctWDay :: Day
ctYDay :: Int
ctTZName :: String
ctTZ :: Int
ctIsDST :: Bool
}
data Month
= January
| February
| March
| April
| May
| June
| July
| August
| September
| October
| November
| December
data Day
= Sunday
| Monday
| Tuesday
| Wednesday
| Thursday
| Friday
| Saturday
toCalendarTime :: ClockTime -> IO CalendarTime
toUTCTime :: ClockTime -> CalendarTime
toClockTime :: CalendarTime -> ClockTime
calendarTimeToString :: CalendarTime -> String
formatCalendarTime :: TimeLocale -> String -> CalendarTime -> String
Clock times
data ClockTime
A representation of the internal clock time. Clock times may be compared, converted to strings, or converted to an external calendar time CalendarTime for I/O or other manipulations.
Constructors
TOD Integer Integer

Construct a clock time. The arguments are a number of seconds since 00:00:00 (UTC) on 1 January 1970, and an additional number of picoseconds.

In Haskell 98, the ClockTime type is abstract.

show/hide Instances
getClockTime :: IO ClockTime
returns the current time in its internal representation.
Time differences
data TimeDiff
records the difference between two clock times in a user-readable way.
Constructors
TimeDiff
tdYear :: Int
tdMonth :: Int
tdDay :: Int
tdHour :: Int
tdMin :: Int
tdSec :: Int
tdPicosec :: Integer
show/hide Instances
noTimeDiff :: TimeDiff
null time difference.
diffClockTimes :: ClockTime -> ClockTime -> TimeDiff
diffClockTimes t1 t2 returns the difference between two clock times t1 and t2 as a TimeDiff.
addToClockTime :: TimeDiff -> ClockTime -> ClockTime
addToClockTime d t adds a time difference d and a clock time t to yield a new clock time. The difference d may be either positive or negative.
normalizeTimeDiff :: TimeDiff -> TimeDiff
converts a time difference to normal form.
timeDiffToString :: TimeDiff -> String
formats time differences using local conventions.
formatTimeDiff :: TimeLocale -> String -> TimeDiff -> String
formats time differences using local conventions and a formatting string. The formatting string is that understood by the ISO C strftime() function.
Calendar times
data CalendarTime
CalendarTime is a user-readable and manipulable representation of the internal ClockTime type.
Constructors
CalendarTime
ctYear :: IntYear (pre-Gregorian dates are inaccurate)
ctMonth :: MonthMonth of the year
ctDay :: IntDay of the month (1 to 31)
ctHour :: IntHour of the day (0 to 23)
ctMin :: IntMinutes (0 to 59)
ctSec :: IntSeconds (0 to 61, allowing for up to two leap seconds)
ctPicosec :: IntegerPicoseconds
ctWDay :: DayDay of the week
ctYDay :: IntDay of the year (0 to 364, or 365 in leap years)
ctTZName :: StringName of the time zone
ctTZ :: IntVariation from UTC in seconds
ctIsDST :: BoolTrue if Daylight Savings Time would be in effect, and False otherwise
show/hide Instances
data Month
A month of the year.
Constructors
January
February
March
April
May
June
July
August
September
October
November
December
show/hide Instances
data Day
A day of the week.
Constructors
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
show/hide Instances
toCalendarTime :: ClockTime -> IO CalendarTime
converts an internal clock time to a local time, modified by the timezone and daylight savings time settings in force at the time of conversion. Because of this dependence on the local environment, toCalendarTime is in the IO monad.
toUTCTime :: ClockTime -> CalendarTime
converts an internal clock time into a CalendarTime in standard UTC format.
toClockTime :: CalendarTime -> ClockTime
converts a CalendarTime into the corresponding internal ClockTime, ignoring the contents of the ctWDay, ctYDay, ctTZName and ctIsDST fields.
calendarTimeToString :: CalendarTime -> String
formats calendar times using local conventions.
formatCalendarTime :: TimeLocale -> String -> CalendarTime -> String
formats calendar times using local conventions and a formatting string. The formatting string is that understood by the ISO C strftime() function.
Produced by Haddock version 0.7