0

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)
    {
        ...
    }
}
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Oodini
  • 1,092
  • 6
  • 11
  • 22

2 Answers2

0

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
  • 216
  • 1
  • 6
  • No, that's not the problem. It does work with only figures (I updated the initial message). – Oodini Feb 18 '10 at 17:39
  • 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 Feb 18 '10 at 18:27
  • 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 Feb 19 '10 at 09:38
  • 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 Feb 19 '10 at 10:01
0

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
  • 1,092
  • 6
  • 11
  • 22