pops-core
0.9
PoPS (Pest or Pathogen Spread) Model Core C++ library
|
Representation and manipulation of a date for the simulation. More...
#include <date.hpp>
Public Member Functions | |
Date (const Date &d) | |
Date (int y, int m, int d) | |
Date (std::string date) | |
Construct date from string. More... | |
Date & | operator= (const Date &)=default |
void | increased_by_days (int num_days) |
Increases the date by the num_days (specified by the user) except on the last timestep of the year, which is increased by num_days plus the number of days left in the year that are less than num_days (e.g. More... | |
void | increased_by_week () |
Increases the date by one week (7 days) except on the last week of the year, which is increased by 8 or 9 days if a leap year. More... | |
void | increased_by_month () |
void | add_day () |
Adds 1 day to a date. More... | |
void | add_days (unsigned n) |
Adds N days to a date. More... | |
void | subtract_day () |
Subtract 1 day from a date. More... | |
void | subtract_days (unsigned n) |
Subtract N days from a date. More... | |
Date | get_year_end () |
Date | get_next_year_end () |
Date | get_last_day_of_week () |
Assumes we call it on the first day of a week. More... | |
Date | get_last_day_of_month () |
Compute the last day of a month. More... | |
bool | is_last_week_of_year () |
bool | is_last_month_of_year () |
bool | is_last_day_of_year () |
bool | is_last_day_of_month () |
bool | is_last_week_of_month () |
bool | is_leap_year () |
std::string | to_string () |
Returns the current date as a string Will be replaced by C++20 format function. More... | |
int | month () const |
int | year () const |
int | day () const |
int | weeks_from_date (Date start) |
Gets number of weeks between start date and this date. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Date &d) |
bool | operator> (const Date &d1, const Date &d2) |
bool | operator>= (const Date &d1, const Date &d2) |
bool | operator< (const Date &d1, const Date &d2) |
bool | operator<= (const Date &d1, const Date &d2) |
bool | operator== (const Date &d1, const Date &d2) |
bool | operator!= (const Date &d1, const Date &d2) |
Representation and manipulation of a date for the simulation.
This class represents and manipulates dates in way which is most useful for the PoPS simulation, i.e. by weeks and months.
|
inline |
pops::Date::Date | ( | std::string | date | ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Increases the date by the num_days (specified by the user) except on the last timestep of the year, which is increased by num_days plus the number of days left in the year that are less than num_days (e.g.
if the num_days = 28 the last time step is 29 or 30 (if leap year), if num_days = 23 that last time step is 43 or 44 (if leap year) days). This ensures that each year of the forecast starts on January 1st.
Definition at line 287 of file date.hpp.
|
inline |
|
inline |
Increases the date by one week (7 days) except on the last week of the year, which is increased by 8 or 9 days if a leap year.
This ensures that each year of the forecast starts on January 1st.
Definition at line 327 of file date.hpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
friend |