Compare commits

...

2 Commits

Author SHA1 Message Date
nobody e332516c1d This commit was manufactured by cvs2svn to create tag
'Version_1_30_0'.

[SVN r18026]
2003-03-20 02:53:48 +00:00
nobody 858618e0da This commit was manufactured by cvs2svn to create branch 'RC_1_30_0'.
[SVN r17693]
2003-03-01 19:43:06 +00:00
3 changed files with 79 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
// This example displays the amount of time until new year's in days
#include "boost/date_time/gregorian/gregorian.hpp"
#include <iostream>
int
main()
{
using namespace boost::gregorian;
date::ymd_type today = day_clock::local_day_ymd();
date new_years_day(today.year + 1,1,1);
date_duration dd = new_years_day - date(today);
std::cout << "Days till new year: " << dd.days() << std::endl;
return 0;
};
+37
View File
@@ -0,0 +1,37 @@
// Simple program that uses the gregorian calendar to find the last
// day of the month.
#include "boost/date_time/gregorian/gregorian.hpp"
#include <iostream>
int
main()
{
std::cout << " Enter Year(ex: 2002): ";
int year, month;
std::cin >> year;
std::cout << " Enter Month(1..12): ";
std::cin >> month;
try {
int day = boost::gregorian::gregorian_calendar::end_of_month_day(year,month);
boost::gregorian::date endOfMonth(year,month,day);
std::cout << boost::gregorian::to_simple_string(endOfMonth) << std::endl;
//Iterate thru by months --
boost::gregorian::month_iterator mitr(endOfMonth,1);
boost::gregorian::date startOfNextYear(year+1,1,1);
//loop thru the days and print each one
while (mitr < startOfNextYear){
std::cout << boost::gregorian::to_simple_string(*mitr) << std::endl;
++mitr;
}
}
catch(...) {
std::cout << "Invalid Date Entered" << std::endl;
}
return 0;
}
+24
View File
@@ -0,0 +1,24 @@
// Simple program that uses the gregorian calendar to find the last
// day of the month.
#include "boost/date_time/gregorian/gregorian.hpp"
#include <iostream>
int
main()
{
using namespace boost::gregorian;
typedef boost::date_time::month_functor<date> add_month;
date d = day_clock::local_day();
add_month mf(1);
date d2 = d + mf.get_offset(d);
std::cout << to_simple_string(d2) << std::endl;
return 0;
}