From 1a8a857f22d7eb4da51508082300a970dfec3f06 Mon Sep 17 00:00:00 2001 From: Jeff Garland Date: Thu, 25 Sep 2003 11:12:27 +0000 Subject: [PATCH] fix algorithm for week no based on comment from C. Tondering [SVN r20180] --- include/boost/date_time/gregorian_calendar.ipp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/boost/date_time/gregorian_calendar.ipp b/include/boost/date_time/gregorian_calendar.ipp index 3dfba2f..cb12640 100644 --- a/include/boost/date_time/gregorian_calendar.ipp +++ b/include/boost/date_time/gregorian_calendar.ipp @@ -30,7 +30,7 @@ namespace date_time { /*!Implements the rules associated with the iso 8601 week number. Basically the rule is that Week 1 of the year is the week that contains January 4th or the week that contains the first Thursday in January. - Reference for this algorithm is the Calendar FAQ by Claus Todering, April 2000. + Reference for this algorithm is the Calendar FAQ by Claus Tondering, April 2000. */ template BOOST_DATE_TIME_INLINE @@ -50,8 +50,8 @@ namespace date_time { if((day==6) ||(day == 5 && is_leap_year(ymd.year))) { return week; //under these circumstances week == 53. } - else if (day != 5) { - return 1; //monday - thursday is in week 1 of next year + else { + return 1; //monday - wednesday is in week 1 of next year } } //if the week is not in current year recalculate using the previous year as the beginning year @@ -117,8 +117,8 @@ namespace date_time { date_int_type d = (4*c + 3)/1461; date_int_type e = c - (1461*d)/4; date_int_type m = (5*e + 2)/153; - unsigned short day = e - ((153*m + 2)/5) + 1; - unsigned short month = m + 3 - 12 * (m/10); + unsigned short day = static_cast(e - ((153*m + 2)/5) + 1); + unsigned short month = static_cast(m + 3 - 12 * (m/10)); date_int_type year = 100*b + d - 4800 + (m/10); //std::cout << year << "-" << month << "-" << day << "\n";