# gregorian::date_duration

Overall Index -- Gregorian Index -- Posix Time Index

Date Documentation

Header -- Construction -- Accessors -- Operators

## Introduction

The class boost::gregorian::date_duration is a simple day count used for arithmetic with gregorian::date. A duration can be either positive or negative.

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

Syntax | Description | Example
date_duration(long) | Create a duration count. | date_duration dd(3); //3 days

## Accessors

Syntax | Description | Example
long days() const | Get the day count. | date_duration dd(3); dd.days() --> 3
bool is_negative() const | True if number of days is less than zero.. | date_duration dd(-1); dd.is_negative() --> true
static date_duration unit() | Return smallest possible unit of duration type. | date_duration::unit() --> date_duration(1)

## Operators

Syntax | Description | Example
operator==, operator!=, operator>, operator< operator>=, operator<= | A full complement of comparison operators | dd1 == dd2, etc
date_duration operator+(date_duration) const | Add date durations. | date_duration dd1(3); date_duration dd2(5); date_duration dd3 = dd1 + dd2;
date_duration operator-(date_duration) const | Subtract durations. | date_duration dd1(3); date_duration dd2(5); date_duration dd3 = dd1 - dd2;