This class holds a date and a time. More...

#include <tntdb/datetime.h>

Public Member Functions

 Datetime ()
 Create a Datetime object with empty values.
 Datetime (const Date &date, const Time &time)
 Create a Datetime object with the values from the given Date and Time objects.
 Datetime (unsigned short year, unsigned short month, unsigned short day, unsigned short hour, unsigned short minute, unsigned short second, unsigned short millis=0)
 Create a Datetime object with the given values.
unsigned short getYear () const
 Get the year part of the Datetime.
unsigned short getMonth () const
 Get the month part of the Datetime.
unsigned short getDay () const
 Get the day part of the Datetime.
unsigned short getHour () const
 Get the hour part of the Datetime.
unsigned short getMinute () const
 Get the minute part of the Datetime.
unsigned short getSecond () const
 Get the second part of the Datetime.
unsigned short getMillis () const
 Get the millisecond part of the Datetime.
Date getDate () const
Time getTime () const
bool isNull () const
std::string getIso () const
 Get the date in ISO format (yyyy-mm-dd hh:mm:ss.hhh)
void set (unsigned short year, unsigned short month, unsigned short day, unsigned short hour, unsigned short minute, unsigned short second, unsigned short millis=0)
 Set the date and the time.
bool operator== (const Datetime &dt) const
bool operator!= (const Datetime &dt) const
bool operator< (const Datetime &dt) const
bool operator> (const Datetime &dt) const
bool operator<= (const Datetime &dt) const
bool operator>= (const Datetime &dt) const

Static Public Member Functions

static Datetime localtime ()
static Datetime gmtime ()
static Datetime fromIso (const std::string &s)
 Construct a Datetime object from the given ISO datetime string.

Detailed Description

This class holds a date and a time.

Constructor & Destructor Documentation

tntdb::Datetime::Datetime ( )
inline

Create a Datetime object with empty values.

tntdb::Datetime::Datetime ( const Date date,
const Time time 
)
inline

Create a Datetime object with the values from the given Date and Time objects.

tntdb::Datetime::Datetime ( unsigned short  year,
unsigned short  month,
unsigned short  day,
unsigned short  hour,
unsigned short  minute,
unsigned short  second,
unsigned short  millis = 0 
)
inline

Create a Datetime object with the given values.

No range checks are done.

Member Function Documentation

static Datetime tntdb::Datetime::fromIso ( const std::string &  s)
static

Construct a Datetime object from the given ISO datetime string.

If the string is not in ISO format, an exception of type tntdb::TypeError is thrown.

Date tntdb::Datetime::getDate ( ) const
inline
unsigned short tntdb::Datetime::getDay ( ) const
inline

Get the day part of the Datetime.

unsigned short tntdb::Datetime::getHour ( ) const
inline

Get the hour part of the Datetime.

std::string tntdb::Datetime::getIso ( ) const

Get the date in ISO format (yyyy-mm-dd hh:mm:ss.hhh)

unsigned short tntdb::Datetime::getMillis ( ) const
inline

Get the millisecond part of the Datetime.

unsigned short tntdb::Datetime::getMinute ( ) const
inline

Get the minute part of the Datetime.

unsigned short tntdb::Datetime::getMonth ( ) const
inline

Get the month part of the Datetime.

unsigned short tntdb::Datetime::getSecond ( ) const
inline

Get the second part of the Datetime.

Time tntdb::Datetime::getTime ( ) const
inline
unsigned short tntdb::Datetime::getYear ( ) const
inline

Get the year part of the Datetime.

static Datetime tntdb::Datetime::gmtime ( )
static
bool tntdb::Datetime::isNull ( ) const
inline
static Datetime tntdb::Datetime::localtime ( )
static
bool tntdb::Datetime::operator!= ( const Datetime dt) const
inline
bool tntdb::Datetime::operator< ( const Datetime dt) const
inline
bool tntdb::Datetime::operator<= ( const Datetime dt) const
inline
bool tntdb::Datetime::operator== ( const Datetime dt) const
inline
bool tntdb::Datetime::operator> ( const Datetime dt) const
inline
bool tntdb::Datetime::operator>= ( const Datetime dt) const
inline
void tntdb::Datetime::set ( unsigned short  year,
unsigned short  month,
unsigned short  day,
unsigned short  hour,
unsigned short  minute,
unsigned short  second,
unsigned short  millis = 0 
)
inline

Set the date and the time.

No range checks are done.


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