在线文档教程
C++
本土化 | Localizations

std::time_get::date_order

STD:时间[医]GET::日期[医]订单,STD::时间[医]得到::做[医]日期[医]命令

Defined in header
public: dateorder date_order() const;(1)
protected: virtual dateorder do_date_order() const;(2)

1%29公共成员函数,调用受保护的虚拟成员函数do_date_order最派生的类。

2%29返回类型的值。std::time_base::dateorder,它描述了此区域设置%28所使用的默认日期格式。get_date()并由std::strftime()格式说明符'%x'29%。

继承的有效值%28。std::time_base%29是:

no_orderthe format contains variable items (week day, Julian day, etc), or this function is not implemented
dmyday, month, year (European locales)
mdymonth, day, year (American locales)
ymdyear, month, day (Asian locales)
ydmyear, day, month (rare)

参数

%280%29

返回值

类型值dateorder...

注记

此函数是可选的,它可能会返回no_order在每一种情况下。

二次

#include <iostream> #include <locale> void show_date_order() { std::time_base::dateorder d = std::use_facet<std::time_get<char>>( std::locale() ).date_order( switch (d) { case std::time_base::no_order: std::cout << "no_order\n"; break; case std::time_base::dmy: std::cout << "day, month, year\n"; break; case std::time_base::mdy: std::cout << "month, day, year\n"; break; case std::time_base::ymd: std::cout << "year, month, day\n"; break; case std::time_base::ydm: std::cout << "year, day, month\n"; break; } } int main() { std::locale::global(std::locale("en_US.utf8") std::cout << "In U.S. locale, the default date order is: "; show_date_order( std::locale::global(std::locale("ja_JP.utf8") std::cout << "In Japanese locale, the default date order is: "; show_date_order( std::locale::global(std::locale("de_DE.utf8") std::cout << "In German locale, the default date order is: "; show_date_order( }

二次

产出:

二次

In U.S. locale, the default date order is: month, day, year In Japanese locale, the default date order is: year, month, day In German locale, the default date order is: day, month, year

二次

另见

do_get_date virtualextracts month, day, and year from input stream (virtual protected member function)
time_basedefines date format constants (class)

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/locale/time[医]得到/日期[医]命令