MissingH-1.3.0.1: Large utility library

Copyright | (c) by Björn Bringert
License | GPL2
Maintainer | Björn Bringert
Stability | provisional
Portability | portable
Safe Haskell | None
Language | Haskell98

System.Time.ParseDate

Description

Utility for parsing dates.

Synopsis

- parseCalendarTime :: TimeLocale -> String -> String -> Maybe CalendarTime

# Documentation

parseCalendarTime Source

Arguments

:: TimeLocale | Time locale
-> String | Date format
-> String | String to parse
-> Maybe CalendarTime | `Nothing` if parsing failed.

Parse a date string as formatted by `formatCalendarTime`.

The resulting `CalendarTime` will only have those fields set that are represented by a format specifier in the format string, and those fields will be set to the values given in the date string. If the same field is specified multiple times, the rightmost occurence takes precedence.

The resulting date is not neccessarily a valid date. For example, if there is no day of the week specifier in the format string, the value of `ctWDay` will most likely be invalid.

Format specifiers are % followed by some character. All other characters are treated literally. Whitespace in the format string matches zero or more arbitrary whitespace characters.

Format specifiers marked with * are matched, but do not set any field in the output.

Some of the format specifiers are marked as space-padded or zero-padded. Regardless of this, space-padded, zero-padded or unpadded inputs are accepted. Note that strings using unpadded fields without separating the fields may cause strange parsing.

Supported format specfiers:

%%
  a % character.
%a
  locale's abbreviated weekday name (Sun ... Sat)
%A
  locale's full weekday name (Sunday .. Saturday)
%b
  locale's abbreviated month name (Jan..Dec)
%B
  locale's full month name (January..December)
%c
  locale's date and time format (Thu Mar 25 17:47:03 CET 2004)
%C
  century [00-99]
%d
  day of month, zero padded (01..31)
%D
  date (%m/%d/%y)
%e
  day of month, space padded ( 1..31)
%h
  same as %b
%H
  hour, 24-hour clock, zero padded (00..23)
%I
  hour, 12-hour clock, zero padded (01..12)
%j
  day of the year, zero padded (001..366)
%k
  hour, 24-hour clock, space padded ( 0..23)
%l
  hour, 12-hour clock, space padded ( 1..12)
%m
  month, zero padded (01..12)
%M
  minute, zero padded (00..59)
%n
  a newline character
%p
  locale's AM or PM indicator
%r
  locale's 12-hour time format (hh:mm:ss AM/PM)
%R
  hours and minutes, 24-hour clock (hh:mm)
%s
  * seconds since '00:00:00 1970-01-01 UTC'
%S
  seconds, zero padded (00..59)
%t
  a horizontal tab character
%T
  time, 24-hour clock (hh:mm:ss)
%u
  numeric day of the week (1=Monday, 7=Sunday)
%U
  * week number, weeks starting on Sunday, zero padded (01-53)
%V
  * week number (as per ISO-8601), week 1 is the first week with a Thursday, zero padded, (01-53)
%w
  numeric day of the week, (0=Sunday, 6=Monday)
%W
  * week number, weeks starting on Monday, zero padded (01-53)
%x
  locale's preferred way of printing dates (%m/%d/%y)
%X
  locale's preferred way of printing time. (%H:%M:%S)
%y
  year, within century, zero padded (00..99)
%Y
  year, including century. Not padded (this is probably a bug, but formatCalendarTime does it this way). (0-9999)
%Z
  time zone abbreviation (e.g. CET) or RFC-822 style numeric timezone (-0500)