diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-05-12 12:41:23 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-05-12 13:12:48 +0200 |
| commit | 4070e3f3b270a4a8c91d4cf2b7942b842c95ea3d (patch) | |
| tree | 6872e110d87288b37b2475b22de63e6ae99055b0 | |
| parent | a774e29da150480594385daf4946010db9d8e391 (diff) | |
Make add_minutes() work correctly with milliseconds.
| -rw-r--r-- | src/local_time.cc | 2 | ||||
| -rw-r--r-- | test/local_time_test.cc | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/local_time.cc b/src/local_time.cc index 1c174e50..ed809d49 100644 --- a/src/local_time.cc +++ b/src/local_time.cc @@ -237,7 +237,7 @@ LocalTime::add_minutes (int m) { using namespace boost; - posix_time::ptime t(gregorian::date(_year, _month, _day), posix_time::time_duration(_hour, _minute, _second)); + 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); } diff --git a/test/local_time_test.cc b/test/local_time_test.cc index a95bf3f6..4ac92240 100644 --- a/test/local_time_test.cc +++ b/test/local_time_test.cc @@ -176,6 +176,12 @@ BOOST_AUTO_TEST_CASE (local_time_add_minutes_test) t.add_minutes (7); BOOST_CHECK_EQUAL (t.as_string(), "2018-02-01T00:02:00+01:00"); } + + { + dcp::LocalTime t("2018-01-31T23:55:00.123"); + t.add_minutes (7); + BOOST_CHECK_EQUAL (t, dcp::LocalTime("2018-02-01T00:02:00.123")); + } } |
