views:

58

answers:

2

The page

http://www.boost.org/doc/libs/1_42_0/doc/html/date_time/gregorian.html#date_construction

explains that you can initialize a Boost date with this kind of call:

date d(2002, Jan, 10);

But when I try that, the compiler doesn't know 'Jan'.

It does work with:

date d(2002, 1, 10);

EDIT:

#include <boost/date_time/gregorian/gregorian.hpp>
..
{
    using namespace boost::gregorian;

    date limit_date(2010,Apr,1);
    date fake_date(2010,2,1);

    if (fake_date>limit_date)
    {
        ...
    }
}
A: 

Maybe you missed including of needed namespace? I can't say which one exactly, because you didn't post whole code, but I can suppose, that it can be something like:

using namespace boost::gregorian;

or

using namespace boost::date_time;

Update:

Defenition of Jan:

namespace boost {
namespace date_time {

  //! An enumeration of weekday names
  enum weekdays {Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday};

  //! Simple enum to allow for nice programming with Jan, Feb, etc
  enum months_of_year {Jan=1,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec,NotAMonth,NumMonths};

} } //namespace date_time
woo
No, that's not the problem. It does work with only figures (I updated the initial message).
Oodini
Yeah, Jan is a member of enum, so it still may be a problem with namespace. Can you post complete code that doesn't work?
woo
Yes, I understood it was an enum, but I didn't find where it was defined...I added the code in the initial message.
Oodini
According to http://www.boost.org/doc/libs/1_42_0/boost/date_time/date_defs.hpp , it must be something like boost::date_time::Jan P.S. I have add defenetion of Jan to main post.
woo
A: 

OK, I found the (silly) solution : I just forgot to link date_time to my own library...

As some parts of boost::date_time don't require an explicit linking, they worked. That's why I didn't explore this way.

Thanks Jan for help and the enum !

Oodini