cpp-utilities/chrono/period.h

58 lines
1.1 KiB
C
Raw Normal View History

#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
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
/*!
* \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;
}
/*!
* \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;
}
/*!
* \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
CPP_UTILITIES_EXPORT DateTime operator+(DateTime begin, Period period);
2017-12-03 01:45:54 +01:00
} // namespace CppUtilities
2015-04-22 18:36:40 +02:00
#endif // CHRONO_UTILITIES_PERIOD_H