Subject: Re: [Boost-bugs] [Boost C++ Libraries] #5753: previous_weekday() returns the very same day
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-03-15 15:42:07
#5753: previous_weekday() returns the very same day
-------------------------------+------------------------
Reporter: mjklaim@⦠| Owner: az_sw_dude
Type: Bugs | Status: closed
Milestone: To Be Determined | Component: date_time
Version: Boost 1.44.0 | Severity: Problem
Resolution: invalid | Keywords:
-------------------------------+------------------------
Changes (by marshall):
* status: new => closed
* resolution: => invalid
Comment:
Here's my take on the code in `days_before_weekday`:
`1`: Calculates a number in the range 0 .. 6 for the next time the
specified day of the week rolls around. Note that asking for Tuesday on
Tuesday gives you 0.
`2`: If we got a number > 0, then we're looking into the future. Set the
`wks` variable to 7.
`3`: Step `wks` days into the future, and then subtract off the number of
days we calculated in step 1.
Note that the comment at the end of the routine explicitly says that this
function can return zero (i.e, zero days from `d`). I don't see a bug in
this code (though I would be tempted to write it like this - ''warning:
untested code''):
{{{
typedef typename date_type::duration_type duration_type;
duration_type dd(wd.as_number() - d.day_of_week().as_number()); // 1
return dd ? duration_type(7) - dd ? 0;
}}}
I don't think there's a bug in this code. The behavior "return 0 when
asking for last Tuesday on Tuesday" is quite deliberate. Whether or not
that ''should'' be the behavior is a different question, and that's a
discussion that should be had on the boost mailing list.
I'll take a look at the documentation; see what the best place to add a
note is.
Closing this as "not a bug". If you disagree, please re-open it.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5753#comment:1> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC