diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/local_time.cc | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/local_time.cc b/src/local_time.cc index 3a4b0cd9..1c174e50 100644 --- a/src/local_time.cc +++ b/src/local_time.cc @@ -220,17 +220,16 @@ LocalTime::time_of_day (bool with_second, bool with_millisecond) const void LocalTime::add_months (int m) { - _month += m; + using namespace boost; - while (_month < 0) { - _month += 12; - _year--; + gregorian::date d (_year, _month, _day); + if (m > 0) { + d += gregorian::months (m); + } else { + d -= gregorian::months (-m); } - while (_month > 11) { - _month -= 12; - _year++; - } + set (posix_time::ptime(d, posix_time::time_duration(_hour, _minute, _second, _millisecond * 1000))); } void |
