diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:12:59 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:12:59 +0900 |
commit | b8cf34c691623e4ec329053cbbf68522a855882d (patch) | |
tree | 34da08632a99677f6b79ecb65e5b655a5b69a67f /boost/date_time/c_local_time_adjustor.hpp | |
parent | 3fdc3e5ee96dca5b11d1694975a65200787eab86 (diff) | |
download | boost-b8cf34c691623e4ec329053cbbf68522a855882d.tar.gz boost-b8cf34c691623e4ec329053cbbf68522a855882d.tar.bz2 boost-b8cf34c691623e4ec329053cbbf68522a855882d.zip |
Imported Upstream version 1.67.0upstream/1.67.0
Diffstat (limited to 'boost/date_time/c_local_time_adjustor.hpp')
-rw-r--r-- | boost/date_time/c_local_time_adjustor.hpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/boost/date_time/c_local_time_adjustor.hpp b/boost/date_time/c_local_time_adjustor.hpp index aa563122b1..9170aa6687 100644 --- a/boost/date_time/c_local_time_adjustor.hpp +++ b/boost/date_time/c_local_time_adjustor.hpp @@ -17,6 +17,7 @@ #include <boost/throw_exception.hpp> #include <boost/date_time/compiler_config.hpp> #include <boost/date_time/c_time.hpp> +#include <boost/numeric/conversion/cast.hpp> namespace boost { namespace date_time { @@ -42,12 +43,14 @@ namespace date_time { } date_duration_type dd = t.date() - time_t_start_day; time_duration_type td = t.time_of_day(); - std::time_t t2 = static_cast<std::time_t>(dd.days())*86400 + - static_cast<std::time_t>(td.hours())*3600 + - static_cast<std::time_t>(td.minutes())*60 + - td.seconds(); + uint64_t t2 = static_cast<uint64_t>(dd.days())*86400 + + static_cast<uint64_t>(td.hours())*3600 + + static_cast<uint64_t>(td.minutes())*60 + + td.seconds(); + // detect y2038 issue and throw instead of proceed with bad time + std::time_t tv = boost::numeric_cast<std::time_t>(t2); std::tm tms, *tms_ptr; - tms_ptr = c_time::localtime(&t2, &tms); + tms_ptr = c_time::localtime(&tv, &tms); date_type d(static_cast<unsigned short>(tms_ptr->tm_year + 1900), static_cast<unsigned short>(tms_ptr->tm_mon + 1), static_cast<unsigned short>(tms_ptr->tm_mday)); |