2016-06-11 19:09:14 +02:00
|
|
|
#ifndef CHRONO_UTILITIES_PERIOD_H
|
|
|
|
#define CHRONO_UTILITIES_PERIOD_H
|
2015-04-22 18:36:40 +02:00
|
|
|
|
2015-09-06 20:19:09 +02:00
|
|
|
#include "./datetime.h"
|
2015-04-22 18:36:40 +02:00
|
|
|
|
2019-06-10 21:56:46 +02:00
|
|
|
namespace CppUtilities {
|
2015-04-22 18:36:40 +02:00
|
|
|
|
2017-05-01 03:13:11 +02:00
|
|
|
class CPP_UTILITIES_EXPORT Period {
|
2015-04-22 18:36:40 +02:00
|
|
|
public:
|
2018-03-07 19:45:02 +01:00
|
|
|
constexpr Period();
|
|
|
|
Period(DateTime begin, DateTime end);
|
|
|
|
constexpr int years() const;
|
|
|
|
constexpr int months() const;
|
|
|
|
constexpr int days() const;
|
2017-05-01 03:13:11 +02:00
|
|
|
|
2015-04-22 18:36:40 +02:00
|
|
|
private:
|
|
|
|
int m_years;
|
|
|
|
int m_months;
|
|
|
|
int m_days;
|
|
|
|
};
|
|
|
|
|
2018-03-07 19:45:02 +01:00
|
|
|
constexpr Period::Period()
|
|
|
|
: m_years(0)
|
|
|
|
, m_months(0)
|
|
|
|
, m_days(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-04-22 18:36:40 +02:00
|
|
|
/*!
|
2017-12-03 01:45:11 +01:00
|
|
|
* \brief Returns the years component of the period represented by the current instance.
|
2015-04-22 18:36:40 +02:00
|
|
|
*/
|
2018-03-07 19:45:02 +01:00
|
|
|
constexpr int Period::years() const
|
2015-04-22 18:36:40 +02:00
|
|
|
{
|
|
|
|
return m_years;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2017-12-03 01:45:11 +01:00
|
|
|
* \brief Returns the months component of the period represented by the current instance.
|
2015-04-22 18:36:40 +02:00
|
|
|
*/
|
2018-03-07 19:45:02 +01:00
|
|
|
constexpr int Period::months() const
|
2015-04-22 18:36:40 +02:00
|
|
|
{
|
|
|
|
return m_months;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
2017-12-03 01:45:11 +01:00
|
|
|
* \brief Returns the days component of the period represented by the current instance.
|
2015-04-22 18:36:40 +02:00
|
|
|
*/
|
2018-03-07 19:45:02 +01:00
|
|
|
constexpr int Period::days() const
|
2015-04-22 18:36:40 +02:00
|
|
|
{
|
|
|
|
return m_days;
|
|
|
|
}
|
2017-12-03 01:45:54 +01:00
|
|
|
|
2020-01-29 18:30:02 +01:00
|
|
|
CPP_UTILITIES_EXPORT DateTime operator+(DateTime begin, Period period);
|
2017-12-03 01:45:54 +01:00
|
|
|
|
2019-06-10 21:56:46 +02:00
|
|
|
} // namespace CppUtilities
|
2015-04-22 18:36:40 +02:00
|
|
|
|
2016-06-11 19:09:14 +02:00
|
|
|
#endif // CHRONO_UTILITIES_PERIOD_H
|