std::time_get<CharT,InputIt>:: date_order, std::time_get<CharT,InputIt>:: do_date_order
From cppreference.net
C++
Text processing library
| Localization library | |||||||||||||||||||||||||
| Regular expressions library (C++11) | |||||||||||||||||||||||||
| Formatting library (C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
Localization library
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::time_get
| Member functions | ||||
|
time_get::date_order
time_get::do_date_order
|
||||
|
定义于头文件
<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
参见
|
[virtual]
|
从输入流提取月份、日期和年份
(虚受保护成员函数) |
|
定义日期格式常量
(类) |