diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-03-10 17:17:45 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-03-10 17:17:45 +0100 |
| commit | a818ea7b22fc3c669dea70f4104ab5d9ed50b642 (patch) | |
| tree | bffbc738184c525564c751a5f039c19478c23af5 /src/local_time.cc | |
| parent | d7e82f235998557e7529729d630762e309d1e654 (diff) | |
Add LocalTime::add_minutes.
Diffstat (limited to 'src/local_time.cc')
| -rw-r--r-- | src/local_time.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/local_time.cc b/src/local_time.cc index 2aa55183..f0eb42a3 100644 --- a/src/local_time.cc +++ b/src/local_time.cc @@ -39,7 +39,9 @@ #include "exceptions.h" #include "dcp_assert.h" #include <boost/lexical_cast.hpp> +#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/c_local_time_adjustor.hpp> +#include <boost/date_time/gregorian/gregorian.hpp> #include <cstdio> using std::string; @@ -79,6 +81,12 @@ LocalTime::set (struct tm const * tm) */ LocalTime::LocalTime (boost::posix_time::ptime t) { + set (t); +} + +void +LocalTime::set (boost::posix_time::ptime t) +{ _year = t.date().year (); _month = t.date().month (); _day = t.date().day (); @@ -234,6 +242,16 @@ LocalTime::add_months (int m) } } +void +LocalTime::add_minutes (int m) +{ + using namespace boost; + + posix_time::ptime t(gregorian::date(_year, _month, _day), posix_time::time_duration(_hour, _minute, _second)); + t += posix_time::time_duration(0, m, 0); + set (t); +} + bool LocalTime::operator== (LocalTime const & other) const { |
