C++ Utilities 5.27.0
Useful C++ classes and routines such as argument parser, IO and conversion utilities
Loading...
Searching...
No Matches
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
6namespace CppUtilities {
7
9public:
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
16private:
17 int m_years;
18 int m_months;
19 int m_days;
20};
21
22constexpr Period::Period()
23 : m_years(0)
24 , m_months(0)
25 , m_days(0)
26{
27}
28
32constexpr int Period::years() const
33{
34 return m_years;
35}
36
40constexpr int Period::months() const
41{
42 return m_months;
43}
44
48constexpr 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:55
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.
Definition global.h:14
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