C++ Utilities 5.26.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 between a concrete starting DateTime and end DateTime. Without that context, a Period instance is useless.
Note the absence of the TimeSpan::totalYears() and TimeSpan::totalMonth() methods. The reason for this limitation of the TimeSpan class is that the TimeSpan is meant to express a duration independently of the concrete starting DateTime and end DateTime. However, the concrete calendar interval is neccassary for expressing a duration in terms of years and months because not all years and months have the same length.
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 |