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, CDS.cpp, ConvertibleBonds.cpp, FittedBondCurve.cpp, Repo.cpp, and swapvaluation.cpp.

## Friends And Related Function Documentation

## years()

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

related

## months()

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

related

## weeks()

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

related

## days()

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

related

## operator*() [1/4]

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

related

## operator*() [2/4]

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

related

## operator-() [1/2]

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

related

## operator*() [3/4]

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

related

## operator*() [4/4]

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

related

## operator/()

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

related

## operator+()

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

related

## operator-() [2/2]

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

related

## operator<()

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

related

## operator==()

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

related

## operator!=()

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

related

## operator>()

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

related

## operator<=()

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

related

## operator>=()

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

related

## operator<<()

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

related