|
Boost Users : |
From: Steve Johns (steve.johns_at_[hidden])
Date: 2007-02-11 16:46:08
Hi.
I am new to Boost, and beginning with compiling example code for
Boost::Date_Time.
I've had success compiling the many examples given here:
http://www.boost.org/doc/html/date_time/examples.html
but the very first example given here:
http://www.boost.org/doc/html/date_time/examples/general_usage_examples.html
I cannot compile without errors. (Code given below)
Changing week(1) to weeks(1) got me past the first hurdle, but still not
home.
The problem seems to have something to do with 'Sunday' not being of the
correct type, but I'm not truly certain what is going on, hence this post
...
As background, I'm using the MS VC++ 2005 compiler and Boost 1_33_1.
This example fails compilation from both the IDE and the command line.
I'd appreciate any insight into what would be needed to get this example to
correctly compile and run.
(And if there is a flaw in the example, I'd suggest that the docs be fixed
to provide it in working form.)
Thanks!
- Steve
__
using namespace boost::gregorian;
date weekstart(2002,Feb,1);
date weekend = weekstart + week(1);
date d2 = d1 + days(5);
date today = day_clock::local_day();
if (d2 >= today) {} //date comparison operators
date_period thisWeek(d1,d2);
if (thisWeek.contains(today)) {}//do something
//iterate and print the week
day_iterator itr(weekstart);
while (itr <= weekend) {
std::cout << (*itr) << std::endl;
++itr;
}
//input streaming
std::stringstream ss("2004-Jan-1");
ss >> d3;
//date generator functions
date d5 = next_weekday(d4, Sunday); //calculate Sunday following d4
//US labor day is first Monday in Sept
nth_day_of_the_week_in_month labor_day(nth_dow::first,Monday, Sep);
//calculate a specific date for 2004 from functor
date d6 = labor_day.get_date(2004);
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