libtabula::Time Class Reference

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

#include <datetime.h>

Inheritance diagram for libtabula::Time:
Inheritance graph
[legend]
Collaboration diagram for libtabula::Time:
Collaboration graph
[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

libtabula::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
libtabula::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 >
libtabula::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, libtabula::String...

See also:
Time(const char*)
libtabula::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 libtabula::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.

libtabula::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:

Generated on 26 May 2014 for Libtabula by  doxygen 1.6.1