diff --git a/include/date/iso_week.h b/include/date/iso_week.h index bbb2c8d..5bbeb0c 100644 --- a/include/date/iso_week.h +++ b/include/date/iso_week.h @@ -1314,7 +1314,7 @@ inline year_lastweek_weekday::operator sys_days() const NOEXCEPT { return sys_days(date::year{static_cast(y_)}/date::dec/date::thu[date::last]) - + (mon - thu) - (mon - wd_); + + (sun - thu) - (sun - wd_); } CONSTCD14 @@ -1322,7 +1322,7 @@ inline year_lastweek_weekday::operator local_days() const NOEXCEPT { return local_days(date::year{static_cast(y_)}/date::dec/date::thu[date::last]) - + (mon - thu) - (mon - wd_); + + (sun - thu) - (sun - wd_); } CONSTCD11 diff --git a/test/iso_week/year_lastweek_weekday.pass.cpp b/test/iso_week/year_lastweek_weekday.pass.cpp index 8827523..5f65f6f 100644 --- a/test/iso_week/year_lastweek_weekday.pass.cpp +++ b/test/iso_week/year_lastweek_weekday.pass.cpp @@ -115,4 +115,15 @@ main() std::ostringstream os; os << x0; assert(os.str() == "2015-W last-Tue"); + + for (auto y = 1950_y; y <= 2050_y; ++y) + { + auto wd = mon; + do + { + auto x = y/last/wd; + assert(date::year_month_day{x} == date::year_month_day{year_weeknum_weekday{x}}); + ++wd; + } while (wd != mon); + } }