#include "boost/gdtl/gregorian/gregorian.hpp"
#include "boost/gdtl/date_parsing.hpp"
#include <iostream>
#include <string>
int
main()
{
using namespace gregorian;
try {
std::string s("2001-10-9");
date d(gdtl::parse_date<date>(s));
std::cout << to_simple_string(d) << std::endl;
std::string ud("20011009");
date d1(gdtl::parse_undelimited_date<date>(ud));
std::cout << to_iso_extended_string(d1) << std::endl;
date::ymd_type ymd = d1.year_month_day();
greg_weekday wd = d1.day_of_week();
std::cout << wd.as_long_string() << " "
<< ymd.month.as_long_string() << " "
<< ymd.day << ", " << ymd.year
<< std::endl;
std::string bad_date("20012509");
std::cout << "An expected exception is next: " << std::endl;
date wont_construct(gdtl::parse_undelimited_date<date>(bad_date));
std::cout << "oh oh, you should reach this line: "
<< to_iso_string(wont_construct) << std::endl;
}
catch(std::exception& e) {
std::cout << " Exception: " << e.what() << std::endl;
}
return 0;
}