Modular Megafauna Model 1.1.5
A physiological, dynamic herbivore simulator in C++.
Loading...
Searching...
No Matches
date.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2020 W. Traylor <wolfgang.traylor@senckenberg.de>
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
11#ifndef FAUNA_DATE_H
12#define FAUNA_DATE_H
13
14#include <array>
15
16namespace Fauna {
17
19class Date {
20 public:
22
30 Date(const unsigned int julian_day, const int year);
31
33
39 unsigned int get_day_of_month(bool leap_year = false) const;
40
42 unsigned int get_julian_day() const { return julian_day; }
43
45
54 unsigned int get_month(const bool leap_year = false) const;
55
57 int get_year() const { return year; }
58
60
65 bool is_successive(const Date& other_date) const;
66
68 bool operator==(const Date& rhs) const;
69
71 bool operator!=(const Date& rhs) const;
72
74 bool operator<(const Date& rhs) const;
75
77 bool operator>(const Date& rhs) const;
78
79 private:
81 static const std::array<int, 12> MONTH_LENGTH;
82
84 static const std::array<int, 12> FIRST_OF_MONTH;
85
87 static const std::array<int, 12> FIRST_OF_MONTH_LEAP;
88
89 unsigned int julian_day;
90 int year;
91};
92} // namespace Fauna
93
94#endif // FAUNA_DATE_H
Helper class to hold an absolute simulation day.
Definition: date.h:19
bool operator>(const Date &rhs) const
Whether another date is before this date.
Definition: date.cpp:155
static const std::array< int, 12 > FIRST_OF_MONTH_LEAP
The Julian day of the first of each month in a 366-days (leap) year.
Definition: date.h:87
bool operator<(const Date &rhs) const
Whether another date is after this date.
Definition: date.cpp:151
static const std::array< int, 12 > MONTH_LENGTH
The number of days in each month in a 365-days (non-leap) year.
Definition: date.h:81
int get_year() const
The year specified in the constructor.
Definition: date.h:57
bool is_successive(const Date &other_date) const
Whether another Date object represents the following day.
Definition: date.cpp:128
int year
Definition: date.h:90
bool operator!=(const Date &rhs) const
Whether another Date object specifies a different day.
Definition: date.cpp:146
unsigned int get_month(const bool leap_year=false) const
The month (counting from 0 == January).
Definition: date.cpp:98
static const std::array< int, 12 > FIRST_OF_MONTH
The Julian day of the first of each month in a 365-days (non-leap) year.
Definition: date.h:84
bool operator==(const Date &rhs) const
Whether another Date object specifies the same day.
Definition: date.cpp:141
unsigned int get_julian_day() const
Day of the year (counting from 0 == Jan 1st).
Definition: date.h:42
unsigned int julian_day
Definition: date.h:89
unsigned int get_day_of_month(bool leap_year=false) const
Get the day of the month (0 = 1st).
Definition: date.cpp:90
Definition: average.h:16