Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2003-11-28 20:02:35


On Fri, 28 Nov 2003 16:36:28 -0800 (PST), David Sankel wrote
> >Thanks. I was planning on modifying parse_date to
> take the order as a
> >parameter (eg: ymd, mdy, etc) and thus would open up
> many other formats as
> >well -- while I was in there....
>
> >So it would look like:
>
> >parse_date(const std::string& s, ymd_order_spec
> order)
>
> Great.
>
> date t =
> boost::date_time::parse_date<date>(std::string(
> __DATE__),
> ymd_order_us);
>
> works for me.

This has been checked into CVS BTW. You can drop to the parse_date level, but
it is less stable. The best way is to do as follows:

  using namespace boost::gregorian;
  date d = from_us_string(__DATE__);
  
There is also a
  date d = from_uk_string("29-Feb-2000");
or
  date d = from_uk_string("29 Feb 2000");

This isn't in the docs yet, but there are tests in
date_time/test/gregorian/testparse_date.cpp.

Jeff


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk