mirror of
https://github.com/boostorg/date_time.git
synced 2026-02-26 16:42:20 +00:00
merge changes from RC_1_29_0 -- fix locale to support date order
[SVN r15560]
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
const char* const de_long_month_names[]={"Januar","Februar","Marz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember","NichtDerMonat"};
|
||||
const char* const de_special_value_names[]={"NichtDatumzeit","-unbegrenztheit", "+unbegrenztheit"};
|
||||
|
||||
// const char* const de_short_weekday_names[]={"Son", "Mon", "Diens"};
|
||||
const char* const de_short_weekday_names[]={"Son", "Mon", "Die","Mit", "Don", "Fre", "Sam"};
|
||||
|
||||
const char* const de_long_weekday_names[]={"Sonntag", "Montag", "Dienstag","Mittwoch", "Donnerstag", "Freitag", "Samstag"};
|
||||
|
||||
@@ -40,7 +40,9 @@ main()
|
||||
|
||||
date_facet gdnp(de_short_month_names, de_long_month_names,
|
||||
de_special_value_names, de_long_weekday_names,
|
||||
de_long_weekday_names);
|
||||
de_long_weekday_names,
|
||||
'.',
|
||||
boost::date_time::ymd_order_dmy);
|
||||
|
||||
std::stringstream ss;
|
||||
std::ostreambuf_iterator<char> coi(ss);
|
||||
@@ -50,13 +52,13 @@ main()
|
||||
|
||||
ss.str(""); //reset string stream
|
||||
greg_month m(Oct);
|
||||
month_formatter::format_month(m, ss, gdnp, boost::date_time::month_as_short_string);
|
||||
month_formatter::format_month(m, ss, gdnp);
|
||||
check("check german short month: " + ss.str(),
|
||||
ss.str() == std::string("Okt"));
|
||||
ss.str(""); //reset string stream
|
||||
month_formatter::format_month(m, ss, gdnp, boost::date_time::month_as_long_string);
|
||||
check("check german long month: " + ss.str(),
|
||||
ss.str() == std::string("Oktober"));
|
||||
// month_formatter::format_month(m, ss, gdnp);
|
||||
// check("check german long month: " + ss.str(),
|
||||
// ss.str() == std::string("Oktober"));
|
||||
|
||||
|
||||
greg_year_month_day ymd(2002,Oct,1);
|
||||
@@ -64,7 +66,7 @@ main()
|
||||
ss.str(""); //reset string stream
|
||||
ymd_formatter::ymd_put(ymd, ss, gdnp);
|
||||
check("check ymd: " + ss.str(),
|
||||
ss.str() == std::string("2002-Okt-01"));
|
||||
ss.str() == std::string("01.Okt.2002"));
|
||||
|
||||
|
||||
typedef boost::date_time::ostream_date_formatter<date, date_facet_base> datef;
|
||||
@@ -73,7 +75,7 @@ main()
|
||||
date d1(2002, Oct, 1);
|
||||
datef::date_put(d1, os, gdnp);
|
||||
check("ostream low level check string:"+os.str(),
|
||||
os.str() == std::string("2002-Okt-01"));
|
||||
os.str() == std::string("01.Okt.2002"));
|
||||
|
||||
// //Locale tests
|
||||
std::locale global;
|
||||
@@ -128,6 +130,54 @@ main()
|
||||
f << d1 << std::endl;
|
||||
|
||||
// // date formatter that takes locale and gets facet from locale
|
||||
std::locale german_dates1(global,
|
||||
new date_facet(de_short_month_names,
|
||||
de_long_month_names,
|
||||
de_special_value_names,
|
||||
de_short_weekday_names,
|
||||
de_long_weekday_names,
|
||||
'.',
|
||||
boost::date_time::ymd_order_dmy,
|
||||
boost::date_time::month_as_integer));
|
||||
|
||||
os3.imbue(german_dates1);
|
||||
os3.str("");
|
||||
os3 << d1;
|
||||
check("check date order: "+os3.str(),
|
||||
os3.str() == std::string("01.10.2002"));
|
||||
|
||||
std::locale german_dates2(global,
|
||||
new date_facet(de_short_month_names,
|
||||
de_long_month_names,
|
||||
de_special_value_names,
|
||||
de_short_weekday_names,
|
||||
de_long_weekday_names,
|
||||
' ',
|
||||
boost::date_time::ymd_order_iso,
|
||||
boost::date_time::month_as_short_string));
|
||||
|
||||
os3.imbue(german_dates2);
|
||||
os3.str("");
|
||||
os3 << d1;
|
||||
check("check date order: "+os3.str(),
|
||||
os3.str() == std::string("2002 Okt 01"));
|
||||
|
||||
std::locale german_dates3(global,
|
||||
new date_facet(de_short_month_names,
|
||||
de_long_month_names,
|
||||
de_special_value_names,
|
||||
de_short_weekday_names,
|
||||
de_long_weekday_names,
|
||||
' ',
|
||||
boost::date_time::ymd_order_us,
|
||||
boost::date_time::month_as_long_string));
|
||||
|
||||
os3.imbue(german_dates3);
|
||||
os3.str("");
|
||||
os3 << d1;
|
||||
check("check date order: "+os3.str(),
|
||||
os3.str() == std::string("Oktober 01 2002"));
|
||||
|
||||
|
||||
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user