|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r53678 - branches/release/boost/date_time
From: andrey.semashev_at_[hidden]
Date: 2009-06-06 07:25:56
Author: andysem
Date: 2009-06-06 07:25:55 EDT (Sat, 06 Jun 2009)
New Revision: 53678
URL: http://svn.boost.org/trac/boost/changeset/53678
Log:
Fixes #2824.
Text files modified:
branches/release/boost/date_time/time_resolution_traits.hpp | 52 +++++++++++++++++++++------------------
1 files changed, 28 insertions(+), 24 deletions(-)
Modified: branches/release/boost/date_time/time_resolution_traits.hpp
==============================================================================
--- branches/release/boost/date_time/time_resolution_traits.hpp (original)
+++ branches/release/boost/date_time/time_resolution_traits.hpp 2009-06-06 07:25:55 EDT (Sat, 06 Jun 2009)
@@ -2,7 +2,7 @@
#define DATE_TIME_TIME_RESOLUTION_TRAITS_HPP
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
- * Use, modification and distribution is subject to the
+ * Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
@@ -10,18 +10,19 @@
*/
-#include "boost/date_time/time_defs.hpp"
-#include "boost/date_time/int_adapter.hpp"
-#include "boost/cstdint.hpp"
+#include <boost/cstdint.hpp>
+#include <boost/date_time/time_defs.hpp>
+#include <boost/date_time/int_adapter.hpp>
+#include <boost/date_time/compiler_config.hpp>
namespace boost {
namespace date_time {
//! Simple function to calculate absolute value of a numeric type
- template <typename T>
- // JDG [7/6/02 made a template],
+ template <typename T>
+ // JDG [7/6/02 made a template],
// moved here from time_duration.hpp 2003-Sept-4.
- inline T absolute_value(T x)
+ inline T absolute_value(T x)
{
return x < 0 ? -x : x;
}
@@ -58,16 +59,16 @@
//! Used to determine if implemented type is int_adapter or int
static bool is_adapted() { return true;}
};
-
- template<typename frac_sec_type,
+
+ template<typename frac_sec_type,
time_resolutions res,
#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
- boost::int64_t resolution_adjust,
+ boost::int64_t resolution_adjust,
#else
- typename frac_sec_type::int_type resolution_adjust,
+ typename frac_sec_type::int_type resolution_adjust,
#endif
- unsigned short frac_digits,
- typename v_type = boost::int32_t >
+ unsigned short frac_digits,
+ typename v_type = boost::int32_t >
class time_resolution_traits {
public:
typedef typename frac_sec_type::int_type fractional_seconds_type;
@@ -77,9 +78,9 @@
typedef v_type hour_type;
typedef v_type min_type;
typedef v_type sec_type;
-
+
// bring in function from frac_sec_type traits structs
- static typename frac_sec_type::int_type as_number(typename frac_sec_type::impl_type i)
+ static fractional_seconds_type as_number(impl_type i)
{
return frac_sec_type::as_number(i);
}
@@ -87,11 +88,14 @@
{
return frac_sec_type::is_adapted();
}
-
+
//Would like this to be frac_sec_type, but some compilers complain
- BOOST_STATIC_CONSTANT(int, ticks_per_second = resolution_adjust);
- // static const boost::int32_t ticks_per_second = resolution_adjust;
-
+#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
+ BOOST_STATIC_CONSTANT(boost::int64_t, ticks_per_second = resolution_adjust);
+#else
+ BOOST_STATIC_CONSTANT(fractional_seconds_type, ticks_per_second = resolution_adjust);
+#endif
+
static time_resolutions resolution()
{
return res;
@@ -116,16 +120,16 @@
minutes = absolute_value(minutes);
seconds = absolute_value(seconds);
fs = absolute_value(fs);
- return (((((fractional_seconds_type(hours)*3600)
- + (fractional_seconds_type(minutes)*60)
+ return (((((fractional_seconds_type(hours)*3600)
+ + (fractional_seconds_type(minutes)*60)
+ seconds)*res_adjust()) + fs) * -1);
}
- return (((fractional_seconds_type(hours)*3600)
- + (fractional_seconds_type(minutes)*60)
+ return (((fractional_seconds_type(hours)*3600)
+ + (fractional_seconds_type(minutes)*60)
+ seconds)*res_adjust()) + fs;
}
-
+
};
typedef time_resolution_traits<time_resolution_traits_adapted32_impl, milli, 1000, 3 > milli_res;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk