mirror of
https://github.com/boostorg/date_time.git
synced 2026-01-30 07:42:57 +00:00
add new gregorian duration types into posix time
[SVN r23272]
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
#ifndef DATE_DURATION_OPERATORS_HPP___
|
||||
#define DATE_DURATION_OPERATORS_HPP___
|
||||
|
||||
/* Copyright (c) 2004 CrystalClear Software, Inc.
|
||||
* Subject to the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE-1.0 or
|
||||
* http://www.boost.org/LICENSE-1.0)
|
||||
* Author: Jeff Garland, Bart Garst
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#include "boost/date_time/gregorian/greg_duration_types.hpp"
|
||||
#include "boost/date_time/posix_time/ptime.hpp"
|
||||
|
||||
namespace boost {
|
||||
namespace posix_time {
|
||||
|
||||
/*** ptime operator functions ***/
|
||||
// ptime & months
|
||||
ptime operator+(const ptime& t, const boost::gregorian::months& m)
|
||||
{
|
||||
return t + m.get_offset(t.date());
|
||||
}
|
||||
ptime operator+=(ptime& t, const boost::gregorian::months& m)
|
||||
{
|
||||
// get_neg_offset returns a negative duration, so we add
|
||||
return t += m.get_offset(t.date());
|
||||
}
|
||||
ptime operator-(const ptime& t, const boost::gregorian::months& m)
|
||||
{
|
||||
// get_neg_offset returns a negative duration, so we add
|
||||
return t + m.get_neg_offset(t.date());
|
||||
}
|
||||
ptime operator-=(ptime& t, const boost::gregorian::months& m)
|
||||
{
|
||||
return t += m.get_neg_offset(t.date());
|
||||
}
|
||||
// ptime & years
|
||||
ptime operator+(const ptime& t, const boost::gregorian::years& y)
|
||||
{
|
||||
return t + y.get_offset(t.date());
|
||||
}
|
||||
ptime operator+=(ptime& t, const boost::gregorian::years& y)
|
||||
{
|
||||
return t += y.get_offset(t.date());
|
||||
}
|
||||
ptime operator-(const ptime& t, const boost::gregorian::years& y)
|
||||
{
|
||||
// get_neg_offset returns a negative duration, so we add
|
||||
return t + y.get_neg_offset(t.date());
|
||||
}
|
||||
ptime operator-=(ptime& t, const boost::gregorian::years& y)
|
||||
{
|
||||
// get_neg_offset returns a negative duration, so we add
|
||||
return t += y.get_neg_offset(t.date());
|
||||
}
|
||||
|
||||
}} // namespaces
|
||||
|
||||
#endif // DATE_DURATION_OPERATORS_HPP___
|
||||
@@ -13,6 +13,9 @@
|
||||
|
||||
#include "boost/date_time/compiler_config.hpp"
|
||||
#include "boost/date_time/posix_time/ptime.hpp"
|
||||
#if defined(BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES)
|
||||
#include "boost/date_time/posix_time/date_duration_operators.hpp"
|
||||
#endif
|
||||
#if defined(BOOST_DATE_TIME_NO_WSTRING_CONVERSIONS)
|
||||
#include "boost/date_time/posix_time/time_formatters_limited.hpp"
|
||||
#else
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
#include "boost/date_time/time_clock.hpp"
|
||||
#include "boost/date_time/microsec_time_clock.hpp"
|
||||
#include "boost/date_time/posix_time/ptime.hpp"
|
||||
#if defined(BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES)
|
||||
#include "boost/date_time/posix_time/date_duration_operators.hpp"
|
||||
#endif
|
||||
#include "boost/date_time/posix_time/posix_time_duration.hpp"
|
||||
#include "boost/date_time/posix_time/posix_time_system.hpp"
|
||||
#include "boost/date_time/posix_time/time_period.hpp"
|
||||
|
||||
Reference in New Issue
Block a user