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_order | the format contains variable items (week day, Julian day, etc), or this function is not implemented |
---|---|
dmy | day, month, year (European locales) |
mdy | month, day, year (American locales) |
ymd | year, month, day (Asian locales) |
ydm | year, 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 virtual | extracts month, day, and year from input stream (virtual protected member function) |
---|---|
time_base | defines date format constants (class) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。