add new gregorian duration types into posix time

[SVN r23272]
This commit is contained in:
Jeff Garland
2004-06-30 00:11:11 +00:00
parent 396d237e90
commit ca9cd67304
3 changed files with 66 additions and 0 deletions

View File

@@ -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___

View File

@@ -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

View File

@@ -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"