Webmaster  |  Imprint 
C++ Server Pages
Main  |  License  |  Documentation  |  Download 

DateTime Class Reference

Combined Date and Time value.

#include <tntdb/cxxtools/datetime.h>

List of all members.

Public Member Functions

 DateTime (int year, unsigned month, unsigned day, unsigned hour=0, unsigned minute=0, unsigned second=0, unsigned msec=0)
 DateTime (const DateTime &dateTime)
DateTimeoperator= (const DateTime &dateTime)
DateTimeoperator= (unsigned julianDay)
void set (int year, unsigned month, unsigned day, unsigned hour=0, unsigned min=0, unsigned sec=0, unsigned msec=0)
void get (int &year, unsigned &month, unsigned &day, unsigned &hour, unsigned &min, unsigned &sec, unsigned &msec) const
const Datedate () const
const Datedate ()
DateTimesetDate (const Date &date)
const Timetime () const
const Timetime ()
DateTimesetTime (const Time &time)
unsigned day () const
 Returns the day-part of the date.
unsigned month () const
 Returns the month-part of the date.
int year () const
 Returns the year-part of the date.
unsigned hour () const
 Returns the hour-part of the Time.
unsigned minute () const
 Returns the minute-part of the Time.
unsigned second () const
 Returns the second-part of the Time.
unsigned msec () const
 Returns the millisecond-part of the Time.
int64_t msecsSinceEpoch () const
 Returns the milliseconds relative to the Unix-epoch.
std::string toIsoString () const
bool operator== (const DateTime &rhs) const
bool operator!= (const DateTime &rhs) const
DateTimeoperator+= (const Timespan &ts)
 Assignment by sum operator.
DateTimeoperator-= (const Timespan &ts)
 Assignment by difference operator.
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 fromJulianDays (unsigned julianDays)
static DateTime fromMSecsSinceEpoch (const int64_t msecsSinceEpoch)
 Creates a DateTime object relative to the Unix epoch.
static DateTime fromIsoString (const std::string &s)
static bool isValid (int year, unsigned month, unsigned day, unsigned hour, unsigned minute, unsigned second, unsigned msec)

Friends

Timespan operator- (const DateTime &first, const DateTime &second)
DateTime operator+ (const DateTime &dt, const Timespan &ts)
DateTime operator- (const DateTime &dt, const Timespan &ts)


Member Function Documentation

static DateTime fromMSecsSinceEpoch ( const int64_t  msecsSinceEpoch  )  [static]

The DateTime will be relative to the unix-epoch (Jan 1st 1970) by the milli-seconds specified by msecsSinceEpoch. The construction does not take care of any time zones. I.e. the milliseconds will be treated as if they were in the same time zone as the reference (January 1st 1970). Thus specifying a "time-zoned" millisecond value will lead to a "time-zoned" DateTime. And accordingly a "GMT" millisecond value will lead to a "GMT" DateTime.

int64_t msecsSinceEpoch (  )  const

The calculation does currently not take care of any time zones. I.e. the milliseconds will be calculated as if they were in the same time zone as the reference (January 1st 1970). Thus calling this API on a "time-zoned" DateTime will lead to a "time-zoned" millisecond value. And accordingly calling this API on a "GMT" DateTime will lead to a "GMT" millisecond value.

Copyright © 2008 The Tntnet Development Team
Tntnet 1.6