Previous: SRFI-19 Date to string, Up: SRFI-19


6.4.15.6 SRFI-19 String to date

— Function: string->date input template

Convert an input string to a date under the control of a template string. Return a newly created date object.

Literal characters in template must match characters in input and `~' escapes must match the input forms described in the table below. “Skip to” means characters up to one of the given type are ignored, or “no skip” for no skipping. “Read” is what's then read, and “Set” is the field affected in the date object.

For example `~Y' skips input characters until a digit is reached, at which point it expects a year and stores that to the year field of the date.

Skip to Read Set


~~ no skip literal ~ nothing


~a char-alphabetic? locale abbreviated weekday name nothing


~A char-alphabetic? locale full weekday name nothing


~b char-alphabetic? locale abbreviated month name date-month


~B char-alphabetic? locale full month name date-month


~d char-numeric? day of month date-day


~e no skip day of month, blank padded date-day


~h same as `~b'


~H char-numeric? hour date-hour


~k no skip hour, blank padded date-hour


~m char-numeric? month date-month


~M char-numeric? minute date-minute


~S char-numeric? second date-second


~y no skip 2-digit year date-year within 50 years


~Y char-numeric? year date-year


~z no skip time zone date-zone-offset

Notice that the weekday matching forms don't affect the date object returned, instead the weekday will be derived from the day, month and year.

Currently Guile doesn't implement any localizations for the above, month and weekday names are always expected in English. This may change in the future.