std::time_get<CharT,InputIt>::date_order, std::time_get<CharT,InputIt>::do_date_order
来自 cppreference.cn
定义于头文件 <locale> |
||
public: dateorder date_order() const; |
(1) | |
protected: virtual dateorder do_date_order() const; |
(2) | |
1) 公有成员函数,调用最派生类的受保护虚成员函数
do_date_order
。2) 返回
std::time_base::dateorder
类型的值,它描述此本地环境使用的默认日期格式( get_date()
期待此格式,且 std::strftime()
以格式说明符 '%x'
生成此格式)。有效值(继承自 std::time_base
)为
no_order
|
格式包含可变项(星期、儒略日等),或此函数未实现 |
dmy
|
日、月、年(欧洲本地环境) |
mdy
|
月、日、年(美洲本地环境) |
ymd
|
年、月、日(亚洲本地环境) |
ydm
|
年、日、月(罕见) |
目录 |
[编辑] 返回值
dateorder
类型的值。
[编辑] 说明
此函数是可选的,它可能在任何情况下都返回 no_order
。
[编辑] 示例
以下输出使用 clang (libc++) 获得。
运行此代码
#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
[编辑] 参见
[虚函数] |
从输入流提取月、日和年 (虚保护成员函数) |
定义日期格式常量 (类) |