QuantLib: Period Class Reference

A free/open-source library for quantitative finance Reference manual - version 1.6

- Main Page
- Related Pages
- Modules
- Classes
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Related Functions | List of all members
Period Class Reference
Date and time calculations

`#include <ql/time/period.hpp>`

## Public Member Functions
| Period (Integer n, TimeUnit units)
| Period (Frequency f)
Integer | length () const
TimeUnit | units () const
Frequency | frequency () const
Period & | operator+= (const Period &)
Period & | operator-= (const Period &)
Period & | operator/= (Integer)
void | normalize ()

## Related Functions
(Note that these are not member functions.)
Real | years (const Period &)
Real | months (const Period &)
Real | weeks (const Period &)
Real | days (const Period &)
template<typename T >
Period | operator* (T n, TimeUnit units)
template<typename T >
Period | operator* (TimeUnit units, T n)
Period | operator- (const Period &)
Period | operator* (Integer n, const Period &)
Period | operator* (const Period &, Integer n)
Period | operator/ (const Period &, Integer n)
Period | operator+ (const Period &, const Period &)
Period | operator- (const Period &, const Period &)
bool | operator< (const Period &, const Period &)
bool | operator== (const Period &, const Period &)
bool | operator!= (const Period &, const Period &)
bool | operator> (const Period &, const Period &)
bool | operator<= (const Period &, const Period &)
bool | operator>= (const Period &, const Period &)
std::ostream & | operator<< (std::ostream &, const Period &)

## Detailed Description

This class provides a Period (length + TimeUnit) class and implements a limited algebra.

Tests:
  self-consistency of algebra is checked.

Examples:
  BermudanSwaption.cpp, Bonds.cpp, CallableBonds.cpp, ConvertibleBonds.cpp, FittedBondCurve.cpp, Repo.cpp, and swapvaluation.cpp.

## Friends And Related Function Documentation

Real years | ( | const Period & |  | ) |
| related

Real months | ( | const Period & |  | ) |
| related

Real weeks | ( | const Period & |  | ) |
| related

Real days | ( | const Period & |  | ) |
| related

Period operator* | ( | T | n,
|  | TimeUnit | units
| ) |  |
| related

Period operator* | ( | TimeUnit | units,
|  | T | n
| ) |  |
| related

Period operator- | ( | const Period & |  | ) |
| related

Period operator* | ( | Integer | n,
|  | const Period & |
| ) |  |
| related

Period operator* | ( | const Period & | ,
|  | Integer | n
| ) |  |
| related

Period operator/ | ( | const Period & | ,
|  | Integer | n
| ) |  |
| related

Period operator+ | ( | const Period & | ,
|  | const Period & |
| ) |  |
| related

Period operator- | ( | const Period & | ,
|  | const Period & |
| ) |  |
| related

bool operator< | ( | const Period & | ,
|  | const Period & |
| ) |  |
| related

bool operator== | ( | const Period & | ,
|  | const Period & |
| ) |  |
| related

bool operator!= | ( | const Period & | ,
|  | const Period & |
| ) |  |
| related

bool operator> | ( | const Period & | ,
|  | const Period & |
| ) |  |
| related

bool operator<= | ( | const Period & | ,
|  | const Period & |
| ) |  |
| related

bool operator>= | ( | const Period & | ,
|  | const Period & |
| ) |  |
| related

std::ostream & operator<< | ( | std::ostream & | ,
|  | const Period & |
| ) |  |
| related