Boost logo

Boost Users :

From: Dale McCoy (dalestan_at_[hidden])
Date: 2006-06-26 23:58:38


On 6/26/06, Jason Dolan <jason_at_[hidden]> wrote:
> I'm looking to take a string and convert it to a date. The only problem
> is the string can be one of many patterns. i.e. ("%Y%m%d", "%Y-%m-%d",
> "%d/%m/%Y", etc...). It is also possible that the given string will
> fail all pattern matches, and thus return false.

What I did was to manually parse the date, and accept the input only
if exactly one of the possible parsings produced a valid date.

There's probably an easier way out there, but my way works for me.

As Jeff points out, the "%Y%m%d" vs "%d/%m/%Y" detection will be ...
interesting, to say the least.

Dale


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net