mirror of
https://github.com/boostorg/date_time.git
synced 2026-02-28 05:12:22 +00:00
change nth_kday_of_month to return last kday if fifth kday of month is selected and it doesn't exist
[SVN r19934]
This commit is contained in:
@@ -83,7 +83,11 @@ namespace date_time {
|
||||
|
||||
//! Useful generator functor for finding holidays
|
||||
/*! Based on the idea in Cal. Calc. for finding holidays that are
|
||||
* the 'first Monday of September'.
|
||||
* the 'first Monday of September'. When instantiated with
|
||||
* 'fifth' kday of month, the result will be the last kday of month
|
||||
* which can be the fourth or fifth depending on the structure of
|
||||
* the month.
|
||||
*
|
||||
* The algorithm here basically guesses for the first
|
||||
* day of the month. Then finds the first day of the correct
|
||||
* type. That is, if the first of the month is a Tuesday
|
||||
@@ -124,6 +128,10 @@ namespace date_time {
|
||||
d = d + one_week;
|
||||
week++;
|
||||
}
|
||||
// remove wrapping to next month behavior
|
||||
if(d.month() != month_) {
|
||||
d = d - one_week;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
// added for streaming
|
||||
|
||||
Reference in New Issue
Block a user