File: period.h

package info (click to toggle)
martchus-cpp-utilities 5.28.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,352 kB
  • sloc: cpp: 12,471; awk: 18; ansic: 12; makefile: 10
file content (57 lines) | stat: -rw-r--r-- 1,089 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef CHRONO_UTILITIES_PERIOD_H
#define CHRONO_UTILITIES_PERIOD_H

#include "./datetime.h"

namespace CppUtilities {

class CPP_UTILITIES_EXPORT Period {
public:
    constexpr Period();
    Period(DateTime begin, DateTime end);
    constexpr int years() const;
    constexpr int months() const;
    constexpr int days() const;

private:
    int m_years;
    int m_months;
    int m_days;
};

constexpr Period::Period()
    : m_years(0)
    , m_months(0)
    , m_days(0)
{
}

/*!
 * \brief Returns the years component of the period represented by the current instance.
 */
constexpr int Period::years() const
{
    return m_years;
}

/*!
 * \brief Returns the months component of the period represented by the current instance.
 */
constexpr int Period::months() const
{
    return m_months;
}

/*!
 * \brief Returns the days component of the period represented by the current instance.
 */
constexpr int Period::days() const
{
    return m_days;
}

CPP_UTILITIES_EXPORT DateTime operator+(DateTime begin, Period period);

} // namespace CppUtilities

#endif // CHRONO_UTILITIES_PERIOD_H