|
Modular Megafauna Model 1.1.5
A physiological, dynamic herbivore simulator in C++.
|
Helper class to hold an absolute simulation day. More...
#include <date.h>
Public Member Functions | |
| Date (const unsigned int julian_day, const int year) | |
| Constructor. More... | |
| unsigned int | get_day_of_month (bool leap_year=false) const |
| Get the day of the month (0 = 1st). More... | |
| unsigned int | get_julian_day () const |
| Day of the year (counting from 0 == Jan 1st). More... | |
| unsigned int | get_month (const bool leap_year=false) const |
| The month (counting from 0 == January). More... | |
| int | get_year () const |
| The year specified in the constructor. More... | |
| bool | is_successive (const Date &other_date) const |
| Whether another Date object represents the following day. More... | |
| bool | operator== (const Date &rhs) const |
| Whether another Date object specifies the same day. More... | |
| bool | operator!= (const Date &rhs) const |
| Whether another Date object specifies a different day. More... | |
| bool | operator< (const Date &rhs) const |
| Whether another date is after this date. More... | |
| bool | operator> (const Date &rhs) const |
| Whether another date is before this date. More... | |
Private Attributes | |
| unsigned int | julian_day |
| int | year |
Static Private Attributes | |
| static const std::array< int, 12 > | MONTH_LENGTH |
| The number of days in each month in a 365-days (non-leap) year. More... | |
| 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. More... | |
| 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. More... | |
Helper class to hold an absolute simulation day.
| Date::Date | ( | const unsigned int | julian_day, |
| const int | year | ||
| ) |
Constructor.
| julian_day | Day of the year. A value of zero equals January 1st. A value of 365 is valid because it might be a leap year. |
| year | An arbitrary year number. This could be a calendar year or an abstract simulation year counter. |
| std::invalid_argument | If julian_day not in interval [0,365]. |
| unsigned int Date::get_day_of_month | ( | bool | leap_year = false | ) | const |
Get the day of the month (0 = 1st).
| leap_year | If false, a 365-days year is assumed with February counting 28 days. If true, February has 29 days. |
|
inline |
Day of the year (counting from 0 == Jan 1st).
| unsigned int Date::get_month | ( | const bool | leap_year = false | ) | const |
The month (counting from 0 == January).
If the Julian day is already the 366th day of the year, it is obviously a leap year. In that special case the leap_year parameter is ignored and a leap year is assumed.
| leap_year | If false, a 365-days year is assumed with February counting 28 days. If true, February has 29 days. |
|
inline |
The year specified in the constructor.
| bool Date::is_successive | ( | const Date & | other_date | ) | const |
Whether another Date object represents the following day.
This assumes a non-leap year: A Julian day of 364 (0==Jan 1st) can be followed by a Julian day of 0. The last day of a leap year (365) will also be validly followed by day 0.
| bool Date::operator!= | ( | const Date & | rhs | ) | const |
Whether another Date object specifies a different day.
| bool Date::operator< | ( | const Date & | rhs | ) | const |
Whether another date is after this date.
| bool Date::operator> | ( | const Date & | rhs | ) | const |
Whether another date is before this date.
|
staticprivate |
The Julian day of the first of each month in a 365-days (non-leap) year.
|
staticprivate |
The Julian day of the first of each month in a 366-days (leap) year.
|
private |
|
staticprivate |
The number of days in each month in a 365-days (non-leap) year.
|
private |