|
||||
File indexing completed on 2025-01-18 09:30:36
0001 #ifndef DATE_DURATION_OPERATORS_HPP___ 0002 #define DATE_DURATION_OPERATORS_HPP___ 0003 0004 /* Copyright (c) 2004 CrystalClear Software, Inc. 0005 * Subject to the Boost Software License, Version 1.0. 0006 * (See accompanying file LICENSE_1_0.txt or 0007 * http://www.boost.org/LICENSE_1_0.txt) 0008 * Author: Jeff Garland, Bart Garst 0009 * $Date$ 0010 */ 0011 0012 #include "boost/date_time/gregorian/greg_duration_types.hpp" 0013 #include "boost/date_time/posix_time/ptime.hpp" 0014 0015 namespace boost { 0016 namespace posix_time { 0017 0018 /*!@file date_duration_operators.hpp Operators for ptime and 0019 * optional gregorian types. Operators use snap-to-end-of-month behavior. 0020 * Further details on this behavior can be found in reference for 0021 * date_time/date_duration_types.hpp and documentation for 0022 * month and year iterators. 0023 */ 0024 0025 0026 /*! Adds a months object and a ptime. Result will be same 0027 * day-of-month as ptime unless original day was the last day of month. 0028 * see date_time::months_duration for more details */ 0029 inline BOOST_CXX14_CONSTEXPR 0030 ptime 0031 operator+(const ptime& t, const boost::gregorian::months& m) 0032 { 0033 return t + m.get_offset(t.date()); 0034 } 0035 0036 /*! Adds a months object to a ptime. Result will be same 0037 * day-of-month as ptime unless original day was the last day of month. 0038 * see date_time::months_duration for more details */ 0039 inline BOOST_CXX14_CONSTEXPR 0040 ptime 0041 operator+=(ptime& t, const boost::gregorian::months& m) 0042 { 0043 // get_neg_offset returns a negative duration, so we add 0044 return t += m.get_offset(t.date()); 0045 } 0046 0047 /*! Subtracts a months object and a ptime. Result will be same 0048 * day-of-month as ptime unless original day was the last day of month. 0049 * see date_time::months_duration for more details */ 0050 inline BOOST_CXX14_CONSTEXPR 0051 ptime 0052 operator-(const ptime& t, const boost::gregorian::months& m) 0053 { 0054 // get_neg_offset returns a negative duration, so we add 0055 return t + m.get_neg_offset(t.date()); 0056 } 0057 0058 /*! Subtracts a months object from a ptime. Result will be same 0059 * day-of-month as ptime unless original day was the last day of month. 0060 * see date_time::months_duration for more details */ 0061 inline BOOST_CXX14_CONSTEXPR 0062 ptime 0063 operator-=(ptime& t, const boost::gregorian::months& m) 0064 { 0065 return t += m.get_neg_offset(t.date()); 0066 } 0067 0068 // ptime & years 0069 0070 /*! Adds a years object and a ptime. Result will be same 0071 * month and day-of-month as ptime unless original day was the 0072 * last day of month. see date_time::years_duration for more details */ 0073 inline BOOST_CXX14_CONSTEXPR 0074 ptime 0075 operator+(const ptime& t, const boost::gregorian::years& y) 0076 { 0077 return t + y.get_offset(t.date()); 0078 } 0079 0080 /*! Adds a years object to a ptime. Result will be same 0081 * month and day-of-month as ptime unless original day was the 0082 * last day of month. see date_time::years_duration for more details */ 0083 inline BOOST_CXX14_CONSTEXPR 0084 ptime 0085 operator+=(ptime& t, const boost::gregorian::years& y) 0086 { 0087 return t += y.get_offset(t.date()); 0088 } 0089 0090 /*! Subtracts a years object and a ptime. Result will be same 0091 * month and day-of-month as ptime unless original day was the 0092 * last day of month. see date_time::years_duration for more details */ 0093 inline BOOST_CXX14_CONSTEXPR 0094 ptime 0095 operator-(const ptime& t, const boost::gregorian::years& y) 0096 { 0097 // get_neg_offset returns a negative duration, so we add 0098 return t + y.get_neg_offset(t.date()); 0099 } 0100 0101 /*! Subtracts a years object from a ptime. Result will be same 0102 * month and day-of-month as ptime unless original day was the 0103 * last day of month. see date_time::years_duration for more details */ 0104 inline BOOST_CXX14_CONSTEXPR 0105 ptime 0106 operator-=(ptime& t, const boost::gregorian::years& y) 0107 { 0108 // get_neg_offset returns a negative duration, so we add 0109 return t += y.get_neg_offset(t.date()); 0110 } 0111 0112 }} // namespaces 0113 0114 #endif // DATE_DURATION_OPERATORS_HPP___
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |