BVB Source Codes

mars Show date_duration_operators.hpp Source code

Return Download mars: download date_duration_operators.hpp Source code - Download mars Source code - Type:.hpp
  1. #ifndef DATE_DURATION_OPERATORS_HPP___
  2. #define DATE_DURATION_OPERATORS_HPP___
  3.                                                                                
  4. /* Copyright (c) 2004 CrystalClear Software, Inc.
  5.  * Subject to the Boost Software License, Version 1.0.
  6.  * (See accompanying file LICENSE_1_0.txt or
  7.  * http://www.boost.org/LICENSE_1_0.txt)
  8.  * Author: Jeff Garland, Bart Garst
  9.  * $Date$
  10.  */
  11.  
  12. #include "boost/date_time/gregorian/greg_duration_types.hpp"
  13. #include "boost/date_time/posix_time/ptime.hpp"
  14.  
  15. namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost {
  16. namespace posix_time {
  17.  
  18.   /*!@file date_duration_operators.hpp Operators for ptime and
  19.    * optional gregorian types. Operators use snap-to-end-of-month behavior.
  20.    * Further details on this behavior can be found in reference for
  21.    * date_time/date_duration_types.hpp and documentation for
  22.    * month and year iterators.
  23.    */
  24.  
  25.  
  26.   /*! Adds a months object and a ptime. Result will be same
  27.    * day-of-month as ptime unless original day was the last day of month.
  28.    * see date_time::months_duration for more details */
  29.   inline
  30.   ptime
  31.   operator+(const ptime& t, const mars_boost::gregorian::months& m)
  32.   {
  33.     return t + m.get_offset(t.date());
  34.   }
  35.  
  36.   /*! Adds a months object to a ptime. Result will be same
  37.    * day-of-month as ptime unless original day was the last day of month.
  38.    * see date_time::months_duration for more details */
  39.   inline
  40.   ptime
  41.   operator+=(ptime& t, const mars_boost::gregorian::months& m)
  42.   {
  43.     // get_neg_offset returns a negative duration, so we add
  44.     return t += m.get_offset(t.date());
  45.   }
  46.  
  47.   /*! Subtracts a months object and a ptime. Result will be same
  48.    * day-of-month as ptime unless original day was the last day of month.
  49.    * see date_time::months_duration for more details */
  50.   inline
  51.   ptime
  52.   operator-(const ptime& t, const mars_boost::gregorian::months& m)
  53.   {
  54.     // get_neg_offset returns a negative duration, so we add
  55.     return t + m.get_neg_offset(t.date());
  56.   }
  57.  
  58.   /*! Subtracts a months object from a ptime. Result will be same
  59.    * day-of-month as ptime unless original day was the last day of month.
  60.    * see date_time::months_duration for more details */
  61.   inline
  62.   ptime
  63.   operator-=(ptime& t, const mars_boost::gregorian::months& m)
  64.   {
  65.     return t += m.get_neg_offset(t.date());
  66.   }
  67.  
  68.   // ptime & years
  69.  
  70.   /*! Adds a years object and a ptime. Result will be same
  71.    * month and day-of-month as ptime unless original day was the
  72.    * last day of month. see date_time::years_duration for more details */
  73.   inline
  74.   ptime
  75.   operator+(const ptime& t, const mars_boost::gregorian::years& y)
  76.   {
  77.     return t + y.get_offset(t.date());
  78.   }
  79.  
  80.   /*! Adds a years object to a ptime. Result will be same
  81.    * month and day-of-month as ptime unless original day was the
  82.    * last day of month. see date_time::years_duration for more details */
  83.   inline
  84.   ptime
  85.   operator+=(ptime& t, const mars_boost::gregorian::years& y)
  86.   {
  87.     return t += y.get_offset(t.date());
  88.   }
  89.  
  90.   /*! Subtracts a years object and a ptime. Result will be same
  91.    * month and day-of-month as ptime unless original day was the
  92.    * last day of month. see date_time::years_duration for more details */
  93.   inline
  94.   ptime
  95.   operator-(const ptime& t, const mars_boost::gregorian::years& y)
  96.   {
  97.     // get_neg_offset returns a negative duration, so we add
  98.     return t + y.get_neg_offset(t.date());
  99.   }
  100.  
  101.   /*! Subtracts a years object from a ptime. Result will be same
  102.    * month and day-of-month as ptime unless original day was the
  103.    * last day of month. see date_time::years_duration for more details */
  104.   inline
  105.   ptime
  106.   operator-=(ptime& t, const mars_boost::gregorian::years& y)
  107.   {
  108.     // get_neg_offset returns a negative duration, so we add
  109.     return t += y.get_neg_offset(t.date());
  110.   }
  111.  
  112. }} // namespaces
  113.  
  114. #endif // DATE_DURATION_OPERATORS_HPP___
  115.  
downloaddate_duration_operators.hpp Source code - Download mars Source code
Related Source Codes/Software:
Hero - Elegant transition library for iOS & tvOS 2017-06-09
deep-photo-styletransfer - Code and data for paper "Deep Photo Style Transfer... 2017-06-09
mastodon - A GNU Social-compatible microblogging server ... 2017-06-09
plyr - A simple HTML5, YouTube and Vimeo player ... 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
Public-APIs - 2017-06-09
lottie-ios - An iOS library to natively render After Effects ve... 2017-06-09
Awesome-Hacking - A collection of various awesome lists for hackers,... 2017-06-09
algorithms - Minimal examples of data structures and algorithms... 2017-06-10
lectures - Oxford Deep NLP 2017 course 2017-06-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top