Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
NewTime
[go: Go Back, main page]

 ContentsIndex
NewTime
Contents
ClockTime
Timezones
CalendarTime
Synopsis
data ClockTime
getClockTime :: IO ClockTime
data Timezone
utcTimezone :: Timezone
taiTimezone :: Timezone
timezoneFromUTCOffset :: Int -> Timezone
timezoneFromName :: String -> Maybe Timezone
timezoneUTCOffset :: Timezone -> Maybe Int
timezoneName :: Timezone -> String
getCurrentTimezone :: IO Timezone
data CalendarTime = CalendarTime {
ctYear :: Int
ctMonth :: Int
ctDay :: Int
ctHour :: Int
ctMin :: Int
ctSec :: Int
ctPicosec :: Integer
ctTZ :: Timezone
}
clockTimeToCalendarTime :: ClockTime -> IO CalendarTime
clockTimeToUTCTime :: ClockTime -> CalendarTime
clockTimeToTAITime :: ClockTime -> CalendarTime
clockTimeToCalendarTimeTZ :: Timezone -> ClockTime -> CalendarTime
calendarTimeToClockTime :: CalendarTime -> Maybe ClockTime
calendarTimeDayOffsets :: CalendarTime -> (Int, Int)
formatCalendarTime :: TimeLocale -> String -> CalendarTime -> String
ClockTime
data ClockTime
A representation of absolute time, measured as picoseconds since the epoch, where the epoch is 1 January 1970 00:10 TAI.
Instances
Show ClockTime
Read ClockTime
Eq ClockTime
Ord ClockTime
Num ClockTime
Enum ClockTime
Real ClockTime
Integral ClockTime
getClockTime :: IO ClockTime
Returns the current absolute time.

Our ClockTime is defined in terms of TAI, because this provides an absolute time scale and can be used for accurate time calculations.

However, this is not always implementable. Many systems run their system clocks on a time scale that ignores leap seconds. For example, POSIX's time_t uses a broken notion of "seconds since the epoch", defined by a formula in terms of UTC time ignoring leap seconds.

On systems which run their clocks on time_t time, the library will do its best to convert to TAI time for a ClockTime. The effect is that the ClockTime might be incorrect by up to 1 second around the time of a leap second (it depends on how your system adjusts its clock when a leap second occurs).

Regardless of what the system supports, calculations on values of type ClockTime are well-defined and deterministic. Inaccuracies only occur at the boundaries:

  • getClockTime might be inaccurate on Unix systems, for the reasons mentioned above.
  • Converting a ClockTime representing a future time into a UTC-based CalendarTime might be inaccurate because of the lack of knowledge of future leap seconds. This problem will be present in any library providing UTC operations.
Timezones
data Timezone
Instances
Show Timezone
Eq Timezone
Read Timezone
Ord Timezone
utcTimezone :: Timezone
The UTC timezone
taiTimezone :: Timezone
The TAI timezone
timezoneFromUTCOffset :: Int -> Timezone
Make a Timezone from an offset, in seconds relative to UTC, which must be smaller in magnitude than +/-12*60*60.
timezoneFromName :: String -> Maybe Timezone
Make a Timezone from a standard timezone name (eg. GMT, PDT). TAI is a valid timezone name.
timezoneUTCOffset :: Timezone -> Maybe Int
Return the offset in seconds of the specified timezone relative to UTC. If the timezone is TAI, returns Nothing, because TAI cannot be represented as a fixed offset relative to UTC.
timezoneName :: Timezone -> String

Return the timezone name corresponding to a Timezone value.

Some timezones may not correspond to a name, or the name of the timezone may not be known (some systems cannot convert easily from UTC offsets to timezone names), in which case timezoneName returns Nothing.

Some timezone names correspond to more than one actual timezone. These are: CST, CDT, EST, and EDT. Each of these is used for an Australian timezone in addition to a North American one. timezoneName is defined to return the North American versions of these. If you want the Australian versions, you can use the non-ambiguous names ACST, ACDT, AEST and AEDT respectively.

getCurrentTimezone :: IO Timezone
Returns the current timezone from the environment. On Unix, the current timezone is taken from the TZ environment variable, or the system default if TZ is not set.
CalendarTime
data CalendarTime
Constructors
CalendarTime
ctYear :: Int
ctMonth :: Int
ctDay :: Int
ctHour :: Int
ctMin :: Int
ctSec :: Int
ctPicosec :: Integer
ctTZ :: Timezone
Instances
Show CalendarTime
Eq CalendarTime
Ord CalendarTime
Read CalendarTime
clockTimeToCalendarTime :: ClockTime -> IO CalendarTime
Converts a ClockTime to a CalendarTime in the current timezone. Caveats for clockTimeToUTCTime also apply here.
clockTimeToUTCTime :: ClockTime -> CalendarTime

Converts a ClockTime to a CalendarTime in UTC.

Note that this function may produce unpredictable results for times sufficiently far in the future, because it is not known when leap seconds will need to be added to or subtracted from UTC.

clockTimeToTAITime :: ClockTime -> CalendarTime
Converts a ClockTime to a CalendarTime in TAI. Always produces predictable results.
clockTimeToCalendarTimeTZ :: Timezone -> ClockTime -> CalendarTime
Converts a ClockTime to a CalendarTime in the specified timezone. Caveats for clockTimeToUTCTime also apply here.
calendarTimeToClockTime :: CalendarTime -> Maybe ClockTime
Convert a CalendarTime to a ClockTime. Some values of CalendarTime do not represent a valid ClockTime, hence this function returns a Maybe type.
calendarTimeDayOffsets :: CalendarTime -> (Int, Int)
Return the day of the week and the day of the year for a given CalendarTime.
formatCalendarTime :: TimeLocale -> String -> CalendarTime -> String
Produced by Haddock version 0.6