名前空間
変種
操作

std::time_get<CharT,InputIt>::date_order、std::time_get<CharT,InputIt>::do_date_order

From cppreference.com
< cpp‎ | locale‎ | time get
 
 
 
 
 
ヘッダー <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() によって期待され、フォーマット指定子 '%x'std::strftime() によって生成されます)。

有効な値(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]
入力ストリームから月、日、年を抽出します。
(仮想保護メンバ関数) [編集]
日付書式の定数を定義する
(クラス) [編集]
English 日本語 中文(简体) 中文(繁體)