Opened 13 years ago
Closed 5 years ago
#3487 closed Bugs (fixed)
using 32bit seconds type in boost::posix_time::time_duration is leading to year 2038 problem
Reported by: | Owned by: | James E. King, III | |
---|---|---|---|
Milestone: | Boost 1.67.0 | Component: | date_time |
Version: | Boost 1.46.0 | Severity: | Showstopper |
Keywords: | Cc: |
Description
In the template class time_resolution_traits the dafault seconds type is boost::int32_t. This type is also used in the posix_time::time_duration class.
When using posix_time::from_time_t() the time_t value (normally a 64bit type on modern systems) is casted into an boost::int32_t value. So time_t values describing times after year 2038 will not processed correctly.
Is it possible to use boost::int64_t as default seconds type?
Change History (5)
comment:1 by , 12 years ago
Milestone: | Boost 1.41.0 → Boost-1.46.0 |
---|---|
Severity: | Problem → Showstopper |
Version: | Boost 1.40.0 → Boost 1.46.0 |
comment:3 by , 11 years ago
This also makes it impossible to use condition::timed_wait(lock_type& m,boost::xtime const& wait_until).
The conversion to time_duration causes an overflow. Apart from that, I've noticed that xtime_get() and xtime_cmp() are broken too (return int).
comment:4 by , 5 years ago
Milestone: | Boost 1.46.0 → Boost 1.67.0 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
This was fixed in github issue 56:
comment:5 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fix merged to master; resolved.
I just stumbled over the same thing when trying to use a boost::posix_time::microseconds() which during the way to a 64bit value will be garbled by calculations around time_resolution_traits because the integer argument is int32_t per default.
I would recommend that you take from the first traits parameter (that is used with the structs time_resolution_traits_adapted64_impl) in date_time/time_resolution_traits.hpp class time_resolution traits instead of
typename v_type = boost::int32_t
you better use
typename v_type = typename frac_sec_type::int_type
since in the end the _res structs are correctly defined as
typedef time_resolution_traits<time_resolution_traits_adapted64_impl, nano, 1000000000, 9 > nano_res;
which would make the 64bit value properly appear.
Otherwise this all is unusable for us since we work with microseconds and nonoseconds since epoch timestamps on wire.