year_month
month_day
month_day_last
month_weekday
month_weekday_last
year_month_day
year_month_day_last
year_month_weekday
year_month_weekday_last
These operator/ overloads provide a conventional syntax for the creation of Proleptic Gregorian calendar dates.
For creation of a full date, any of the following three orders are accepted:
year/month/day
,month/day/year
,day/month/year
.In each case day
can replaced with one of:
weekday[i]
, for the i
th weekday of the month;weekday[std::chrono::last]
, for the last weekday of the month.A plain integer is accepted if its meaning is unambiguous from the types of other operands: 2005y/4/5 is allowed, but 5/April/2005 is not.
Partial-date types (year_month
, month_day
, etc.) can be created by not applying the second operator/ in any of the three orders.
#include <chrono> using namespace std::chrono; constexpr auto ym{2021y/8}; static_assert(ym == year_month(year(2021), August)); constexpr auto md{9/15d}; static_assert(md == month_day(September, day(15))); constexpr auto mdl{October/last}; static_assert(mdl == month_day_last(month(10))); constexpr auto mw{11/Monday[3]}; static_assert(mw == month_weekday(November, Monday[3])); constexpr auto mwdl{December/Sunday[last]}; static_assert(mwdl == month_weekday_last(month(12), weekday_last(Sunday))); // Those 3 year/month/day orders that people actually use on this planet and beyond: constexpr auto ymd{year(2021)/January/day(23)}; static_assert(ymd == month{1}/23/2021); static_assert(ymd == day{23}/1/2021); static_assert(ymd == year_month_day(2021y, month(January), 23d)); int main() {}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4