diff --git a/boost/date_time/microsec_time_clock.hpp b/boost/date_time/microsec_time_clock.hpp index bffc741..9c19c6d 100644 --- a/boost/date_time/microsec_time_clock.hpp +++ b/boost/date_time/microsec_time_clock.hpp @@ -104,9 +104,9 @@ namespace date_time { //The following line will adjust the fractional second tick in terms //of the current time system. For example, if the time system - //doesn't support fractional seconds then res_adjust returns 0 + //doesn't support fractional seconds then res_adjust is 0 //and all the fractional seconds return 0. - int adjust = static_cast< int >(resolution_traits_type::res_adjust() / 1000000); + int adjust = static_cast< int >(resolution_traits_type::res_adjust / 1000000); time_duration_type td(static_cast< typename time_duration_type::hour_type >(curr_ptr->tm_hour), static_cast< typename time_duration_type::min_type >(curr_ptr->tm_min), diff --git a/boost/date_time/time_duration.hpp b/boost/date_time/time_duration.hpp index 2b8870d..5cb4fce 100644 --- a/boost/date_time/time_duration.hpp +++ b/boost/date_time/time_duration.hpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -74,7 +75,7 @@ namespace date_time { //! Return the number of ticks in a second static tick_type ticks_per_second() { - return rep_type::res_adjust(); + return rep_type::res_adjust; } //! Provide the resolution of this duration type static time_resolutions resolution() @@ -267,8 +268,10 @@ namespace date_time { public: typedef typename base_duration::traits_type traits_type; explicit subsecond_duration(boost::int64_t ss) : - base_duration(0,0,0,ss*traits_type::res_adjust()/frac_of_second) - {} + base_duration(0,0,0,ss * (traits_type::res_adjust / frac_of_second)) + { + BOOST_STATIC_ASSERT((traits_type::res_adjust % frac_of_second) == 0); + } }; diff --git a/boost/date_time/time_resolution_traits.hpp b/boost/date_time/time_resolution_traits.hpp index 37785d0..875dc07 100644 --- a/boost/date_time/time_resolution_traits.hpp +++ b/boost/date_time/time_resolution_traits.hpp @@ -79,6 +79,8 @@ namespace date_time { typedef v_type min_type; typedef v_type sec_type; + static const fractional_seconds_type res_adjust = resolution_adjust; + // bring in function from frac_sec_type traits structs static fractional_seconds_type as_number(impl_type i) { @@ -104,10 +106,7 @@ namespace date_time { { return frac_digits; } - static fractional_seconds_type res_adjust() - { - return resolution_adjust; - } + //! Any negative argument results in a negative tick_count static tick_type to_tick_count(hour_type hours, min_type minutes, @@ -122,12 +121,12 @@ namespace date_time { fs = absolute_value(fs); return (((((fractional_seconds_type(hours)*3600) + (fractional_seconds_type(minutes)*60) - + seconds)*res_adjust()) + fs) * -1); + + seconds)*res_adjust) + fs) * -1); } return (((fractional_seconds_type(hours)*3600) + (fractional_seconds_type(minutes)*60) - + seconds)*res_adjust()) + fs; + + seconds)*res_adjust) + fs; } }; diff --git a/boost/date_time/time_system_counted.hpp b/boost/date_time/time_system_counted.hpp index e5ed20b..169f9f6 100644 --- a/boost/date_time/time_system_counted.hpp +++ b/boost/date_time/time_system_counted.hpp @@ -88,7 +88,7 @@ namespace date_time { static int_type frac_sec_per_day() { int_type seconds_per_day = 60*60*24; - int_type fractional_sec_per_sec(resolution_traits::res_adjust()); + int_type fractional_sec_per_sec(resolution_traits::res_adjust); return seconds_per_day*fractional_sec_per_sec; } bool is_pos_infinity()const