diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-03-05 13:44:36 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-03-05 13:44:36 +0000 |
| commit | c8938a37429c914b77663328b6cff881be608775 (patch) | |
| tree | f3fef00fd60fab1b9c8dc99b3d5fdc9ee725b36b /src | |
| parent | 5bb20f440b2ce3f6410cf9107029b048b625e89f (diff) | |
Add new LocalTime constructor.
Diffstat (limited to 'src')
| -rw-r--r-- | src/local_time.cc | 16 | ||||
| -rw-r--r-- | src/local_time.h | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/local_time.cc b/src/local_time.cc index b8feb849..3c545279 100644 --- a/src/local_time.cc +++ b/src/local_time.cc @@ -67,6 +67,22 @@ LocalTime::LocalTime (boost::posix_time::ptime t) set_local_time_zone (); } +/** Construct a LocalTime from a boost::posix_time::ptime and a time zone offset */ +LocalTime::LocalTime (boost::posix_time::ptime t, int tz_hour, int tz_minute) +{ + _year = t.date().year (); + _month = t.date().month (); + _day = t.date().day (); + _hour = t.time_of_day().hours (); + _minute = t.time_of_day().minutes (); + _second = t.time_of_day().seconds (); + _millisecond = t.time_of_day().fractional_seconds () / 1000; + DCP_ASSERT (_millisecond < 1000); + + _tz_hour = tz_hour; + _tz_minute = tz_minute; +} + /** Set our UTC offset to be according to the local time zone */ void LocalTime::set_local_time_zone () diff --git a/src/local_time.h b/src/local_time.h index 4a7f3cd8..ac849574 100644 --- a/src/local_time.h +++ b/src/local_time.h @@ -45,6 +45,7 @@ class LocalTime public: LocalTime (); LocalTime (boost::posix_time::ptime); + LocalTime (boost::posix_time::ptime, int tz_hour, int tz_minute); LocalTime (std::string); std::string as_string (bool with_millisecond = false) const; |
