| time-1.1.2.1: time library | Source code | Contents | Index
Data.Time.Format
Contents
UNIX-style formatting UNIX-style parsing
Synopsis
class FormatTime t where
formatCharacter :: Char -> Maybe (TimeLocale -> t -> String)
formatTime :: FormatTime t => TimeLocale -> String -> t -> String
parseTime :: ParseTime t => TimeLocale -> String -> String -> Maybe t
readTime :: ParseTime t => TimeLocale -> String -> String -> t
readsTime :: ParseTime t => TimeLocale -> String -> ReadS t
class ParseTime t where
buildTime :: TimeLocale -> [(Char, String)] -> t
UNIX-style formatting
class FormatTime t where | Source
Methods
formatCharacter :: Char -> Maybe (TimeLocale -> t -> String) | Source
Instances
FormatTime Day
FormatTime LocalTime
FormatTime TimeOfDay
FormatTime TimeZone
FormatTime UTCTime
FormatTime ZonedTime
formatTime :: FormatTime t => TimeLocale -> String -> t -> String | Source
Substitute various time-related information for each %-code in the string, as per `formatCharacter`. For all types (note these three are done here, not by `formatCharacter`): `%%` `%` `%t` tab `%n` newline For TimeZone (and ZonedTime and UTCTime): `%z` timezone offset on the format `-HHMM`. `%Z` timezone name For LocalTime (and ZonedTime and UTCTime): `%c` as `dateTimeFmt` `locale` (e.g. `%a %b %e %H:%M:%S %Z %Y`) For TimeOfDay (and LocalTime and ZonedTime and UTCTime): `%R` same as `%H:%M` `%T` same as `%H:%M:%S` `%X` as `timeFmt` `locale` (e.g. `%H:%M:%S`) `%r` as `time12Fmt` `locale` (e.g. `%I:%M:%S %p`) `%P` day half from (`amPm` `locale`), converted to lowercase, `am`, `pm` `%p` day half from (`amPm` `locale`), `AM`, `PM` `%H` hour, 24-hour, leading 0 as needed, `00` - `23` `%I` hour, 12-hour, leading 0 as needed, `01` - `12` `%k` hour, 24-hour, leading space as needed, `0` - `23` `%l` hour, 12-hour, leading space as needed, `1` - `12` `%M` minute, `00` - `59` `%S` second, without decimal part, `00` - `60` `%q` picosecond, including trailing zeros, `000000000000` - `999999999999`. `%Q` decimal point and up to 12 second decimals, without trailing zeros. For a whole number of seconds, `%Q` produces the empty string. For UTCTime and ZonedTime: `%s` number of whole seconds since the Unix epoch. For times before the Unix epoch, this is a negative number. Note that in `%s.%q` and `%s%Q` the decimals are positive, not negative. For example, 0.9 seconds before the Unix epoch is formatted as `-1.1` with `%s%Q`. For Day (and LocalTime and ZonedTime and UTCTime): `%D` same as `%m/%d/%y` `%F` same as `%Y-%m-%d` `%x` as `dateFmt` `locale` (e.g. `%m/%d/%y`) `%Y` year `%y` last two digits of year, `00` - `99` `%C` century (being the first two digits of the year), `00` - `99` `%B` month name, long form (`fst` from `months` `locale`), `January` - `December` `%b`, `%h` month name, short form (`snd` from `months` `locale`), `Jan` - `Dec` `%m` month of year, leading 0 as needed, `01` - `12` `%d` day of month, leading 0 as needed, `01` - `31` `%e` day of month, leading space as needed, `1` - `31` `%j` day of year for Ordinal Date format, `001` - `366` `%G` year for Week Date format `%g` last two digits of year for Week Date format, `00` - `99` `%f` century (first two digits of year) for Week Date format, `00` - `99` `%V` week for Week Date format, `01` - `53` `%u` day for Week Date format, `1` - `7` `%a` day of week, short form (`snd` from `wDays` `locale`), `Sun` - `Sat` `%A` day of week, long form (`fst` from `wDays` `locale`), `Sunday` - `Saturday` `%U` week number of year, where weeks start on Sunday (as `sundayStartWeek`), `00` - `53` `%w` day of week number, `0` (= Sunday) - `6` (= Saturday) `%W` week number of year, where weeks start on Monday (as `mondayStartWeek`), `00` - `53`
UNIX-style parsing
parseTime | Source
:: ParseTime t |
=> TimeLocale | Time locale.
-> String | Format string.
-> String | Input string.
-> Maybe t | The time value, or `Nothing` if the input could not be parsed using the given format.
Parses a time value given a format string. Supports the same %-codes as formatTime. Leading and trailing whitespace is accepted. Some variations in the input are accepted: `%z` accepts any of `-HHMM` or `-HH:MM`. `%Z` accepts any string of upper case letters, or any of the formats accepted by `%z`.
readTime | Source
:: ParseTime t |
=> TimeLocale | Time locale.
-> String | Format string.
-> String | Input string.
-> t | The time value.
Parse a time value given a format string. Fails if the input could not be parsed using the given format. See `parseTime` for details.
readsTime | Source
:: ParseTime t |
=> TimeLocale | Time locale.
-> String | Format string
-> ReadS t |
Parse a time value given a format string. See `parseTime` for details.
class ParseTime t where | Source
The class of types which can be parsed given a UNIX-style time format string.
Methods
buildTime | Source
:: TimeLocale | The time locale.
-> [(Char, String)] | Pairs of format characters and the corresponding part of the input.
-> t |
Builds a time value from a parsed input string. If the input does not include all the information needed to construct a complete value, any missing parts should be taken from 1970-01-01 00:00:00 +0000 (which was a Thursday).
Instances
ParseTime Day
ParseTime LocalTime
ParseTime TimeOfDay
ParseTime TimeZone
ParseTime UTCTime
ParseTime ZonedTime
Produced by Haddock version 0.9