#include <tntdb/cxxtools/date.h>
Public Types | |
| enum | Month { Jan = 1, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec } |
| enum | WeekDay { Sun = 0, Mon, Tue, Wed, Thu, Fri, Sat } |
Public Member Functions | |
| Date () | |
| Default constructor. | |
| Date (const Date &date) | |
| Copy constructor. | |
| Date (int y, unsigned m, unsigned d) | |
| Constructs a Date from given values. | |
| Date (unsigned julianDays) | |
| Constructs a Date from a julian day. | |
| void | setJulian (unsigned d) |
| Sets the Date to a julian day. | |
| unsigned | julian () const |
| Returns the Date as a julian day. | |
| void | set (int year, unsigned month, unsigned day) |
| Sets the date to a year, month and day. | |
| void | get (int &year, unsigned &month, unsigned &day) const |
| Gets the year, month and day. | |
| unsigned | day () const |
| Returns the day-part of the date. | |
| unsigned | month () const |
| Returns the month-part of the date. | |
| int | year () const |
| Returns the year-part of the date. | |
| unsigned | dayOfWeek () const |
| Return day of the week, starting with sunday. | |
| unsigned | daysInMonth () const |
| Returns the days of the month of the date. | |
| unsigned | dayOfYear () const |
| Returns the day of the year. | |
| bool | leapYear () const |
| Returns true if the date is in a leap year. | |
| Date & | operator= (const Date &date) |
| Assignment operator. | |
| Date & | operator+= (int days) |
| Add days to the date. | |
| Date & | operator-= (int days) |
| Substract days from the date. | |
| Date & | operator++ () |
| Increments the date by one day. | |
| Date & | operator-- () |
| Decrements the date by one day. | |
| bool | operator== (const Date &date) const |
| Returns true if the dates are equal. | |
| bool | operator!= (const Date &date) const |
| Returns true if the dates are not equal. | |
| bool | operator< (const Date &date) const |
| Less-than comparison operator. | |
| bool | operator<= (const Date &date) const |
| Less-than-equal comparison operator. | |
| bool | operator> (const Date &date) const |
| Greater-than comparison operator. | |
| bool | operator>= (const Date &date) const |
| Greater-than-equal comparison operator. | |
| std::string | toIsoString () const |
| Returns the date in ISO-format. | |
Static Public Member Functions | |
| static Date | fromIsoString (const std::string &s) |
| Interprets a string as a date-string in ISO-format. | |
| static bool | isValid (int y, int m, int d) |
| Returns true if values describe a valid date. | |
| static bool | leapYear (int year) |
| Returns true if the year is in a leap year. | |
Static Public Attributes | |
| static const unsigned | DaysPerYear = 365 |
| The number of days of an ordinary year. | |
| static const unsigned | DaysPerLeapYear = 366 |
| The number of days of a leap year. | |
| static const unsigned | DaysOfJan = 31 |
| The number of days of a January. | |
| static const unsigned | DaysOfFeb = 28 |
| The number of days of a February. | |
| static const unsigned | DaysOfLeapFeb = 29 |
| The number of days of a February in a leap year. | |
| static const unsigned | DaysOfMar = 31 |
| The number of days of a March. | |
| static const unsigned | DaysOfApr = 30 |
| The number of days of a April. | |
| static const unsigned | DaysOfMay = 31 |
| The number of days of a May. | |
| static const unsigned | DaysOfJun = 30 |
| The number of days of a June. | |
| static const unsigned | DaysOfJul = 31 |
| The number of days of a July. | |
| static const unsigned | DaysOfAug = 31 |
| The number of days of a August. | |
| static const unsigned | DaysOfSep = 30 |
| The number of days of a September. | |
| static const unsigned | DaysOfOct = 31 |
| The number of days of a October. | |
| static const unsigned | DaysOfNov = 30 |
| The number of days of a November. | |
| static const unsigned | DaysOfDec = 31 |
| The number of days of a December. | |
Friends | |
| Date | operator+ (const Date &d, int days) |
| Date | operator+ (int days, const Date &d) |
| int | operator- (const Date &a, const Date &b) |
| Date | ( | ) |
The default constructed date is undefined.
| Date | ( | int | y, | |
| unsigned | m, | |||
| unsigned | d | |||
| ) |
Sets the date to a new year, month and day. InvalidDate is thrown if any of the values is out of range
| void set | ( | int | year, | |
| unsigned | month, | |||
| unsigned | day | |||
| ) |
Sets the date to a new year, month and day. InvalidDate is thrown if any of the values is out of range
Referenced by tntdb::operator>>().
| std::string toIsoString | ( | ) | const |
| Date fromIsoString | ( | const std::string & | s | ) | [static] |
Interprets a string as a date-string in ISO-format (yyyy-mm-dd) and returns a Date-object. When the string is not in ISO-format, an exception is thrown.
| s | Iso formated date string. |
| IllegalArgument |