blob: 883299c610c5c91dfb11f7f8a7a2984acf0a803a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
/*-----------------------------------------------------------------------------+
Copyright (c) 2008-2009: Joachim Faulhaber
+------------------------------------------------------------------------------+
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENCE.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
+-----------------------------------------------------------------------------*/
#ifndef BOOST_ICL_GREGORIAN_DATE_HPP_JOFA_080416
#define BOOST_ICL_GREGORIAN_DATE_HPP_JOFA_080416
#include <boost/icl/detail/boost_config.hpp>
#include <boost/detail/workaround.hpp>
#ifdef BOOST_MSVC
#pragma warning(push)
#pragma warning(disable:4100) // unreferenced formal parameter
#pragma warning(disable:4127) // conditional expression is constant
#pragma warning(disable:4244) // 'argument' : conversion from 'int' to 'unsigned short', possible loss of data
#pragma warning(disable:4702) // boost\lexical_cast.hpp(1159) : warning C4702: unreachable code
#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'
#endif
#include <stdio.h>
#include <string>
#include <sstream>
#include <iostream>
#include <boost/date_time/gregorian/gregorian.hpp>
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
#include <boost/icl/type_traits/identity_element.hpp>
#include <boost/icl/type_traits/is_discrete.hpp>
#include <boost/icl/type_traits/difference_type_of.hpp>
#include <boost/icl/type_traits/size_type_of.hpp>
namespace boost{namespace icl
{
template<> struct is_discrete<boost::gregorian::date>
{
typedef is_discrete type;
BOOST_STATIC_CONSTANT(bool, value = true);
};
template<>
inline boost::gregorian::date identity_element<boost::gregorian::date>::value()
{
return boost::gregorian::date(boost::gregorian::min_date_time);
}
template<>
struct identity_element<boost::gregorian::date_duration>
{
static boost::gregorian::date_duration value()
{
return boost::gregorian::date(boost::gregorian::min_date_time)
- boost::gregorian::date(boost::gregorian::min_date_time);
}
};
template<>
struct has_difference<boost::gregorian::date>
{
typedef has_difference type;
BOOST_STATIC_CONSTANT(bool, value = true);
};
template<>
struct difference_type_of<boost::gregorian::date>
{ typedef boost::gregorian::date_duration type; };
template<>
struct size_type_of<boost::gregorian::date>
{ typedef boost::gregorian::date_duration type; };
// ------------------------------------------------------------------------
boost::gregorian::date operator ++(boost::gregorian::date& x)
{
return x += boost::gregorian::date::duration_type::unit();
}
boost::gregorian::date operator --(boost::gregorian::date& x)
{
return x -= boost::gregorian::date::duration_type::unit();
}
// ------------------------------------------------------------------------
template<> struct is_discrete<boost::gregorian::date_duration>
{
typedef is_discrete type;
BOOST_STATIC_CONSTANT(bool, value = true);
};
template<>
struct has_difference<boost::gregorian::date_duration>
{
typedef has_difference type;
BOOST_STATIC_CONSTANT(bool, value = true);
};
template<>
struct size_type_of<boost::gregorian::date_duration>
{
typedef boost::gregorian::date_duration type;
};
boost::gregorian::date_duration operator ++(boost::gregorian::date_duration& x)
{
return x += boost::gregorian::date::duration_type::unit();
}
boost::gregorian::date_duration operator --(boost::gregorian::date_duration& x)
{
return x -= boost::gregorian::date::duration_type::unit();
}
// ------------------------------------------------------------------------
}} // namespace icl boost
#endif
|