C++ Boost

gregorian::date_period


Overall Index -- Gregorian Index -- Posix Time Index

Date Period Documentation

Header -- Construction -- Accessors -- Conversion To String -- Operators --

Introduction

The class boost::gregorian::date_period provides direct representation for ranges between two dates. Periods provide the ability to simplify some types of caculations by simplifing the conditional logic of the program. For example, testing if a date is within an irregular schedule such as a weekend or holiday can be accomplished using collections of date periods. This is facilitated by several methods that allow evaluation if a date_period intersects with another date period, and to generate the period resulting from the intersection. The period calculation example provides an example of this.
boost::gregorian::date_period クラスは、二つの日付の範囲(期間)を直接表現する。 プログラムの条件付きの論理を単純化することによって、ある種の計算を単純化する能力を提供する。 例えば、日付が週末あるいは休日のような不規則なスケジュールの中であるかどうか試すのは date_period のコレクションを使って達成され得る。 これは、date_period が別の期間(date period)と重複する場合に評価を許可する、あるいは重複している期間を生成する、といったいくつかの方法によって容易になる。 period calculation example(期間計算の例) はこの例を提供する。

Date periods used in combination with infinity values have the abilty to represent complex concepts such as 'until further notice'.
無限値と組み合わせて使用される期間(date periods)は、「追って通知があるまで」といった複雑な概念を表現する能力を持っている。

Header

#include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o
or
#include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types

Construction

SyntaxDescriptionExample
date_period(date begin, date last) [begin, last) で表される期間(period)を生成する。
last <= begin のときは null となる。
date_period dp(date(2002,Jan,10), date_duration(2));
date_period(date start, date end) [begin, begin+len)で表される期間(period)を生成する。
len <= 0 のときは null となる。
date_period dp(date(2002,Jan,10), date_duration(2));
date_period(date_period rhs) コピーコンストラクタ date_period dp1(dp)

Accessors

SyntaxDescriptionExample
date begin() const 期間(period)の初日を返す date_period dp(date(2002,Jan,1), date(2002,Jan,10));
dp.begin() --> 2002-Jan-01
date last() const 期間(period)の最終日を返す date_period dp(date(2002,Jan,1), date(2002,Jan,10));
dp.last() --> 2002-Jan-09
date end() const 期間(period)の最終日の翌日を返す date_period dp(date(2002,Jan,1), date(2002,Jan,10));
dp.end() --> 2002-Jan-10
bool is_null() const 期間(period)が正しい形式でないときtrue
例: start less than end ?逆では?
date_period dp(date(2002,Jan,10), date(2002,Jan,1));
dp.is_null() --> true
原文はたぶんコピペミス
bool contains(date) const 日付が期間(period)の範囲内にあるとき true date_period dp(date(2002,Jan,1), date(2002,Jan,10));
dp.contains(date(2002,Jan,2)) --> true
bool contains(date_period) const date_period が期間(period)の範囲内にあるときtrue date_period dp1(date(2002,Jan,1), date(2002,Jan,10));
date_period dp2(date(2002,Jan,2), date(2002,Jan,3));
dp1.contains(dp2) --> true
dp2.contains(dp1) --> false
bool intersects(date_period) const 期間(period)が重複するときtrue date_period dp1(date(2002,Jan,1), date(2002,Jan,10));
date_period dp2(date(2002,Jan,2), date(2002,Jan,3));
dp2.intersects(dp1) --> true
date_period intersection(date_period) const 2つの期間(period)から重複する期間(period)を計算する。 期間(period)が重複しないときは null が返る date_period dp1(date(2002,Jan,1), date(2002,Jan,10));
date_period dp2(date(2002,Jan,2), date(2002,Jan,3));
dp2.intersects(dp1) --> dp2
date_period merge(date_period) const 2つの期間(period)を結合して返す。期間(period)が重複しないときは null が返る date_period dp1(date(2002,Jan,1), date(2002,Jan,10));
date_period dp2(date(2002,Jan,9), date(2002,Jan,31));
dp2.intersects(dp1) --> 2002-Jan-01/2002-Jan-31
date_period shift(date_duration) 初日と最終日に日数(date_duration)を加算する。 date_period dp1(date(2002,Jan,1), date(2002,Jan,10));
dp1.shift(date_duration(1)); --> 2002-Jan-02/2002-Jan-11

Conversion To String

SyntaxDescriptionExample
std::string to_simple_string(date_period dp) [YYYY-mmm-DD/YYYY-mmm-DD] (mmm は月名の3文字短縮形)形式の文字列に変換 [2002-Jan-01/2002-Jan-31]

Operators

SyntaxDescriptionExample
operator==, operator!=,
operator>, operator<
サポートする比較演算子 dp1 == dp2, etc
operator< dp1.end()がdp2.begin()よりも小さいとき true dp1 < dp2, etc
operator> dp1.begin()がdp2.end()よりも大きいとき true dp1 > dp2, etc


Last modified: Tue Sep 3 16:15:21 MST 2002 by Jeff Garland © 2000-2002
Japanese Translation Copyright (C) 2003 Shoji Shinohara.