Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:35

0001 #ifndef LOCAL_TIME_DATE_DURATION_OPERATORS_HPP___
0002 #define LOCAL_TIME_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/local_time/local_date_time.hpp"
0014 
0015 namespace boost {
0016 namespace local_time {
0017   
0018   /*!@file date_duration_operators.hpp Operators for local_date_time 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 local_date_time. Result will be same 
0027    * day-of-month as local_date_time unless original day was the last day of month.
0028    * see date_time::months_duration for more details */
0029   inline
0030   local_date_time 
0031   operator+(const local_date_time& t, const boost::gregorian::months& m)
0032   {
0033     return t + m.get_offset(t.utc_time().date());
0034   }
0035   
0036   /*! Adds a months object to a local_date_time. Result will be same 
0037    * day-of-month as local_date_time unless original day was the last day of month.
0038    * see date_time::months_duration for more details */
0039   inline
0040   local_date_time 
0041   operator+=(local_date_time& t, const boost::gregorian::months& m)
0042   {
0043     return t += m.get_offset(t.utc_time().date());
0044   }
0045 
0046   /*! Subtracts a months object and a local_date_time. Result will be same 
0047    * day-of-month as local_date_time unless original day was the last day of month.
0048    * see date_time::months_duration for more details */
0049   inline
0050   local_date_time 
0051   operator-(const local_date_time& t, const boost::gregorian::months& m)
0052   {
0053     // get_neg_offset returns a negative duration, so we add
0054     return t + m.get_neg_offset(t.utc_time().date());
0055   }
0056   
0057   /*! Subtracts a months object from a local_date_time. Result will be same 
0058    * day-of-month as local_date_time unless original day was the last day of month.
0059    * see date_time::months_duration for more details */
0060   inline
0061   local_date_time 
0062   operator-=(local_date_time& t, const boost::gregorian::months& m)
0063   {
0064     // get_neg_offset returns a negative duration, so we add
0065     return t += m.get_neg_offset(t.utc_time().date());
0066   }
0067 
0068   // local_date_time & years
0069   
0070   /*! Adds a years object and a local_date_time. Result will be same 
0071    * month and day-of-month as local_date_time unless original day was the 
0072    * last day of month. see date_time::years_duration for more details */
0073   inline
0074   local_date_time 
0075   operator+(const local_date_time& t, const boost::gregorian::years& y)
0076   {
0077     return t + y.get_offset(t.utc_time().date());
0078   }
0079 
0080   /*! Adds a years object to a local_date_time. Result will be same 
0081    * month and day-of-month as local_date_time unless original day was the 
0082    * last day of month. see date_time::years_duration for more details */
0083   inline
0084   local_date_time 
0085   operator+=(local_date_time& t, const boost::gregorian::years& y)
0086   {
0087     return t += y.get_offset(t.utc_time().date());
0088   }
0089 
0090   /*! Subtracts a years object and a local_date_time. Result will be same 
0091    * month and day-of-month as local_date_time unless original day was the 
0092    * last day of month. see date_time::years_duration for more details */
0093   inline
0094   local_date_time 
0095   operator-(const local_date_time& 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.utc_time().date());
0099   }
0100 
0101   /*! Subtracts a years object from a local_date_time. Result will be same 
0102    * month and day-of-month as local_date_time unless original day was the 
0103    * last day of month. see date_time::years_duration for more details */
0104   inline
0105   local_date_time 
0106   operator-=(local_date_time& 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.utc_time().date());
0110   }
0111 
0112 
0113 }} // namespaces
0114 
0115 #endif // LOCAL_TIME_DATE_DURATION_OPERATORS_HPP___