|
C++ Utilities 5.32.1
Useful C++ classes and routines such as argument parser, IO and conversion utilities
|
Represents a period of time. More...
#include <period.h>
Public Member Functions | |
| constexpr | Period () |
| Period (DateTime begin, DateTime end) | |
| Constructs a new Period defined by a start DateTime and an end DateTime. | |
| constexpr int | years () const |
| Returns the years component of the period represented by the current instance. | |
| constexpr int | months () const |
| Returns the months component of the period represented by the current instance. | |
| constexpr int | days () const |
| Returns the days component of the period represented by the current instance. | |
Represents a period of time.
In contrast to the TimeSpan class, a Period represents a duration expressed in years, months and days between a concrete starting DateTime and end DateTime. Without that context, the exact duration represented by a Period is not clearly defined as years and month have different lengths.
This is also the reason for the absence of the TimeSpan::totalYears() and TimeSpan::totalMonth() methods as the TimeSpan class is meant to express a duration independently of the concrete starting DateTime and end DateTime.
The Period class, on the other hand, expresses the duration between a concrete starting DateTime and end DateTime as the number of years, month and days which have been passed in that particular order. The accuracy is one day, so the DateTime::timeOfDay() is lost.
|
constexpr |
|
constexpr |
|
constexpr |