# mysqlpp::Time Class Reference

C++ form of SQL's TIME type. More...

`#include <datetime.h>`

Inheritance diagram for mysqlpp::Time:

[legend]
Collaboration diagram for mysqlpp::Time:

[legend]
List of all members.

## 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-255.
void | hour (unsigned char h)
| Change the time's hour part, 0-255.
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.

## Detailed Description

C++ form of SQL's TIME type.

Objects of this class can be inserted into streams, and initialized from SQL TIME strings.

## Constructor & Destructor Documentation

mysqlpp::Time::Time | ( | unsigned char | h,
|  | unsigned char | m,
|  | unsigned char | s |
| ) |  |  | `[inline]`

Initialize object.

Parameters:

  | h | hour, 0-255 (yes, > 1 day is legal in SQL!)
  | m | minute, 0-59
  | s | second, 0-59

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.

template<class Str>

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...

See also:
  Time(const char*)

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.

## Member Function Documentation

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"

The documentation for this class was generated from the following files:

- datetime.h
- datetime.cpp