std::time_get<CharT,InputIt>::date_order, std::time_get<CharT,InputIt>::do_date_order
提供: cppreference.com
<tbody>
</tbody>
| ヘッダ <locale> で定義
|
||
public: dateorder date_order() const; |
(1) | |
protected: virtual dateorder do_date_order() const; |
(2) | |
1) public メンバ関数。 最も派生したクラスの protected virtual メンバ関数
do_date_order を呼びます。2) std::time_base::dateorder 型の値を返します。 これはこのロケールによって使用されるデフォルトの日付の書式を記述します (get_date() によって期待され、書式指定子
'%x' を用いた std::strftime() によって生成されます)。(std::time_base から継承した) 有効な値は以下の通りです。
no_order
|
書式が可変な項目 (曜日、ユリウス日、など) を含む、または、この関数は実装されません |
dmy
|
日、月、年 (ヨーロッパ式) |
mdy
|
月、日、年 (アメリカ式) |
ymd
|
年、月、日 (アジア式) |
ydm
|
年、日、月 (稀) |
引数
(なし)
戻り値
dateorder 型の値。
ノート
この関数はオプショナルです。 すべての場合に no_order を返しても構いません。
例
Run this code
#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
関連項目
[仮想] |
入力ストリームから月、日、年を抽出します (仮想プロテクテッドメンバ関数) |
| 日付の書式の定数を定義します (クラス) |