Warning: This is the manual of the legacy Guile 2.0 series. You may want to read the manual of the current stable series instead.

Previous: , Up: SRFI-19   [Contents][Index]


7.5.16.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 toReadSet
~~no skipliteral ~nothing
~achar-alphabetic?locale abbreviated weekday namenothing
~Achar-alphabetic?locale full weekday namenothing
~bchar-alphabetic?locale abbreviated month namedate-month
~Bchar-alphabetic?locale full month namedate-month
~dchar-numeric?day of monthdate-day
~eno skipday of month, blank paddeddate-day
~hsame as ‘~b
~Hchar-numeric?hourdate-hour
~kno skiphour, blank paddeddate-hour
~mchar-numeric?monthdate-month
~Mchar-numeric?minutedate-minute
~Schar-numeric?seconddate-second
~yno skip2-digit yeardate-year within 50 years
~Ychar-numeric?yeardate-year
~zno skiptime zonedate-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.

Conversion is locale-dependent on systems that support it (see Accessing Locale Information). See setlocale, for information on how to change the current locale.