Utility for parsing dates.
String to parse
|-> Maybe CalendarTime|
Parse a date string as formatted by
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.
- locale's abbreviated weekday name (Sun ... Sat)
- locale's full weekday name (Sunday .. Saturday)
- locale's abbreviated month name (Jan..Dec)
- locale's full month name (January..December)
- locale's date and time format (Thu Mar 25 17:47:03 CET 2004)
- century [00-99]
- day of month, zero padded (01..31)
- date (%m/%d/%y)
- day of month, space padded ( 1..31)
- same as %b
- hour, 24-hour clock, zero padded (00..23)
- hour, 12-hour clock, zero padded (01..12)
- day of the year, zero padded (001..366)
- hour, 24-hour clock, space padded ( 0..23)
- hour, 12-hour clock, space padded ( 1..12)
- month, zero padded (01..12)
- minute, zero padded (00..59)
- a newline character
- locale's AM or PM indicator
- locale's 12-hour time format (hh:mm:ss AM/PM)
- hours and minutes, 24-hour clock (hh:mm)
- * seconds since '00:00:00 1970-01-01 UTC'
- seconds, zero padded (00..59)
- a horizontal tab character
- time, 24-hour clock (hh:mm:ss)
- numeric day of the week (1=Monday, 7=Sunday)
- * week number, weeks starting on Sunday, zero padded (01-53)
- * week number (as per ISO-8601), week 1 is the first week with a Thursday, zero padded, (01-53)
- numeric day of the week, (0=Sunday, 6=Monday)
- * week number, weeks starting on Monday, zero padded (01-53)
- locale's preferred way of printing dates (%m/%d/%y)
- locale's preferred way of printing time. (%H:%M:%S)
- year, within century, zero padded (00..99)
- year, including century. Not padded (this is probably a bug, but formatCalendarTime does it this way). (0-9999)
- time zone abbreviation (e.g. CET) or RFC-822 style numeric timezone (-0500)