std::time_g..._date_order(3)
π¦ std::time_g..._date_order(3) π¦
okay so bestie, this page comes from the C++ Standard Libary manual β that's the manual name exactly, spelling and all, no cap. It's the whole vibe check on std::time_get::date_order and std::time_get::do_date_order π
β¨
πΈ NAME πΈ
bestie, the name is a two-for-one: std::time_get::date_order and std::time_get::do_date_order. The official name line is exactly:
std::time_get::date_order,std::time_get::do_date_order - std::time_get::date_order,std::time_get::do_date_order
β¨ Synopsis β¨
Defined in header <locale> β here's the exact synopsis, bestie:
Defined in header <locale>
public: (1)
dateorder date_order() const;
protected: (2)
virtual dateorder do_date_order() const;
- Public member function, calls the protected virtual member function
do_date_orderof the most derived class. - Returns a value of type
std::time_base::dateorder, which describes the default date format used by this locale (expected byget_date()and produced bystd::strftime()with format specifier'%x').
The valid values (inherited from std::time_base) are:
no_orderβ the format contains variable items (week day,Julian day, etc), or this function is not implementeddmyβ day, month, year (European locales)mdyβ month, day, year (American locales)ymdβ year, month, day (Asian locales)ydmβ year, day, month (rare)
π Parameters π
(none) β literally none, bestie. No args, no stress π«Ά
π Return value π
A value of type dateorder β¨
π§ Notes π§
This function is optional, it may return no_order in every case. So yeah, it's giving optional and may just say no_order every time.
π₯ Example π₯
The output below was obtained using clang (libc++).
// 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();
}
π Possible output π
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
π See also π
do_get_dateβ extracts month, day, and year from input stream ([virtual], virtual protected member function)time_baseβ defines date format constants (class)
okay that's the page, bestie! source/version: http://cppreference.com Β· date: 2024.06.10 Β· page: std::time_g..._date_order(3) β mwah πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms