Add add_days to LocalTime.
authorCarl Hetherington <cth@carlh.net>
Wed, 20 May 2020 20:09:55 +0000 (22:09 +0200)
committerCarl Hetherington <cth@carlh.net>
Wed, 20 May 2020 20:10:44 +0000 (22:10 +0200)
src/local_time.cc
src/local_time.h

index ed809d4926a088b7fd730bd425d33e69b5cf3165..6a8579ffc495743c365157502297106767e7f3bf 100644 (file)
@@ -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)
 {
index 310c598cc6d430fd84bc79996b8f979ccfccd2f9..e818ba6e32a9165fc9bb9ef53cab161967c1d309 100644 (file)
@@ -83,6 +83,7 @@ public:
                _year = y;
        }
 
+       void add_days (int d);
        void add_months (int a);
        void add_minutes (int a);