Skip to content

Commit

Permalink
Simplify isStartOfMonth and isEndOfMonth functions
Browse files Browse the repository at this point in the history
  • Loading branch information
igitur committed Jul 29, 2024
1 parent 6331e50 commit 5de635f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ql/time/calendar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,15 @@ namespace QuantLib {
}

inline bool Calendar::isStartOfMonth(const Date& d) const {
return (d.month() != adjust(d-1, Preceding).month());
return d <= startOfMonth(d);
}

inline Date Calendar::startOfMonth(const Date& d) const {
return adjust(Date::startOfMonth(d), Following);
}

inline bool Calendar::isEndOfMonth(const Date& d) const {
return (d.month() != adjust(d+1).month());
return d >= endOfMonth(d);
}

inline Date Calendar::endOfMonth(const Date& d) const {
Expand Down

0 comments on commit 5de635f

Please sign in to comment.