#include <datetime.h>
Inheritance diagram for mysqlpp::Date:
Public Member Functions | |
Date () | |
Default constructor. | |
Date (unsigned short y, unsigned char m, unsigned char d) | |
Initialize object. | |
Date (const Date &other) | |
Initialize object as a copy of another Date. | |
Date (const DateTime &other) | |
Initialize object from date part of date/time object. | |
Date (const char *str) | |
Initialize object from a C string containing a date. | |
template<class Str> | |
Date (const Str &str) | |
Initialize object from a C++ string containing a date. | |
Date (time_t t) | |
Initialize object from a time_t . | |
int | compare (const Date &other) const |
Compare this date to another. | |
const char * | convert (const char *) |
Parse a SQL date string into this object. | |
unsigned char | day () const |
Get the date's day part, 1-31. | |
void | day (unsigned char d) |
Change the date's day part, 1-31. | |
unsigned char | month () const |
Get the date's month part, 1-12. | |
void | month (unsigned char m) |
Change the date's month part, 1-12. | |
operator std::string () const | |
Convert to std::string. | |
operator time_t () const | |
Convert to time_t. | |
std::string | str () const |
Return our value in std::string form. | |
unsigned short | year () const |
Get the date's year part. | |
void | year (unsigned short y) |
Change the date's year part. |
Objects of this class can be inserted into streams, and initialized from SQL DATE strings.
|
Initialize object from a C string containing a date. String must be in the YYYY-MM-DD format. It doesn't have to be zero-padded. |
|
Initialize object from a C++ string containing a date. This works with any stringish class that declares a c_str() member function: std::string, mysqlpp::String...
|
|
Initialize object from a
Naturally, we throw away the "time" part of the |
|
Compare this date to another. Returns < 0 if this date is before the other, 0 of they are equal, and > 0 if this date is after the other. Implements Comparable< Date >. |
|
Convert to time_t.
The "time" part of the |
|
Change the date's year part. Pass the year value normally; we don't optimize the value by subtracting 1900 like some other date implementations. |
|
Get the date's year part. There's no trickery here like in some date implementations where you have to add 1900 or something like that. |