41using years = std::chrono::duration
198template<class CharT, class Traits>
199std::basic_ostream<CharT, Traits>&
200operator<<(std::basic_ostream<CharT, Traits>& os, const
day& d);
235template<class CharT, class Traits>
236std::basic_ostream<CharT, Traits>&
237operator<<(std::basic_ostream<CharT, Traits>& os, const
month& m);
277template<class CharT, class Traits>
278std::basic_ostream<CharT, Traits>&
279operator<<(std::basic_ostream<CharT, Traits>& os, const
year& y);
318template<class CharT, class Traits>
319std::basic_ostream<CharT, Traits>&
320operator<<(std::basic_ostream<CharT, Traits>& os, const
weekday& wd);
340template<class CharT, class Traits>
341std::basic_ostream<CharT, Traits>&
342operator<<(std::basic_ostream<CharT, Traits>& os, const
weekday_indexed& wdi);
360template<class CharT, class Traits>
361std::basic_ostream<CharT, Traits>&
362operator<<(std::basic_ostream<CharT, Traits>& os, const
weekday_last& wdl);
401template<class CharT, class Traits>
402std::basic_ostream<CharT, Traits>&
403operator<<(std::basic_ostream<CharT, Traits>& os, const
year_month& ym);
428template<class CharT, class Traits>
429std::basic_ostream<CharT, Traits>&
430operator<<(std::basic_ostream<CharT, Traits>& os, const
month_day& md);
452template<class CharT, class Traits>
453std::basic_ostream<CharT, Traits>&
454operator<<(std::basic_ostream<CharT, Traits>& os, const
month_day_last& mdl);
475template<class CharT, class Traits>
476std::basic_ostream<CharT, Traits>&
477operator<<(std::basic_ostream<CharT, Traits>& os, const
month_weekday& mwd);
501template<class CharT, class Traits>
502std::basic_ostream<CharT, Traits>&
553template<class CharT, class Traits>
554std::basic_ostream<CharT, Traits>&
555operator<<(std::basic_ostream<CharT, Traits>& os, const
year_month_day& ymd);
620template<class CharT, class Traits>
621std::basic_ostream<CharT, Traits>&
687template<class CharT, class Traits>
688std::basic_ostream<CharT, Traits>&
753template<class CharT, class Traits>
754std::basic_ostream<CharT, Traits>&
757#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
758inline namespace literals
801 return static_cast<unsigned>(x) ==
static_cast<unsigned>(y);
817 return static_cast<unsigned>(x) <
static_cast<unsigned>(y);
849 return days{
static_cast<days::rep
>(
static_cast<unsigned>(x)
850 -
static_cast<unsigned>(y))};
858 return day{
static_cast<unsigned>(x) +
static_cast<unsigned>(y.count())};
877template<
class CharT,
class Traits>
879std::basic_ostream<CharT, Traits>&
880operator<<(std::basic_ostream<CharT, Traits>& os,
const day& d)
886 os << static_cast<unsigned>(d);
924 return static_cast<unsigned>(x) ==
static_cast<unsigned>(y);
940 return static_cast<unsigned>(x) <
static_cast<unsigned>(y);
972 auto const d =
static_cast<unsigned>(x) -
static_cast<unsigned>(y);
973 return months(d <= 11 ? d : d + 12);
981 auto const mu =
static_cast<long long>(
static_cast<unsigned>(x)) - 1 + y.count();
982 auto const yr = (
mu >= 0 ?
mu :
mu-11) / 12;
983 return month{
static_cast<unsigned>(
mu - yr * 12 + 1)};
1002template<
class CharT,
class Traits>
1004std::basic_ostream<CharT, Traits>&
1005operator<<(std::basic_ostream<CharT, Traits>& os,
const month& m)
1007 switch (
static_cast<unsigned>(m))
1046 os << static_cast<unsigned>(m) <<
" is not a valid month";
1094 return static_cast<int>(x) ==
static_cast<int>(y);
1110 return static_cast<int>(x) <
static_cast<int>(y);
1142 return years{
static_cast<int>(x) -
static_cast<int>(y)};
1150 return year{
static_cast<int>(x) + y.count()};
1166 return year{
static_cast<int>(x) - y.count()};
1169template<
class CharT,
class Traits>
1171std::basic_ostream<CharT, Traits>&
1172operator<<(std::basic_ostream<CharT, Traits>& os,
const year& y)
1177 os.width(4 + (y < year{0}));
1178 os << static_cast<int>(y);
1189 return static_cast<unsigned char>(
static_cast<unsigned>(
1190 z >= -4 ? (z+4) % 7 : (z+5) % 7 + 6));
1196 : wd_(
static_cast<decltype(wd_)
>(wd))
1202 : wd_(weekday_from_days(dp.time_since_epoch().count()))
1208 : wd_(weekday_from_days(dp.time_since_epoch().count()))
1238 return static_cast<unsigned>(wd_);
1248 return static_cast<unsigned>(x) ==
static_cast<unsigned>(y);
1264 auto const diff =
static_cast<unsigned>(x) -
static_cast<unsigned>(y);
1265 return days{diff <= 6 ? diff : diff + 7};
1273 auto const wdu =
static_cast<long long>(
static_cast<unsigned>(x)) + y.count();
1274 auto const wk = (wdu >= 0 ? wdu : wdu-6) / 7;
1275 return weekday{
static_cast<unsigned>(wdu - wk * 7)};
1294template<
class CharT,
class Traits>
1296std::basic_ostream<CharT, Traits>&
1297operator<<(std::basic_ostream<CharT, Traits>& os,
const weekday& wd)
1299 switch (
static_cast<unsigned>(wd))
1323 os << static_cast<unsigned>(wd) <<
" is not a valid weekday";
1329#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
1330inline namespace literals
1373#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
1394 return weekday().
ok() && 1 <= index_ && index_ <= 5;
1400 : wd_(
static_cast<decltype(wd_)
>(
static_cast<unsigned>(wd)))
1401 , index_(
static_cast<decltype(index_)
>(index))
1404template<
class CharT,
class Traits>
1406std::basic_ostream<CharT, Traits>&
1409 return os << wdi.
weekday() <<
'[' << wdi.
index() <<
']';
1417 return {*
this, index};
1425 return x.weekday() == y.weekday() && x.index() == y.index();
1447 return x.weekday() == y.weekday();
1458template<
class CharT,
class Traits>
1460std::basic_ostream<CharT, Traits>&
1461operator<<(std::basic_ostream<CharT, Traits>& os,
const weekday_last& wdl)
1463 return os << wdl.weekday() <<
"[last]";
1528 return x.year() == y.year() && x.month() == y.month();
1544 return x.year() < y.year() ? true
1545 : (x.year() > y.year() ? false
1546 : (x.month() < y.month()));
1578 auto dmi =
static_cast<int>(
static_cast<unsigned>(ym.month())) - 1 + dm.count();
1579 auto dy = (dmi >= 0 ? dmi : dmi-11) / 12;
1580 dmi = dmi - dy * 12 + 1;
1581 return (ym.year() +
years(dy)) /
month(
static_cast<unsigned>(dmi));
1605 return (x.year() - y.year()) +
1606 months(
static_cast<unsigned>(x.month()) -
static_cast<unsigned>(y.month()));
1614 return (ym.year() + dy) / ym.month();
1633template<
class CharT,
class Traits>
1635std::basic_ostream<CharT, Traits>&
1636operator<<(std::basic_ostream<CharT, Traits>& os,
const year_month& ym)
1638 return os << ym.year() <<
'/' << ym.month();
1663 return m_.
ok() &&
julian::day(1) <=
d_ && d_ <= d[static_cast<unsigned>(m_)-1];
1671 return x.month() == y.month() && x.day() == y.day();
1687 return x.month() < y.month() ? true
1688 : (x.month() > y.month() ? false
1689 : (x.day() < y.day()));
1716template<
class CharT,
class Traits>
1718std::basic_ostream<CharT, Traits>&
1719operator<<(std::basic_ostream<CharT, Traits>& os,
const month_day& md)
1721 return os << md.month() <<
'/' << md.day();
1735 return x.month() == y.month();
1751 return x.month() < y.month();
1778template<
class CharT,
class Traits>
1780std::basic_ostream<CharT, Traits>&
1781operator<<(std::basic_ostream<CharT, Traits>& os,
const month_day_last& mdl)
1783 return os << mdl.month() <<
"/last";
1811 return m_.
ok() && wdi_.
ok();
1819 return x.month() == y.month() && x.weekday_indexed() == y.weekday_indexed();
1830template<
class CharT,
class Traits>
1832std::basic_ostream<CharT, Traits>&
1833operator<<(std::basic_ostream<CharT, Traits>& os,
const month_weekday& mwd)
1835 return os << mwd.month() <<
'/' << mwd.weekday_indexed();
1863 return m_.
ok() && wdl_.
ok();
1871 return x.month() == y.month() && x.weekday_last() == y.weekday_last();
1882template<
class CharT,
class Traits>
1884std::basic_ostream<CharT, Traits>&
1885operator<<(std::basic_ostream<CharT, Traits>& os,
const month_weekday_last& mwdl)
1887 return os << mwdl.month() <<
'/' << mwdl.weekday_last();
1979 return y_.
ok() && mdl_.
ok();
1987 return x.year() == y.year() && x.month_day_last() == y.month_day_last();
2003 return x.year() < y.year() ? true
2004 : (x.year() > y.year() ? false
2005 : (x.month_day_last() < y.month_day_last()));
2032template<
class CharT,
class Traits>
2034std::basic_ostream<CharT, Traits>&
2035operator<<(std::basic_ostream<CharT, Traits>& os,
const year_month_day_last& ymdl)
2037 return os << ymdl.year() <<
'/' << ymdl.month_day_last();
2045 return (ymdl.year() / ymdl.month() + dm) /
last;
2061 return ymdl + (-dm);
2069 return {ymdl.year()+dy, ymdl.month_day_last()};
2085 return ymdl + (-dy);
2164 static_assert(std::numeric_limits<unsigned>::digits >= 18,
2165 "This algorithm has not been ported to a 16 bit unsigned integer");
2166 static_assert(std::numeric_limits<int>::digits >= 20,
2167 "This algorithm has not been ported to a 16 bit signed integer");
2168 auto const y =
static_cast<int>(y_) - (m_ <=
feb);
2169 auto const m =
static_cast<unsigned>(m_);
2170 auto const d =
static_cast<unsigned>(
d_);
2171 auto const era = (y >= 0 ? y : y-3) / 4;
2172 auto const yoe =
static_cast<unsigned>(y - era * 4);
2173 auto const doy = (153*(m > 2 ? m-3 : m+9) + 2)/5 + d-1;
2174 auto const doe = yoe * 365 + doy;
2175 return days{era * 1461 +
static_cast<int>(doe) - 719470};
2197 if (!(y_.
ok() && m_.
ok()))
2207 return x.year() == y.year() && x.month() == y.month() && x.day() == y.day();
2223 return x.year() < y.year() ? true
2224 : (x.year() > y.year() ? false
2225 : (x.month() < y.month() ? true
2226 : (x.month() > y.month() ? false
2227 : (x.day() < y.day()))));
2254template<
class CharT,
class Traits>
2256std::basic_ostream<CharT, Traits>&
2257operator<<(std::basic_ostream<CharT, Traits>& os,
const year_month_day& ymd)
2262 os << ymd.year() <<
'-';
2264 os << static_cast<unsigned>(ymd.month()) <<
'-';
2274 static_assert(std::numeric_limits<unsigned>::digits >= 18,
2275 "This algorithm has not been ported to a 16 bit unsigned integer");
2276 static_assert(std::numeric_limits<int>::digits >= 20,
2277 "This algorithm has not been ported to a 16 bit signed integer");
2278 auto const z = dp.count() + 719470;
2279 auto const era = (z >= 0 ? z : z - 1460) / 1461;
2280 auto const doe =
static_cast<unsigned>(z - era * 1461);
2281 auto const yoe = (doe - doe/1460) / 365;
2282 auto const y =
static_cast<sys_days::rep
>(yoe) + era * 4;
2283 auto const doy = doe - 365*yoe;
2284 auto const mp = (5*doy + 2)/153;
2285 auto const d = doy - (153*mp+2)/5 + 1;
2286 auto const m = mp < 10 ? mp+3 : mp-9;
2295 return (ymd.year() / ymd.month() + dm) / ymd.day();
2319 return (ymd.year() + dy) / ymd.month() / ymd.day();
2414 return wdi_.
index();
2446 if (wdi_.
index() <= 4)
2449 return static_cast<unsigned>(d2.count()) <=
static_cast<unsigned>((y_/m_/
last).day());
2460 return {ymd.year(), ymd.month(), wd[(
static_cast<unsigned>(ymd.day())-1)/7+1]};
2470 ).time_since_epoch();
2478 return x.year() == y.year() && x.month() == y.month() &&
2479 x.weekday_indexed() == y.weekday_indexed();
2490template<
class CharT,
class Traits>
2492std::basic_ostream<CharT, Traits>&
2493operator<<(std::basic_ostream<CharT, Traits>& os,
const year_month_weekday& ymwdi)
2495 return os << ymwdi.year() <<
'/' << ymwdi.month()
2496 <<
'/' << ymwdi.weekday_indexed();
2504 return (ymwd.year() / ymwd.month() + dm) / ymwd.weekday_indexed();
2520 return ymwd + (-dm);
2528 return {ymwd.year()+dy, ymwd.month(), ymwd.weekday_indexed()};
2544 return ymwd + (-dy);
2633 return y_.
ok() && m_.
ok() && wdl_.
ok();
2650 return x.year() == y.year() && x.month() == y.month() &&
2651 x.weekday_last() == y.weekday_last();
2662template<
class CharT,
class Traits>
2664std::basic_ostream<CharT, Traits>&
2665operator<<(std::basic_ostream<CharT, Traits>& os,
const year_month_weekday_last& ymwdl)
2667 return os << ymwdl.year() <<
'/' << ymwdl.month() <<
'/' << ymwdl.weekday_last();
2672year_month_weekday_last
2675 return (ymwdl.year() / ymwdl.month() + dm) / ymwdl.weekday_last();
2680year_month_weekday_last
2688year_month_weekday_last
2691 return ymwdl + (-dm);
2696year_month_weekday_last
2699 return {ymwdl.year()+dy, ymwdl.month(), ymwdl.weekday_last()};
2704year_month_weekday_last
2712year_month_weekday_last
2715 return ymwdl + (-dy);
2733 return y /
month(
static_cast<unsigned>(m));
2759 return m /
day(
static_cast<unsigned>(d));
2767 return month(
static_cast<unsigned>(m)) / d;
2795 return month(
static_cast<unsigned>(m))/
last;
2829 return month(
static_cast<unsigned>(m)) / wdi;
2863 return month(
static_cast<unsigned>(m)) / wdl;
2881 return {ym.year(), ym.month(), d};
2889 return ym /
day(
static_cast<unsigned>(d));
2897 return y / md.month() / md.day();
2905 return year(y) / md;
2921 return year(y) / md;
2947 return year(y) / mdl;
2963 return year(y) / mdl;
2973 return {ym.year(), ym.month(), wdi};
2981 return {y, mwd.month(), mwd.weekday_indexed()};
2989 return year(y) / mwd;
3005 return year(y) / mwd;
3012year_month_weekday_last
3015 return {ym.year(), ym.month(), wdl};
3020year_month_weekday_last
3023 return {y, mwdl.month(), mwdl.weekday_last()};
3028year_month_weekday_last
3031 return year(y) / mwdl;
3036year_month_weekday_last
3044year_month_weekday_last
3047 return year(y) / mwdl;
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD14 day & operator+=(const days &d) NOEXCEPT
CONSTCD14 day & operator-=(const days &d) NOEXCEPT
CONSTCD14 day & operator--() NOEXCEPT
CONSTCD14 day & operator++() NOEXCEPT
CONSTCD11 day(unsigned d) NOEXCEPT
CONSTCD11 month_day_last(const julian::month &m) NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD11 julian::month month() const NOEXCEPT
CONSTCD11 julian::month month() const NOEXCEPT
CONSTCD11 month_day(const julian::month &m, const julian::day &d) NOEXCEPT
CONSTCD11 julian::day day() const NOEXCEPT
CONSTCD14 bool ok() const NOEXCEPT
CONSTCD11 julian::weekday_last weekday_last() const NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
julian::weekday_last wdl_
CONSTCD11 julian::month month() const NOEXCEPT
CONSTCD11 month_weekday_last(const julian::month &m, const julian::weekday_last &wd) NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
julian::weekday_indexed wdi_
CONSTCD11 julian::month month() const NOEXCEPT
CONSTCD11 month_weekday(const julian::month &m, const julian::weekday_indexed &wdi) NOEXCEPT
CONSTCD11 julian::weekday_indexed weekday_indexed() const NOEXCEPT
CONSTCD14 month & operator+=(const months &m) NOEXCEPT
CONSTCD14 month & operator-=(const months &m) NOEXCEPT
CONSTCD14 month & operator++() NOEXCEPT
CONSTCD11 month(unsigned m) NOEXCEPT
CONSTCD14 month & operator--() NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD11 unsigned index() const NOEXCEPT
CONSTCD11 weekday_indexed(const julian::weekday &wd, unsigned index) NOEXCEPT
CONSTCD11 julian::weekday weekday() const NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD11 julian::weekday weekday() const NOEXCEPT
CONSTCD11 weekday_last(const julian::weekday &wd) NOEXCEPT
CONSTCD14 weekday & operator++() NOEXCEPT
static CONSTCD11 unsigned char weekday_from_days(int z) NOEXCEPT
CONSTCD14 weekday & operator--() NOEXCEPT
CONSTCD14 weekday & operator-=(const days &d) NOEXCEPT
CONSTCD11 weekday(unsigned wd) NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD14 weekday & operator+=(const days &d) NOEXCEPT
CONSTCD11 weekday_indexed operator[](unsigned index) const NOEXCEPT
julian::month_day_last mdl_
CONSTCD11 julian::month month() const NOEXCEPT
CONSTCD11 julian::year year() const NOEXCEPT
CONSTCD11 year_month_day_last(const julian::year &y, const julian::month_day_last &mdl) NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD14 julian::day day() const NOEXCEPT
CONSTCD11 julian::month_day_last month_day_last() const NOEXCEPT
CONSTCD14 year_month_day_last & operator+=(const months &m) NOEXCEPT
CONSTCD14 year_month_day_last & operator-=(const months &m) NOEXCEPT
static CONSTCD14 year_month_day from_days(days dp) NOEXCEPT
CONSTCD11 julian::month month() const NOEXCEPT
CONSTCD11 julian::day day() const NOEXCEPT
CONSTCD14 days to_days() const NOEXCEPT
CONSTCD14 year_month_day & operator-=(const months &m) NOEXCEPT
CONSTCD11 year_month_day(const julian::year &y, const julian::month &m, const julian::day &d) NOEXCEPT
CONSTCD11 julian::year year() const NOEXCEPT
CONSTCD14 year_month_day & operator+=(const months &m) NOEXCEPT
CONSTCD14 bool ok() const NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD14 days to_days() const NOEXCEPT
CONSTCD11 julian::weekday_last weekday_last() const NOEXCEPT
julian::weekday_last wdl_
CONSTCD14 year_month_weekday_last & operator-=(const months &m) NOEXCEPT
CONSTCD11 julian::month month() const NOEXCEPT
CONSTCD11 julian::year year() const NOEXCEPT
CONSTCD11 julian::weekday weekday() const NOEXCEPT
CONSTCD14 year_month_weekday_last & operator+=(const months &m) NOEXCEPT
CONSTCD11 year_month_weekday_last(const julian::year &y, const julian::month &m, const julian::weekday_last &wdl) NOEXCEPT
CONSTCD11 julian::month month() const NOEXCEPT
CONSTCD11 year_month_weekday(const julian::year &y, const julian::month &m, const julian::weekday_indexed &wdi) NOEXCEPT
CONSTCD14 year_month_weekday & operator-=(const months &m) NOEXCEPT
CONSTCD14 year_month_weekday & operator+=(const months &m) NOEXCEPT
CONSTCD11 julian::weekday_indexed weekday_indexed() const NOEXCEPT
static CONSTCD14 year_month_weekday from_days(days dp) NOEXCEPT
CONSTCD14 bool ok() const NOEXCEPT
CONSTCD11 julian::year year() const NOEXCEPT
CONSTCD11 julian::weekday weekday() const NOEXCEPT
CONSTCD14 days to_days() const NOEXCEPT
julian::weekday_indexed wdi_
CONSTCD11 unsigned index() const NOEXCEPT
CONSTCD14 year_month & operator-=(const months &dm) NOEXCEPT
CONSTCD14 year_month & operator+=(const months &dm) NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD11 julian::month month() const NOEXCEPT
CONSTCD11 julian::year year() const NOEXCEPT
CONSTCD11 year_month(const julian::year &y, const julian::month &m) NOEXCEPT
CONSTCD14 year & operator++() NOEXCEPT
CONSTCD14 year & operator-=(const years &y) NOEXCEPT
CONSTCD11 bool is_leap() const NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD14 year & operator--() NOEXCEPT
static CONSTCD11 year max() NOEXCEPT
CONSTCD14 year & operator+=(const years &y) NOEXCEPT
static CONSTCD11 year min() NOEXCEPT
CONSTCD11 year(int y) NOEXCEPT
decltype(std::ratio_divide< R1, R2 >{}) ratio_divide
decltype(std::ratio_multiply< R1, R2 >{}) ratio_multiply
local_time< days > local_days
std::chrono::duration< int, detail::ratio_multiply< std::ratio< 7 >, days::period > > weeks
std::chrono::duration< int, detail::ratio_multiply< std::ratio< 24 >, std::chrono::hours::period > > days
sys_time< days > sys_days
CONSTDATA julian::month oct
CONSTDATA julian::month jul
CONSTDATA julian::weekday fri
CONSTDATA julian::month apr
CONSTDATA julian::month feb
CONSTDATA julian::month sep
CONSTDATA julian::weekday sun
CONSTDATA julian::month dec
CONSTDATA julian::weekday tue
CONSTDATA julian::month jan
CONSTDATA julian::month nov
CONSTDATA julian::weekday mon
CONSTDATA julian::last_spec last
CONSTDATA julian::weekday sat
CONSTDATA julian::weekday thu
CONSTDATA julian::weekday wed
CONSTDATA julian::month aug
CONSTDATA julian::month jun
CONSTDATA julian::month mar
CONSTDATA julian::month may
CONSTCD11 day operator+(const day &x, const days &y) NOEXCEPT
std::chrono::duration< int, date::detail::ratio_divide< years::period, std::ratio< 12 > > > months
CONSTCD11 bool operator>=(const day &x, const day &y) NOEXCEPT
CONSTCD11 bool operator!=(const day &x, const day &y) NOEXCEPT
CONSTCD11 bool operator>(const day &x, const day &y) NOEXCEPT
std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &os, const day &d)
CONSTCD11 day operator-(const day &x, const days &y) NOEXCEPT
std::chrono::duration< int, date::detail::ratio_multiply< std::ratio< 1461, 4 >, days::period > > years
CONSTCD11 bool operator==(const day &x, const day &y) NOEXCEPT
CONSTCD11 year_month operator/(const year &y, const month &m) NOEXCEPT
CONSTCD11 bool operator<=(const day &x, const day &y) NOEXCEPT
date::local_days local_days
CONSTCD11 bool operator<(const day &x, const day &y) NOEXCEPT
Namespace for mathematical applications.