C++ Utilities  5.10.5
Useful C++ classes and routines such as argument parser, IO and conversion utilities
period.h
Go to the documentation of this file.
1 #ifndef CHRONO_UTILITIES_PERIOD_H
2 #define CHRONO_UTILITIES_PERIOD_H
3 
4 #include "./datetime.h"
5 
6 namespace CppUtilities {
7 
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 
32 constexpr int Period::years() const
33 {
34  return m_years;
35 }
36 
40 constexpr int Period::months() const
41 {
42  return m_months;
43 }
44 
48 constexpr int Period::days() const
49 {
50  return m_days;
51 }
52 
54 
55 } // namespace CppUtilities
56 
57 #endif // CHRONO_UTILITIES_PERIOD_H
Represents an instant in time, typically expressed as a date and time of day.
Definition: datetime.h:53
Represents a period of time.
Definition: period.h:8
constexpr int days() const
Returns the days component of the period represented by the current instance.
Definition: period.h:48
constexpr int years() const
Returns the years component of the period represented by the current instance.
Definition: period.h:32
constexpr int months() const
Returns the months component of the period represented by the current instance.
Definition: period.h:40
constexpr Period()
Definition: period.h:22
#define CPP_UTILITIES_EXPORT
Marks the symbol to be exported by the c++utilities library.
Contains all utilities provides by the c++utilities library.
CPP_UTILITIES_EXPORT DateTime operator+(DateTime begin, Period period)
Adds the specified period to the specified date.
Definition: period.cpp:60