std::chrono::year_month_day::operatorsys_days,std::chrono::year_month_day::operatorlocal_days (3) - Linux Manuals
std::chrono::year_month_day::operatorsys_days,std::chrono::year_month_day::operatorlocal_days: std::chrono::year_month_day::operatorsys_days,std::chrono::year_month_day::operatorlocal_days
Command to display std::chrono::year_month_day::operatorsys_days,std::chrono::year_month_day::operatorlocal_days
manual in Linux: $ man 3 std::chrono::year_month_day::operatorsys_days,std::chrono::year_month_day::operatorlocal_days
NAME
std::chrono::year_month_day::operatorsys_days,std::chrono::year_month_day::operatorlocal_days - std::chrono::year_month_day::operatorsys_days,std::chrono::year_month_day::operatorlocal_days
Synopsis
constexpr operator std::chrono::sys_days() const noexcept; (1) (since C++20)
explicit constexpr operator std::chrono::local_days() const noexcept; (2) (since C++20)
Converts *this to a std::chrono::time_point representing the same date as this year_month_day.
1) If ok() is true, the return value holds a count of days from the std::chrono::system_clock epoch (1970-01-01) to *this. The result is negative if *this represent a date prior to it.
Otherwise, if the stored year and month are valid (year().ok() && month().ok() is true), then the returned value is sys_days(year()/month()/1d) + (day() - 1d).
Otherwise (if year().ok() && month().ok() is false), the return value is unspecified.
A sys_days in the range [std::chrono::days{-12687428}, std::chrono::days{11248737}], when converted to year_month_day and back, yields the same value.
2) Same as (1) but returns local_days instead. Equivalent to return local_days(sys_days(*this).time_since_epoch());.
Notes
Converting to sys_days and back can be used to normalize a year_month_day that contains an invalid day but a valid year and month:
using namespace std::chrono;
auto ymd = 2017y/January/0;
ymd = sys_days{ymd};
// ymd is now 2016y/December/31
Normalizing the year and month can be done by adding (or subtracting) zero std::chrono::months:
using namespace std::chrono;
constexpr year_month_day normalize(year_month_day ymd){
ymd += months{0}; // normalizes year and month
return sys_days{ymd}; // normalizes day
}
static_assert(normalize(2017y/33/59) == 2019y/10/29);
Example
This section is incomplete
Reason: no example
Pages related to std::chrono::year_month_day::operatorsys_days,std::chrono::year_month_day::operatorlocal_days
- std::chrono::year_month_day::operatorsys_days,std::chrono::year_month_day::operator (3) - std::chrono::year_month_day::operatorsys_days,std::chrono::year_month_day::operator
- std::chrono::year_month_day::operator+=,std::chrono::year_month_day::operator-= (3) - std::chrono::year_month_day::operator+=,std::chrono::year_month_day::operator-=
- std::chrono::year_month_day::ok (3) - std::chrono::year_month_day::ok
- std::chrono::year_month_day::year,std::chrono::year_month_day::month, (3) - std::chrono::year_month_day::year,std::chrono::year_month_day::month,
- std::chrono::year_month_day::year,std::chrono::year_month_day::month,std::chrono::year_month_day::day (3) - std::chrono::year_month_day::year,std::chrono::year_month_day::month,std::chrono::year_month_day::day
- std::chrono::year_month_day::year_month_day (3) - std::chrono::year_month_day::year_month_day
- std::chrono::year_month_day (3) - std::chrono::year_month_day
- std::chrono::year_month_day_last (3) - std::chrono::year_month_day_last
- std::chrono::year_month_day_last::ok (3) - std::chrono::year_month_day_last::ok
- std::chrono::year_month_day_last::operator+=,std::chrono::year_month_day_last::operator-= (3) - std::chrono::year_month_day_last::operator+=,std::chrono::year_month_day_last::operator-=
- std::chrono::year_month_day_last::operatorsys_days, (3) - std::chrono::year_month_day_last::operatorsys_days,
- std::chrono::year_month_day_last::operatorsys_days,std::chrono::year_month_day_last::operatorlocal_days (3) - std::chrono::year_month_day_last::operatorsys_days,std::chrono::year_month_day_last::operatorlocal_days
- std::chrono::year_month_day_last::year,std::chrono::year_month_day_last::month, (3) - std::chrono::year_month_day_last::year,std::chrono::year_month_day_last::month,
- std::chrono::year_month_day_last::year,std::chrono::year_month_day_last::month,std::chrono::year_month_day_last::day,std::chrono::year_month_day_last::month_day_last (3) - std::chrono::year_month_day_last::year,std::chrono::year_month_day_last::month,std::chrono::year_month_day_last::day,std::chrono::year_month_day_last::month_day_last
- std::chrono::year_month_day_last::year_month_day_last (3) - std::chrono::year_month_day_last::year_month_day_last
- std::chrono::year_month_weekday (3) - std::chrono::year_month_weekday
- std::chrono::year_month_weekday::ok (3) - std::chrono::year_month_weekday::ok
- std::chrono::year_month_weekday::operator+=,std::chrono::year_month_weekday::operator-= (3) - std::chrono::year_month_weekday::operator+=,std::chrono::year_month_weekday::operator-=
- std::chrono::year_month_weekday::operatorsys_days, (3) - std::chrono::year_month_weekday::operatorsys_days,
- std::chrono::year_month_weekday::operatorsys_days,std::chrono::year_month_weekday::operatorlocal_days (3) - std::chrono::year_month_weekday::operatorsys_days,std::chrono::year_month_weekday::operatorlocal_days
- std::chrono::year_month_weekday::year,std::chrono::year_month_weekday::month, (3) - std::chrono::year_month_weekday::year,std::chrono::year_month_weekday::month,
- std::chrono::year_month_weekday::year_month_weekday (3) - std::chrono::year_month_weekday::year_month_weekday
- std::chrono::year_month_weekday_last (3) - std::chrono::year_month_weekday_last
- std::chrono::year_month_weekday_last::ok (3) - std::chrono::year_month_weekday_last::ok
- std::chrono::year_month_weekday_last::operator+=, (3) - std::chrono::year_month_weekday_last::operator+=,
- std::chrono::year_month_weekday_last::operator+=,std::chrono::year_month_weekday_last::operator-= (3) - std::chrono::year_month_weekday_last::operator+=,std::chrono::year_month_weekday_last::operator-=
- std::chrono::year_month_weekday_last::operatorsys_days, (3) - std::chrono::year_month_weekday_last::operatorsys_days,
- std::chrono::year_month_weekday_last::operatorsys_days,std::chrono::year_month_weekday_last::operatorlocal_days (3) - std::chrono::year_month_weekday_last::operatorsys_days,std::chrono::year_month_weekday_last::operatorlocal_days