Skip to content

Commit

Permalink
Added casts of date/time components to uint32_t to silence MSVC warni…
Browse files Browse the repository at this point in the history
…ngs.

The date and time values handled by Boost.Log are not supposed to exceed
uint32_t range most of the time. The possible exceptions are date/time
durations, which are currently handled by the same code path as the
date/time points. If durations become an issue, the code should be
reworked so that durations are handled separately by the formater.
Converting all of the implementation to uint64_t won't help since the
decomposed date/time is further converted to std::tm, which is unlikely to
have uint64_t-wide components.
  • Loading branch information
Lastique committed Sep 2, 2017
1 parent 8c4e805 commit 0b4ce57
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions include/boost/log/support/date_time.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ inline void decompose_date(DateT const& d, boost::log::aux::decomposed_time_wrap
{
typedef typename DateT::ymd_type ymd_type;
ymd_type ymd = d.year_month_day();
v.year = ymd.year;
v.month = ymd.month;
v.day = ymd.day;
v.year = static_cast< uint32_t >(ymd.year);
v.month = static_cast< uint32_t >(ymd.month);
v.day = static_cast< uint32_t >(ymd.day);
}

template< typename TimeDurationT, typename ValueT >
inline void decompose_time_of_day(TimeDurationT const& tod, boost::log::aux::decomposed_time_wrapper< ValueT >& v)
{
v.hours = tod.hours();
v.minutes = tod.minutes();
v.seconds = tod.seconds();
v.hours = static_cast< uint32_t >(tod.hours());
v.minutes = static_cast< uint32_t >(tod.minutes());
v.seconds = static_cast< uint32_t >(tod.seconds());

typedef typename TimeDurationT::traits_type traits_type;
enum
Expand Down Expand Up @@ -96,10 +96,10 @@ inline void decompose_date_duration(DateDurationT const& dur, boost::log::aux::d
if (dur.is_negative())
{
v.negative = true;
v.day = (-dur).days();
v.day = static_cast< uint32_t >((-dur).days());
}
else
v.day = dur.days();
v.day = static_cast< uint32_t >(dur.days());
}

template< typename TimeT, typename ValueT >
Expand Down

0 comments on commit 0b4ce57

Please sign in to comment.