![]() |
Home | Libraries | People | FAQ | More |
boost::date_time::period — Provides generalized period type useful in date-time systems.
// In header: <boost/date_time/period.hpp> template<typename point_rep, typename duration_rep> class period : private { public: // types typedef point_rep ; typedef ; // construct/copy/destruct (point_rep, point_rep); (point_rep, ); // public member functions BOOST_CXX14_CONSTEXPR point_rep () ; BOOST_CXX14_CONSTEXPR point_rep () ; BOOST_CXX14_CONSTEXPR point_rep () ; BOOST_CXX14_CONSTEXPR () ; BOOST_CXX14_CONSTEXPR bool () ; BOOST_CXX14_CONSTEXPR bool (const period &) ; BOOST_CXX14_CONSTEXPR bool (const period &) ; BOOST_CXX14_CONSTEXPR void (const ); BOOST_CXX14_CONSTEXPR void (const ); BOOST_CXX14_CONSTEXPR bool (const point_rep &) ; BOOST_CXX14_CONSTEXPR bool (const period &) ; BOOST_CXX14_CONSTEXPR bool (const period &) ; BOOST_CXX14_CONSTEXPR bool (const period &) ; BOOST_CXX14_CONSTEXPR bool (const point_rep &) ; BOOST_CXX14_CONSTEXPR bool (const point_rep &) ; BOOST_CXX14_CONSTEXPR period (const period &) ; BOOST_CXX14_CONSTEXPR period (const period &) ; BOOST_CXX14_CONSTEXPR period (const period &) ; };
This template uses a class to represent a time point within the period and another class to represent a duration. As a result, this class is not appropriate for use when the number and duration representation are the same (eg: in the regular number domain).
A period can be specified by providing either the begining point and a duration or the begining point and the end point( end is NOT part of the period but 1 unit past it. A period will be "invalid" if either end_point <= begin_point or the given duration is <= 0. Any valid period will return false for is_null().
Zero length periods are also considered invalid. Zero length periods are periods where the begining and end points are the same, or, the given duration is zero. For a zero length period, the last point will be one unit less than the begining point.
In the case that the begin and last are the same, the period has a length of one unit.
The best way to handle periods is usually to provide a begining point and a duration. So, day1 + 7 days is a week period which includes all of the first day and 6 more days (eg: Sun to Sat).
period
public member functionsBOOST_CXX14_CONSTEXPR point_rep () ;Return the first element in the period.
BOOST_CXX14_CONSTEXPR point_rep () ;Return one past the last element.
BOOST_CXX14_CONSTEXPR point_rep () ;Return the last item in the period.
BOOST_CXX14_CONSTEXPR () ;Return the length of the period.
BOOST_CXX14_CONSTEXPR bool () ;True if period is ill formed (length is zero or less)
BOOST_CXX14_CONSTEXPR bool (const period & rhs) ;Equality operator.
BOOST_CXX14_CONSTEXPR bool (const period & rhs) ;Strict as defined by rhs.last <= lhs.last.
BOOST_CXX14_CONSTEXPR void (const d);Shift the start and end by the specified amount.
BOOST_CXX14_CONSTEXPR void (const d);
Expands the size of the period by the duration on both ends.
So before expand
[-------] ^ ^ ^ ^ ^ ^ ^
After expand(2)
[----------------------] ^ ^ ^ ^ ^ ^ ^
BOOST_CXX14_CONSTEXPR bool (const point_rep & point) ;True if the point is inside the period, zero length periods contain no points.
BOOST_CXX14_CONSTEXPR bool (const period & other) ;True if this period fully contains (or equals) the other period.
BOOST_CXX14_CONSTEXPR bool (const period & other) ;True if the periods overlap in any way.
BOOST_CXX14_CONSTEXPR bool (const period & other) ;True if periods are next to each other without a gap.
BOOST_CXX14_CONSTEXPR bool (const point_rep & point) ;True if all of the period is prior to the passed point or end <= t.
BOOST_CXX14_CONSTEXPR bool (const point_rep & point) ;True if all of the period is prior or t < start.
BOOST_CXX14_CONSTEXPR period (const period & other) ;Returns the period of intersection or invalid range no intersection.
BOOST_CXX14_CONSTEXPR period (const period & other) ;Returns the union of intersecting periods – or null period.
BOOST_CXX14_CONSTEXPR period (const period & other) ;Combine two periods with earliest start and latest end.
Combines two periods and any gap between them such that start = min(p1.start, p2.start) end = max(p1.end , p2.end)
[---