diff options
Diffstat (limited to 'src/local_time.cc')
| -rw-r--r-- | src/local_time.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/local_time.cc b/src/local_time.cc index f125b38f..d22e07a7 100644 --- a/src/local_time.cc +++ b/src/local_time.cc @@ -418,3 +418,13 @@ LocalTime::as_utc() const return t; } + +time_t +LocalTime::as_time_t() const +{ + DCP_ASSERT(_year >= 1970); + + auto const since_epoch = boost::gregorian::date(_year, _month, _day) - boost::gregorian::date(1970, boost::gregorian::Jan, 1); + return ((((static_cast<time_t>(since_epoch.days()) * 24) + _hour) * 60) + _minute) * 60 + _second; +} + |
