New year wildcard for string->date Dave Gurnell (09 Feb 2010 14:52 UTC)
Re: New year wildcard for string->date Marco Maggi (09 Feb 2010 20:12 UTC)
Re: New year wildcard for string->date Dave Gurnell (11 Feb 2010 07:52 UTC)

Re: New year wildcard for string->date Marco Maggi 09 Feb 2010 20:05 UTC

"Dave Gurnell" wrote:
> I use  string->date to parse dates in  my user interfaces,
> and my users  are always entering the year  with the wrong
> number of digits.

> (string->date "13/01/2010" "~d/~m/~y") ; => 13/01/2020 - incorrect
> (string->date "13/01/10"   "~d/~m/~Y") ; => 13/01/0010 - incorrect

If  I am  not mistaken,  this  specific cases  can be  fixed
doing:

(string->date "13/01/2010 " "~d/~m/~y ")
(string->date "13/01/10 " "~d/~m/~Y ")

that is: appending a white  space to both the strings, which
force the  termination of the escape sequence  match.  It is
not much beautiful but it is ready now.

  The  only  clean alternative  I  see  is  to introduce  an
end-of-string escape sequence, analogous to "$" for regexps.
--
Marco Maggi