#include <datetime.h>
Inheritance diagram for mysqlpp::Time:
Public Member Functions | |
Time () | |
Default constructor. | |
Time (unsigned char h, unsigned char m, unsigned char s) | |
Initialize object. | |
Time (const Time &other) | |
Initialize object as a copy of another Time. | |
Time (const DateTime &other) | |
Initialize object from time part of date/time object. | |
Time (const char *str) | |
Initialize object from a C string containing a SQL time string. | |
template<class Str> | |
Time (const Str &str) | |
Initialize object from a C++ string containing a SQL time string. | |
Time (time_t t) | |
Initialize object from a time_t . | |
int | compare (const Time &other) const |
Compare this time to another. | |
const char * | convert (const char *) |
Parse a SQL time string into this object. | |
unsigned char | hour () const |
Get the time's hour part, 0-23. | |
void | hour (unsigned char h) |
Change the time's hour part, 0-23. | |
unsigned char | minute () const |
Get the time's minute part, 0-59. | |
void | minute (unsigned char m) |
Change the time's minute part, 0-59. | |
operator std::string () const | |
Convert to std::string. | |
operator time_t () const | |
Convert to time_t. | |
unsigned char | second () const |
Get the time's second part, 0-59. | |
void | second (unsigned char s) |
Change the time's second part, 0-59. | |
std::string | str () const |
Return our value in std::string form. |
Objects of this class can be inserted into streams, and initialized from SQL TIME strings.
mysqlpp::Time::Time | ( | const char * | str | ) | [inline, explicit] |
Initialize object from a C string containing a SQL time string.
String must be in the HH:MM:SS format. It doesn't have to be zero-padded.
mysqlpp::Time::Time | ( | const Str & | str | ) | [inline, explicit] |
Initialize object from a C++ string containing a SQL time string.
This works with any stringish class that declares a c_str() member function: std::string, mysqlpp::String...
mysqlpp::Time::Time | ( | time_t | t | ) | [explicit] |
Initialize object from a time_t
.
Naturally, we throw away the "date" part of the time_t
. If you need to keep it, you want to use DateTime instead.
int mysqlpp::Time::compare | ( | const Time & | other | ) | const |
Compare this time to another.
Returns < 0 if this time is before the other, 0 of they are equal, and > 0 if this time is after the other.
mysqlpp::Time::operator time_t | ( | ) | const |
Convert to time_t.
The "date" part of the time_t
is "today"