1 /*-----------------------------------------------------------------------------+
2 Copyright (c) 2008-2009: Joachim Faulhaber
3 +------------------------------------------------------------------------------+
4 Distributed under the Boost Software License, Version 1.0.
5 (See accompanying file LICENCE.txt or copy at
6 http://www.boost.org/LICENSE_1_0.txt)
7 +-----------------------------------------------------------------------------*/
8 #ifndef BOOST_ICL_GREGORIAN_DATE_HPP_JOFA_080416
9 #define BOOST_ICL_GREGORIAN_DATE_HPP_JOFA_080416
11 #include <boost/icl/detail/boost_config.hpp>
12 #include <boost/detail/workaround.hpp>
16 #pragma warning(disable:4100) // unreferenced formal parameter
17 #pragma warning(disable:4127) // conditional expression is constant
18 #pragma warning(disable:4244) // 'argument' : conversion from 'int' to 'unsigned short', possible loss of data
19 #pragma warning(disable:4702) // boost\lexical_cast.hpp(1159) : warning C4702: unreachable code
20 #pragma warning(disable:4996) // Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
27 #include <boost/date_time/gregorian/gregorian.hpp>
33 #include <boost/icl/type_traits/identity_element.hpp>
34 #include <boost/icl/type_traits/is_discrete.hpp>
35 #include <boost/icl/type_traits/difference_type_of.hpp>
36 #include <boost/icl/type_traits/size_type_of.hpp>
38 namespace boost{namespace icl
40 template<> struct is_discrete<boost::gregorian::date>
42 typedef is_discrete type;
43 BOOST_STATIC_CONSTANT(bool, value = true);
47 inline boost::gregorian::date identity_element<boost::gregorian::date>::value()
49 return boost::gregorian::date(boost::gregorian::min_date_time);
53 struct identity_element<boost::gregorian::date_duration>
55 static boost::gregorian::date_duration value()
57 return boost::gregorian::date(boost::gregorian::min_date_time)
58 - boost::gregorian::date(boost::gregorian::min_date_time);
63 struct has_difference<boost::gregorian::date>
65 typedef has_difference type;
66 BOOST_STATIC_CONSTANT(bool, value = true);
70 struct difference_type_of<boost::gregorian::date>
71 { typedef boost::gregorian::date_duration type; };
74 struct size_type_of<boost::gregorian::date>
75 { typedef boost::gregorian::date_duration type; };
79 // ------------------------------------------------------------------------
80 inline boost::gregorian::date operator ++(boost::gregorian::date& x)
82 return x += boost::gregorian::date::duration_type::unit();
85 inline boost::gregorian::date operator --(boost::gregorian::date& x)
87 return x -= boost::gregorian::date::duration_type::unit();
90 // ------------------------------------------------------------------------
91 template<> struct is_discrete<boost::gregorian::date_duration>
93 typedef is_discrete type;
94 BOOST_STATIC_CONSTANT(bool, value = true);
98 struct has_difference<boost::gregorian::date_duration>
100 typedef has_difference type;
101 BOOST_STATIC_CONSTANT(bool, value = true);
105 struct size_type_of<boost::gregorian::date_duration>
107 typedef boost::gregorian::date_duration type;
110 inline boost::gregorian::date_duration operator ++(boost::gregorian::date_duration& x)
112 return x += boost::gregorian::date::duration_type::unit();
115 inline boost::gregorian::date_duration operator --(boost::gregorian::date_duration& x)
117 return x -= boost::gregorian::date::duration_type::unit();
120 // ------------------------------------------------------------------------
123 }} // namespace icl boost