diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-12-01 21:22:44 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-12-13 21:57:52 +0100 |
| commit | 9e63c37ed41d2eb4fd321cf29ac6c682423f2bb6 (patch) | |
| tree | 6f3b9cebde30264f14f9aaa7e68f6d9a2f36b2be /src/local_time.cc | |
| parent | 0ece82d184b618a8314bc07d4a447f856847104f (diff) | |
Add LocalTime::add().
Diffstat (limited to 'src/local_time.cc')
| -rw-r--r-- | src/local_time.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/local_time.cc b/src/local_time.cc index 8d48e037..c8576584 100644 --- a/src/local_time.cc +++ b/src/local_time.cc @@ -236,6 +236,17 @@ LocalTime::add_days (int days) void +LocalTime::add(boost::posix_time::time_duration duration) +{ + using namespace boost; + + posix_time::ptime t(gregorian::date(_year, _month, _day), posix_time::time_duration(_hour, _minute, _second, _millisecond * 1000)); + t += duration; + set (t); +} + + +void LocalTime::add_months (int m) { using namespace boost; @@ -254,11 +265,7 @@ 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, _millisecond * 1000)); - t += posix_time::time_duration(0, m, 0); - set (t); + add(boost::posix_time::time_duration(0, m, 0)); } |
