tntdb::Datetime Class Reference

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

`#include <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

## Datetime() [1/3]

tntdb::Datetime::Datetime | ( |  | ) |

inline

Create a Datetime object with empty values.

## Datetime() [2/3]

tntdb::Datetime::Datetime | ( | const Date & | date,
|  | const Time & | time )

inline

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

## Datetime() [3/3]

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

## fromIso()

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.

## getDay()

unsigned short tntdb::Datetime::getDay | ( |  | ) | const

inline

Get the day part of the Datetime.

## getHour()

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

inline

Get the hour part of the Datetime.

## getIso()

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

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

## getMillis()

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

inline

Get the millisecond part of the Datetime.

## getMinute()

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

inline

Get the minute part of the Datetime.

## getMonth()

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

inline

Get the month part of the Datetime.

## getSecond()

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

inline

Get the second part of the Datetime.

## getYear()

unsigned short tntdb::Datetime::getYear | ( |  | ) | const

inline

Get the year part of the Datetime.

## set()

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:

- tntdb/datetime.h