| 1 | #ifndef CHRONO_UTILITIES_PERIOD_H |
| 2 | #define CHRONO_UTILITIES_PERIOD_H |
| 3 | |
| 4 | #include "./datetime.h" |
| 5 | |
| 6 | namespace CppUtilities { |
| 7 | |
| 8 | class CPP_UTILITIES_EXPORT Period { |
| 9 | public: |
| 10 | constexpr Period(); |
| 11 | Period(DateTime begin, DateTime end); |
| 12 | constexpr int years() const; |
| 13 | constexpr int months() const; |
| 14 | constexpr int days() const; |
| 15 | |
| 16 | private: |
| 17 | int m_years; |
| 18 | int m_months; |
| 19 | int m_days; |
| 20 | }; |
| 21 | |
| 22 | constexpr Period::Period() |
| 23 | : m_years(0) |
| 24 | , m_months(0) |
| 25 | , m_days(0) |
| 26 | { |
| 27 | } |
| 28 | |
| 29 | /*! |
| 30 | * \brief Returns the years component of the period represented by the current instance. |
| 31 | */ |
| 32 | constexpr int Period::years() const |
| 33 | { |
| 34 | return m_years; |
| 35 | } |
| 36 | |
| 37 | /*! |
| 38 | * \brief Returns the months component of the period represented by the current instance. |
| 39 | */ |
| 40 | constexpr int Period::months() const |
| 41 | { |
| 42 | return m_months; |
| 43 | } |
| 44 | |
| 45 | /*! |
| 46 | * \brief Returns the days component of the period represented by the current instance. |
| 47 | */ |
| 48 | constexpr int Period::days() const |
| 49 | { |
| 50 | return m_days; |
| 51 | } |
| 52 | |
| 53 | CPP_UTILITIES_EXPORT DateTime operator+(DateTime begin, Period period); |
| 54 | |
| 55 | } // namespace CppUtilities |
| 56 | |
| 57 | #endif // CHRONO_UTILITIES_PERIOD_H |