1 #ifndef POSIX_TIME_DURATION_HPP___
2 #define POSIX_TIME_DURATION_HPP___
3 
4 /* Copyright (c) 2002,2003, 2020 CrystalClear Software, Inc.
5  * Use, modification and distribution is subject to the
6  * Boost Software License, Version 1.0. (See accompanying
7  * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
8  * Author: Jeff Garland
9  * $Date$
10  */
11 
12 #include <boost/core/enable_if.hpp>
13 #include <boost/date_time/compiler_config.hpp>
14 #include <boost/date_time/posix_time/posix_time_config.hpp>
15 #include <boost/numeric/conversion/cast.hpp>
16 #include <boost/type_traits/is_integral.hpp>
17 
18 namespace boost {
19 namespace posix_time {
20 
21   //! Allows expression of durations as an hour count
22   //! The argument must be an integral type
23   /*! \ingroup time_basics
24    */
25   class BOOST_SYMBOL_VISIBLE hours : public time_duration
26   {
27   public:
28       template <typename T>
hours(T const & h,typename boost::enable_if<boost::is_integral<T>,void>::type * =BOOST_DATE_TIME_NULLPTR)29       BOOST_CXX14_CONSTEXPR explicit hours(T const& h,
30           typename boost::enable_if<boost::is_integral<T>, void>::type* = BOOST_DATE_TIME_NULLPTR) :
31       time_duration(numeric_cast<hour_type>(h), 0, 0)
32     {}
33   };
34 
35   //! Allows expression of durations as a minute count
36   //! The argument must be an integral type
37   /*! \ingroup time_basics
38    */
39   class BOOST_SYMBOL_VISIBLE minutes : public time_duration
40   {
41   public:
42       template <typename T>
minutes(T const & m,typename boost::enable_if<boost::is_integral<T>,void>::type * =BOOST_DATE_TIME_NULLPTR)43       BOOST_CXX14_CONSTEXPR explicit minutes(T const& m,
44           typename boost::enable_if<boost::is_integral<T>, void>::type* = BOOST_DATE_TIME_NULLPTR) :
45       time_duration(0, numeric_cast<min_type>(m),0)
46     {}
47   };
48 
49   //! Allows expression of durations as a seconds count
50   //! The argument must be an integral type
51   /*! \ingroup time_basics
52    */
53   class BOOST_SYMBOL_VISIBLE seconds : public time_duration
54   {
55   public:
56       template <typename T>
seconds(T const & s,typename boost::enable_if<boost::is_integral<T>,void>::type * =BOOST_DATE_TIME_NULLPTR)57       BOOST_CXX14_CONSTEXPR explicit seconds(T const& s,
58           typename boost::enable_if<boost::is_integral<T>, void>::type* = BOOST_DATE_TIME_NULLPTR) :
59       time_duration(0,0, numeric_cast<sec_type>(s))
60     {}
61   };
62 
63 
64   //! Allows expression of durations as milli seconds
65   /*! \ingroup time_basics
66    */
67   typedef date_time::subsecond_duration<time_duration,1000> millisec;
68   typedef date_time::subsecond_duration<time_duration,1000> milliseconds;
69 
70   //! Allows expression of durations as micro seconds
71   /*! \ingroup time_basics
72    */
73   typedef date_time::subsecond_duration<time_duration,1000000> microsec;
74   typedef date_time::subsecond_duration<time_duration,1000000> microseconds;
75 
76   //This is probably not needed anymore...
77 #if defined(BOOST_DATE_TIME_HAS_NANOSECONDS)
78 
79   //! Allows expression of durations as nano seconds
80   /*! \ingroup time_basics
81    */
82   typedef date_time::subsecond_duration<time_duration,1000000000> nanosec;
83   typedef date_time::subsecond_duration<time_duration,1000000000> nanoseconds;
84 
85 #endif
86 
87 } }//namespace posix_time
88 
89 
90 #endif
91 
92