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 | |
| parent | 0ece82d184b618a8314bc07d4a447f856847104f (diff) | |
Add LocalTime::add().
Diffstat (limited to 'src')
| -rw-r--r-- | src/local_time.cc | 17 | ||||
| -rw-r--r-- | src/local_time.h | 2 |
2 files changed, 14 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)); } diff --git a/src/local_time.h b/src/local_time.h index aacd7728..d2f4b2c5 100644 --- a/src/local_time.h +++ b/src/local_time.h @@ -121,6 +121,8 @@ public: void add_months (int a); void add_minutes (int a); + void add(boost::posix_time::time_duration duration); + static LocalTime from_asn1_utc_time (std::string time); static LocalTime from_asn1_generalized_time (std::string time); |
