Fix off-by-one bug in iso_week::year_lastweek_weekday

* The conversion from year_lastweek_weekday to sys_days
  and local_days had an off by one error.
* Added test for this case.
This commit is contained in:
Howard Hinnant
2017-11-30 10:28:14 -05:00
parent 87ed7f83cf
commit c513a20691
2 changed files with 13 additions and 2 deletions
+2 -2
View File
@@ -1314,7 +1314,7 @@ inline
year_lastweek_weekday::operator sys_days() const NOEXCEPT
{
return sys_days(date::year{static_cast<int>(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<int>(y_)}/date::dec/date::thu[date::last])
+ (mon - thu) - (mon - wd_);
+ (sun - thu) - (sun - wd_);
}
CONSTCD11