#include #include #include #include #include #include #define DATESTR "%Y-%m-%d %H:%M:%S" using namespace boost::locale; static std::string _strftime( std::string format, date_time ts, std::locale loc ) { std::stringstream tmp; tmp.imbue( loc ); tmp << as::ftime( format ); tmp << ts; return tmp.str(); } static void _setdate( date_time &t, int year, int month, int day ) { t.set( period::year(), year ); t.set( period::month(), month ); t.set( period::day(), day ); t.set( period::hour(), 0 ); t.set( period::minute(), 0 ); t.set( period::second(), 0 ); } static void _printdates( std::locale loc, date_time t, int n ) { std::string mismatch; for( int _n = 0; _n < n; _n++, t+=period::day() ) { std::stringstream i; i << t.get( period::year() ); if( i.str() != _strftime("%Y", t, loc) ) { mismatch = " !"; } else { mismatch = ""; } std::cout << t << " ++ " << _strftime( DATESTR, t, loc ) << mismatch << std::endl; } std::cout << std::endl; } int main( int argc, char** argv ) { int n = 10; generator gen; std::locale loc = gen( "" ); std::locale::global( loc ); std::cout.imbue( loc ); date_time t; for( int y=2000; y<2014; y++ ) { _setdate( t, y, 11, 27 ); _printdates( loc, t, n ); } }