C++ Utilities: chrono/period.h Source File

C++ Utilities 5.34.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
8 class CPP_UTILITIES_EXPORT Period {
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
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
53 CPP_UTILITIES_EXPORT DateTime operator+(DateTime begin, Period period);
54
55} // namespace CppUtilities
56
57#endif // CHRONO_UTILITIES_PERIOD_H
CppUtilities::DateTime
Represents an instant in time, typically expressed as a date and time of day.
Definition datetime.h:55
CppUtilities::Period
Represents a period of time.
Definition period.h:8
CppUtilities::Period::days
constexpr int days() const
Returns the days component of the period represented by the current instance.
Definition period.h:48
CppUtilities::Period::years
constexpr int years() const
Returns the years component of the period represented by the current instance.
Definition period.h:32
CppUtilities::Period::months
constexpr int months() const
Returns the months component of the period represented by the current instance.
Definition period.h:40
CppUtilities::Period::Period
constexpr Period()
Definition period.h:22
datetime.h
CPP_UTILITIES_EXPORT
#define CPP_UTILITIES_EXPORT
Marks the symbol to be exported by the c++utilities library.
Definition global.h:14
CppUtilities
Contains all utilities provided by the c++utilities library.
Definition argumentparser.h:18
CppUtilities::operator+
CPP_UTILITIES_EXPORT DateTime operator+(DateTime begin, Period period)
Adds the specified period to the specified date.
Definition period.cpp:59