Project

General

Profile

Bug #2803 ยป test_WBoostAny_locale.C

Bruce Toll, 03/11/2014 05:13 PM

 
#include <iostream>
#include <Wt/WDate>
#include <Wt/WDateTime>
#include <Wt/WBoostAny>
#include <Wt/WLocale>

int main(int argc, char **argv)
{
Wt::WLocale default_us_locale(
Wt::WLocale::currentLocale()); // the default WLocale is based on US conventions

Wt::WDate date(2014, 12, 31); // year, month, day
Wt::WDateTime date_time(date);
boost::any ba_date(date);
boost::any ba_date_time(date_time);

std::cout << "locale dateFormat: " << default_us_locale.dateFormat() << "\n";
std::cout << "locale dateTimeFormat: " << default_us_locale.dateTimeFormat() << "\n";
std::cout << "WDate: toString(): " << date.toString() << "\n";
std::cout << "WDateTime toString(): " << date_time.toString() << "\n";

std::cout << "\n\nNOTE: boost::any WDate honors currentLocale, but boost::any WDateTime does not\n\n";
std::cout << "Wt::asString(boost::any WDate): " << Wt::asString(ba_date) << "\n";
std::cout << "Wt::asString(boost::any WDateTime): " << Wt::asString(ba_date_time) << "\n\n\n";


std::cout << "NOTE: Documentation implies that both default to a dd/MM/yy format, regardless of locale\n\n";
std::cout << "See: http://www.webtoolkit.eu/wt/doc/reference/html/group__modelview.html#ga57b5cadd177847f51eaeb0cee23782c1\n";

return 0;
}
    (1-1/1)