Ticket #4057: date_duration_operators_acpreble_20100401.patch

File date_duration_operators_acpreble_20100401.patch, 1.9 KB (added by adam.preble@…, 13 years ago)

Apply to posix_time/date_duration_operators.hpp

Line 
1*** /home/rocko/tmp/boost_changes/date_duration_operators.hpp Tue Mar 30 19:12:34 2010
2--- date_duration_operators.hpp Thu Apr 1 17:43:59 2010
3***************
4*** 5,11 ****
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: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $
10 */
11
12--- 5,11 ----
13 * Subject to the Boost Software License, Version 1.0.
14 * (See accompanying file LICENSE_1_0.txt or
15 * http://www.boost.org/LICENSE_1_0.txt)
16! * Author: Jeff Garland, Bart Garst, Adam Preble
17 * $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $
18 */
19
20***************
21*** 23,28 ****
22--- 23,66 ----
23 */
24
25
26+ // ptime & days
27+
28+ /*! Adds a days object and a ptime. Result will be same time of day. */
29+ inline
30+ ptime
31+ operator+(const ptime& t, const boost::gregorian::days& d)
32+ {
33+ return ptime(t.date() + d, t.time_of_day());
34+ }
35+
36+ /*! Adds a days object to a ptime. Result will be same time of day. */
37+ inline
38+ ptime
39+ operator+=(ptime& t, const boost::gregorian::days& d)
40+ {
41+ t = ptime(t.date() + d, t.time_of_day());
42+ return t;
43+ }
44+
45+ /*! Subtracts a days object and a ptime. Result will be same time of day. */
46+ inline
47+ ptime
48+ operator-(const ptime& t, const boost::gregorian::days& d)
49+ {
50+ return ptime(t.date() - d, t.time_of_day());
51+ }
52+
53+ /*! Subtracts a days object from a ptime. Result will be same time of day. */
54+ inline
55+ ptime
56+ operator-=(ptime& t, const boost::gregorian::days& d)
57+ {
58+ t = ptime(t.date() - d, t.time_of_day());
59+ return t;
60+ }
61+
62+ // ptime & months
63+
64 /*! Adds a months object and a ptime. Result will be same
65 * day-of-month as ptime unless original day was the last day of month.
66 * see date_time::months_duration for more details */