This class provides simple date representation. More...
#include <date.hpp>
Public Member Functions | |
| date () | |
| date (int julian_date) | |
| date (int day, int month, int year) | |
| date (const char *stamp, const char *format="%d.%m.%Y") | |
| date (const date &x) | |
| date (date &&x)=default | |
| date & | operator= (const date &x) |
| date & | operator= (date &&x)=default |
| date & | operator= (int julian_date) |
| date & | operator+= (int days) |
| date & | operator-= (int days) |
| date & | operator++ () |
| date | operator++ (int) |
| date & | operator-- () |
| date | operator-- (int) |
| void | set (const char *datestr, const char *format="%d.%m.%Y") |
| void | set (int day, int month, int year) |
| void | set (int julian_date) |
| int | day () const |
| int | month () const |
| int | year () const |
| date & | day (int d) |
| date & | month (int m) |
| date & | year (int y) |
| bool | is_leapyear () const |
| bool | is_daylight_saving () const |
| int | julian_date () const |
| virtual int | difference (const date &x) const |
Static Public Member Functions | |
| static date | parse (const std::string &dstr, const char *format) |
| static bool | is_leapyear (int year) |
| static bool | is_valid_date (int year, int month, int day) |
| static bool | is_daylight_saving (int year, int month, int day) |
Friends | |
| OOS_UTILS_API bool | operator== (const date &a, const date &b) |
| OOS_UTILS_API bool | operator!= (const date &a, const date &b) |
| OOS_UTILS_API date | operator+ (date a, int days) |
| OOS_UTILS_API date | operator- (date a, int days) |
| OOS_UTILS_API bool | operator< (const date &a, const date &b) |
| OOS_UTILS_API bool | operator> (const date &a, const date &b) |
| OOS_UTILS_API bool | operator<= (const date &a, const date &b) |
| OOS_UTILS_API bool | operator>= (const date &a, const date &b) |
| OOS_UTILS_API std::ostream & | operator<< (std::ostream &out, const date &d) |
This class provides simple date representation.
This class provides simple date representation with julian calendar for date calculation.
A date can be constructed either from
| matador::date::date | ( | ) |
Creates a date of now
|
explicit |
Creates a date from the given julian date
| julian_date | The julian date to create a date from |
| matador::date::date | ( | int | day, |
| int | month, | ||
| int | year | ||
| ) |
Creates a date from given year, month and day
| day | Dates day |
| month | Dates month |
| year | Dates year |
|
explicit |
Creates a date from a given date/time string and a format string
| stamp | The date/time string to parse |
| format | The format to use for parsing |
| matador::date::date | ( | const date & | x | ) |
Copy date from given date
| x | Date to copy from. |
|
default |
Copy move date from given date
| x | Date to copy from. |
| int matador::date::day | ( | ) | const |
Returns the day part of date
| date & matador::date::day | ( | int | d | ) |
Sets the day part of the date and returns a reference to the date
| d | The day part of the date |
|
virtual |
Returns the difference of two dates in days.
| x | The date to calculate the difference with. |
| bool matador::date::is_daylight_saving | ( | ) | const |
Returns true if date is in daylight saving range which depends one the country.
|
static |
Returns true if time is in daylight saving range which depends one the country.
| bool matador::date::is_leapyear | ( | ) | const |
Returns true if dates year is a leap year.
|
static |
Returns true if dates year is a leap year.
| year | The year to check. |
|
static |
Checks if given date parts are valid
0 < month <= 12 Valid day with given month
| year | Year to check |
| month | Month to check |
| day | Day to check |
| int matador::date::julian_date | ( | ) | const |
Returns the underlying julian date
| int matador::date::month | ( | ) | const |
Returns the month part of date
| date & matador::date::month | ( | int | m | ) |
Sets the month part of the date and returns a reference to the date
| m | The month part of the date |
| date & matador::date::operator++ | ( | ) |
Increment date by one day
| date matador::date::operator++ | ( | int | ) |
Increment date by one day
| date & matador::date::operator+= | ( | int | days | ) |
Add a given number of days.
| days | Days to add |
| date & matador::date::operator-- | ( | ) |
Decrement date by one day
| date matador::date::operator-- | ( | int | ) |
Decrement date by one day
| date & matador::date::operator-= | ( | int | days | ) |
Subtract a given number of days.
| days | Days to subtract |
Assign from given date
| x | The date to assign from. |
Assignment move from given date
| x | The date to assign from. |
| date & matador::date::operator= | ( | int | julian_date | ) |
Assign a date from julian date value
| julian_date | The julian adte to assign from |
|
static |
Parse a given date string with a valid format and return a corresponding date object.
| dstr | Date string. |
| format | Date strings format. |
| void matador::date::set | ( | const char * | datestr, |
| const char * | format = "%d.%m.%Y" |
||
| ) |
Sets the date from a given date/time string and a format string
| datestr | The date/time string to parse |
| format | The format to use for parsing |
| void matador::date::set | ( | int | day, |
| int | month, | ||
| int | year | ||
| ) |
Sets the date from given year, month and day
| day | Dates day |
| month | Dates month |
| year | Dates year |
| void matador::date::set | ( | int | julian_date | ) |
Sets the date from the given julian date
| julian_date | The julian date to set |
| int matador::date::year | ( | ) | const |
Returns the year part of date
| date & matador::date::year | ( | int | y | ) |
Sets the year part of the date and returns a reference to the date
| y | The year part of the date |
Check if two dates are not equal
| a | The left hand date to compare. |
| b | The right hand date to compare. |
Add a number of days to a given date
| a | The date to add the days to |
| days | The days to be added |
Subtract a number of days to a given date
| a | The date to subtract the days to |
| days | The days to be subtracted |
Checks if date a is less than date b
| a | The left hand date to compare. |
| b | The right hand date to compare. |
|
friend |
Writes a date to a given ostream
| out | The ostream to write to |
| d | The date to write |
Checks if date a is less equal than date b
| a | The left hand date to compare. |
| b | The right hand date to compare. |
Check if two dates are equal
| a | The left hand date to compare. |
| b | The right hand date to compare. |
Checks if date a is greater than date b
| a | The left hand date to compare. |
| b | The right hand date to compare. |
Checks if date a is greater equal than date b
| a | The left hand date to compare. |
| b | The right hand date to compare. |