ml::DateTime Class Reference
[Reentrant Classes]

Class for performing date/time arithmetics, comparisons and formatting. More...

#include <mlDateTime.h>

List of all members.

Public Types

typedef MLint32 DateTimeIntType
 Specify data type for year, month, day, hour and minute type as MLint32.
typedef MLdouble DateTimeFloatType
 Specify data type for seconds and fractions of other time units.

Public Member Functions

Initialization
 DateTime ()
 DateTime (const DateTime &dt)
 DateTime (DateTimeIntType yearV, DateTimeIntType monthV, DateTimeIntType dayV, DateTimeIntType hourV=0, DateTimeIntType minuteV=0, DateTimeFloatType secondV=0)
 DateTime (const char *dtString, const char *format=0)
 DateTime (DateTimeIntType linearDaysV, DateTimeFloatType linearSecondsV)
Set date and time
DateTimeoperator= (const DateTime &dt)
bool set (DateTimeIntType yearV, DateTimeIntType monthV, DateTimeIntType dayV, DateTimeIntType hourV=0, DateTimeIntType minuteV=0, DateTimeFloatType secondV=0)
bool set (const char *dtString, const char *format=0)
bool set (DateTimeIntType linDaysV, DateTimeFloatType linSecondsV)
bool setYMD (DateTimeIntType yearV, DateTimeIntType monthV, DateTimeIntType dayV)
bool setHMS (DateTimeIntType hourV, DateTimeIntType minuteV, DateTimeFloatType secondV)
DateTimenow ()
Returns date and time
void get (DateTimeIntType *yearV, DateTimeIntType *monthV, DateTimeIntType *dayV, DateTimeIntType *hourV=0, DateTimeIntType *minuteV=0, DateTimeFloatType *secondV=0) const
void get (char *dtString, const char *format=0) const
void getYMD (DateTimeIntType *yearV, DateTimeIntType *monthV, DateTimeIntType *dayV) const
void getHMS (DateTimeIntType *hourV, DateTimeIntType *minuteV, DateTimeFloatType *secondV) const
DateTimeIntType year () const
DateTimeIntType month () const
DateTimeIntType day () const
DateTimeIntType hour () const
DateTimeIntType minute () const
DateTimeFloatType second () const
DateTimeIntType dayInYear () const
DateTimeIntType linearDays () const
DateTimeFloatType linearSeconds () const
 operator void * () const
bool operator! () const
Arithmetics
void addDays (DateTimeIntType daysV)
void addDays (DateTimeFloatType daysV)
void addSeconds (DateTimeFloatType secondsV)
DateTimeFloatType daysSince (const DateTime &dateTime) const
DateTimeFloatType secondsSince (const DateTime &dateTime) const
Comparison
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

Protected Member Functions

Auxiliary conversion methods
void normalize ()

Deprecated

typedef MLint32 DTIType
typedef MLdouble DTFType
DateTimeIntType linDays () const
DateTimeFloatType linSeconds () const

Special date methods

DateTimeIntType daysOfMonth () const
DateTimeIntType daysOfYear () const
bool isLeapYear () const
static bool validYMD (DateTimeIntType yearV, DateTimeIntType monthV, DateTimeIntType dayV)
static bool validHMS (DateTimeIntType hourV, DateTimeIntType minuteV, DateTimeFloatType secondV)
static DateTimeIntType daysOfMonth (DateTimeIntType monthV, DateTimeIntType yearV)
static DateTimeIntType daysOfYear (DateTimeIntType yearV)
static bool isLeapYear (DateTimeIntType yearV)


Detailed Description

Class for performing date/time arithmetics, comparisons and formatting.

Thread-safety: This class is reentrant.

This class represents points in a time continuum by

The class provides member functions to convert between the internal representation and the usual one using year, month, day, hour, minute and second. There are also functions to compare two dates and to perform simple arithmetics, as adding/subtracting a number of days or seconds and computing the difference between two dates in either days or seconds.

Years, months, days, hours, minutes are represented by the type DateTime::DateTimeIntType which is a normal integer type.

Seconds and fractions of other time units are represented as DateTime::DateTimeFloatType, a normal floating point type.

The seconds counter is implemented as a double precision variable, hence it is able to measure fractions of a second with a precision in the nanosecond range.

The linear day counter counts days passed since the (non-existing) date 01-Jan-0000, assuming that the modern leap year rules would have been valid since the beginning of time. It is well known that this is not true, so computations involving dates before 1752 (the year the Gregorian calendar has been established) are

A year is considered a leap year if

Leap seconds and time zones are not supported.

The class supports three different time and date representations:

1 <= month <= 12 1 <= day <= Number of days in month 0 <= hour <= 23 0 <= minute <= 59 0 <= second < 60

The year number can be arbitrary, although numbers smaller than 1752 might make no sense (cf above). There is no implicit assumption on the century, i.e., the year 99 is NOT the year 1999, and 01 is NOT 2001.

Specifications outside the valid range are signaled as invalid but are nevertheless converted into a valid internal representation by "extrapolation". For example, the dates 2000-02-30 and 2000-03-01 are considered the same, 12:61:00 is the same as 13:01:00 and 24:15:30 is really 0:15:30 the next day.

y : Year, two digits (only get()) Y : Year, four digits m : Month d, D : Day h, H : Hour M : Minute s, S : Second (as an integer)

If no format is specified, the default format

Y-m-d H:M:S

is used.

Definition at line 121 of file mlDateTime.h.


Member Typedef Documentation

Specify data type for seconds and fractions of other time units.

Definition at line 129 of file mlDateTime.h.

Specify data type for year, month, day, hour and minute type as MLint32.

Definition at line 127 of file mlDateTime.h.

Deprecated:
Use DateTimeFloatType instead.

Definition at line 320 of file mlDateTime.h.

Deprecated:
Use DateTimeIntType instead.

Definition at line 317 of file mlDateTime.h.


Constructor & Destructor Documentation

ml::DateTime::DateTime (  ) 

ml::DateTime::DateTime ( const DateTime dt  ) 

ml::DateTime::DateTime ( DateTimeIntType  yearV,
DateTimeIntType  monthV,
DateTimeIntType  dayV,
DateTimeIntType  hourV = 0,
DateTimeIntType  minuteV = 0,
DateTimeFloatType  secondV = 0 
)

ml::DateTime::DateTime ( const char *  dtString,
const char *  format = 0 
)

ml::DateTime::DateTime ( DateTimeIntType  linearDaysV,
DateTimeFloatType  linearSecondsV 
)


Member Function Documentation

void ml::DateTime::addDays ( DateTimeFloatType  daysV  ) 

void ml::DateTime::addDays ( DateTimeIntType  daysV  ) 

void ml::DateTime::addSeconds ( DateTimeFloatType  secondsV  ) 

DateTimeIntType ml::DateTime::day (  )  const

DateTimeIntType ml::DateTime::dayInYear (  )  const

DateTimeIntType ml::DateTime::daysOfMonth (  )  const

static DateTimeIntType ml::DateTime::daysOfMonth ( DateTimeIntType  monthV,
DateTimeIntType  yearV 
) [static]

DateTimeIntType ml::DateTime::daysOfYear (  )  const

static DateTimeIntType ml::DateTime::daysOfYear ( DateTimeIntType  yearV  )  [static]

DateTimeFloatType ml::DateTime::daysSince ( const DateTime dateTime  )  const

void ml::DateTime::get ( char *  dtString,
const char *  format = 0 
) const

void ml::DateTime::get ( DateTimeIntType yearV,
DateTimeIntType monthV,
DateTimeIntType dayV,
DateTimeIntType hourV = 0,
DateTimeIntType minuteV = 0,
DateTimeFloatType secondV = 0 
) const

void ml::DateTime::getHMS ( DateTimeIntType hourV,
DateTimeIntType minuteV,
DateTimeFloatType secondV 
) const

void ml::DateTime::getYMD ( DateTimeIntType yearV,
DateTimeIntType monthV,
DateTimeIntType dayV 
) const

DateTimeIntType ml::DateTime::hour (  )  const

bool ml::DateTime::isLeapYear (  )  const

static bool ml::DateTime::isLeapYear ( DateTimeIntType  yearV  )  [static]

DateTimeIntType ml::DateTime::linDays (  )  const [inline]

Deprecated:
Use linearDays() instead.

Definition at line 323 of file mlDateTime.h.

DateTimeIntType ml::DateTime::linearDays (  )  const [inline]

Definition at line 199 of file mlDateTime.h.

DateTimeFloatType ml::DateTime::linearSeconds (  )  const [inline]

Definition at line 200 of file mlDateTime.h.

DateTimeFloatType ml::DateTime::linSeconds (  )  const [inline]

Deprecated:
Use linearSeconds() instead.

Definition at line 326 of file mlDateTime.h.

DateTimeIntType ml::DateTime::minute (  )  const

DateTimeIntType ml::DateTime::month (  )  const

void ml::DateTime::normalize (  )  [protected]

DateTime& ml::DateTime::now (  ) 

ml::DateTime::operator void * (  )  const

bool ml::DateTime::operator! (  )  const

bool ml::DateTime::operator!= ( const DateTime dt  )  const

bool ml::DateTime::operator< ( const DateTime dt  )  const

bool ml::DateTime::operator<= ( const DateTime dt  )  const

DateTime& ml::DateTime::operator= ( const DateTime dt  ) 

bool ml::DateTime::operator== ( const DateTime dt  )  const

bool ml::DateTime::operator> ( const DateTime dt  )  const

bool ml::DateTime::operator>= ( const DateTime dt  )  const

DateTimeFloatType ml::DateTime::second (  )  const

DateTimeFloatType ml::DateTime::secondsSince ( const DateTime dateTime  )  const

bool ml::DateTime::set ( DateTimeIntType  linDaysV,
DateTimeFloatType  linSecondsV 
)

bool ml::DateTime::set ( const char *  dtString,
const char *  format = 0 
)

bool ml::DateTime::set ( DateTimeIntType  yearV,
DateTimeIntType  monthV,
DateTimeIntType  dayV,
DateTimeIntType  hourV = 0,
DateTimeIntType  minuteV = 0,
DateTimeFloatType  secondV = 0 
)

bool ml::DateTime::setHMS ( DateTimeIntType  hourV,
DateTimeIntType  minuteV,
DateTimeFloatType  secondV 
)

bool ml::DateTime::setYMD ( DateTimeIntType  yearV,
DateTimeIntType  monthV,
DateTimeIntType  dayV 
)

static bool ml::DateTime::validHMS ( DateTimeIntType  hourV,
DateTimeIntType  minuteV,
DateTimeFloatType  secondV 
) [static]

static bool ml::DateTime::validYMD ( DateTimeIntType  yearV,
DateTimeIntType  monthV,
DateTimeIntType  dayV 
) [static]

DateTimeIntType ml::DateTime::year (  )  const


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

Generated on Sat Sep 3 18:39:37 2011 for MeVisLab Toolbox Reference by  doxygen 1.5.8