From da78a8adb2302b15f89d353fa6610385f0bf2a69 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 20 May 2020 22:09:55 +0200 Subject: Add add_days to LocalTime. --- src/local_time.cc | 17 +++++++++++++++++ src/local_time.h | 1 + 2 files changed, 18 insertions(+) (limited to 'src') diff --git a/src/local_time.cc b/src/local_time.cc index ed809d49..6a8579ff 100644 --- a/src/local_time.cc +++ b/src/local_time.cc @@ -217,6 +217,23 @@ LocalTime::time_of_day (bool with_second, bool with_millisecond) const return buffer; } + +void +LocalTime::add_days (int days) +{ + using namespace boost; + + gregorian::date d (_year, _month, _day); + if (days > 0) { + d += gregorian::days (days); + } else { + d -= gregorian::days (-days); + } + + set (posix_time::ptime(d, posix_time::time_duration(_hour, _minute, _second, _millisecond * 1000))); +} + + void LocalTime::add_months (int m) { diff --git a/src/local_time.h b/src/local_time.h index 310c598c..e818ba6e 100644 --- a/src/local_time.h +++ b/src/local_time.h @@ -83,6 +83,7 @@ public: _year = y; } + void add_days (int d); void add_months (int a); void add_minutes (int a); -- cgit v1.2.3