libcommonc++  0.7
DateTime Class Reference

A representation of a calendar date and clock time. More...

#include <DateTime.h++>

Inheritance diagram for DateTime:
Collaboration diagram for DateTime:

Public Types

enum  Weekday {
  Invalid = 0, Monday, Tuesday, Wednesday,
  Thursday, Friday, Saturday, Sunday
}
 

Public Member Functions

 DateTime (time_s_t time)
 Construct a DateTime for the given system time. More...
 
 DateTime (time_ms_t time=0)
 Construct a DateTime for the given time (or the current time). More...
 
 DateTime (uint_t day, uint_t month, uint_t year, uint_t hour=0, uint_t minute=0, uint_t second=0, uint_t msec=0)
 Construct a DateTime with the given components. More...
 
 DateTime (const Date &date, const Time &time)
 Construct a DateTime from the given Date and Time. More...
 
 DateTime (const Date &date)
 Construct a DateTime for the given Date. More...
 
 DateTime (const Time &time)
 Construct a DateTime for the given Time. More...
 
 DateTime (const DateTime &other)
 Copy constructor. More...
 
virtual ~DateTime ()
 Destructor. More...
 
DateTimenormalize ()
 Normalize the DateTime. More...
 
 operator time_s_t () const
 Cast operator. More...
 
 operator time_ms_t () const
 Cast operator. More...
 
bool operator== (const DateTime &other) const
 
bool operator< (const DateTime &other) const
 
bool operator<= (const DateTime &other) const
 
bool operator!= (const DateTime &other) const
 
bool operator> (const DateTime &other) const
 
bool operator>= (const DateTime &other) const
 
DateTimeoperator= (time_s_t other)
 
DateTimeoperator= (time_ms_t other)
 
DateTimeoperator= (const DateTime &other)
 
void setTime (uint_t hour, uint_t minute, uint_t second=0, uint_t msec=0)
 Set the hour, minute, second, and millisecond components of the time. More...
 
void setDate (uint_t day, uint_t month, uint_t year)
 Set the day, month, and year components of the date. More...
 
DateTimesetDate (const Date &other)
 Set the date portion of the DateTime. More...
 
DateTimesetTime (const Time &other)
 Set the time portion of the DateTime. More...
 
DateTimeoperator+= (const TimeSpan &span)
 Add a TimeSpan to this DateTime. More...
 
DateTimeoperator-= (const TimeSpan &span)
 Subtract a TimeSpan from this DateTime. More...
 
void setMonth (uint_t month)
 Set the month component of the date. More...
 
void setDay (uint_t day)
 Set the day-of-month component of the date. More...
 
void setYear (uint_t year)
 Set the year component of the date. More...
 
uint_t getMonth () const
 Get the month component of the date. More...
 
uint_t getDay () const
 Get the day-of-month component of the date. More...
 
uint_t getYear () const
 Get the year component of the date. More...
 
Weekday getWeekday () const
 Get the weekday of the date. More...
 
uint_t getDayOfYear () const
 Get the day of the year. More...
 
uint_t getWeekOfYear () const
 Get the week number of the year, where weeks are defined as beginning on Monday (ISO standard). More...
 
bool isValid () const
 Test if the date is valid. More...
 
bool operator== (const Date &other) const
 
bool operator< (const Date &other) const
 
bool operator<= (const Date &other) const
 
bool operator!= (const Date &other) const
 
bool operator> (const Date &other) const
 
bool operator>= (const Date &other) const
 
void setHour (uint_t hour)
 Set the hour component of the time. More...
 
void setHour12 (uint_t hour, bool pm=false)
 Set the hour component of the time (12-hour clock). More...
 
void setMinute (uint_t minute)
 Set the minute component of the time. More...
 
void setSecond (uint_t second)
 Set the second component of the time. More...
 
void setMillisecond (uint_t msec)
 Set the millisecond component of the time. More...
 
uint_t getHour () const
 Get the hour component of the time. More...
 
uint_t getHour12 () const
 Get the hour component of the time (12-hour clock). More...
 
bool isPM () const
 Test if the hour is post meridiem. More...
 
bool isAM () const
 Test if the hour is ante meridiem. More...
 
uint_t getMinute () const
 Get the minute component of the time. More...
 
uint_t getSecond () const
 Get the second component of the time. More...
 
uint_t getMillisecond () const
 Get the millisecond component of the time. More...
 
bool operator== (const Time &other) const
 
bool operator< (const Time &other) const
 
bool operator<= (const Time &other) const
 
bool operator!= (const Time &other) const
 
bool operator> (const Time &other) const
 
bool operator>= (const Time &other) const
 

Static Public Member Functions

static bool isDSTActive ()
 Test if Daylight Saving Time is in effect for the current local time. More...
 
static int getGMTOffset ()
 Get the offset, in seconds, between local time and GMT. More...
 
static String getTimeZone ()
 Get the name of the local time zone. More...
 
static bool isLeapYear (uint_t year)
 Test if a year is a leap year. More...
 

Static Public Attributes

static const uint_t JAN = 1
 The month of January. More...
 
static const uint_t FEB = 2
 The month of February. More...
 
static const uint_t MAR = 3
 The month of March. More...
 
static const uint_t APR = 4
 The month of April. More...
 
static const uint_t MAY = 5
 The month of May. More...
 
static const uint_t JUN = 6
 The month of June. More...
 
static const uint_t JUL = 7
 The month of July. More...
 
static const uint_t AUG = 8
 The month of August. More...
 
static const uint_t SEP = 9
 The month of September. More...
 
static const uint_t OCT = 10
 The month of October. More...
 
static const uint_t NOV = 11
 The month of November. More...
 
static const uint_t DEC = 12
 The month of December. More...
 

Detailed Description

A representation of a calendar date and clock time.

Author
Mark Lindner

Member Enumeration Documentation

◆ Weekday

enum Weekday
inherited
Enumerator
Invalid 
Monday 
Tuesday 
Wednesday 
Thursday 
Friday 
Saturday 
Sunday 

Constructor & Destructor Documentation

◆ DateTime() [1/7]

DateTime ( time_s_t  time)

Construct a DateTime for the given system time.

◆ DateTime() [2/7]

DateTime ( time_ms_t  time = 0)

Construct a DateTime for the given time (or the current time).

◆ DateTime() [3/7]

DateTime ( uint_t  day,
uint_t  month,
uint_t  year,
uint_t  hour = 0,
uint_t  minute = 0,
uint_t  second = 0,
uint_t  msec = 0 
)

Construct a DateTime with the given components.

◆ DateTime() [4/7]

DateTime ( const Date date,
const Time time 
)

Construct a DateTime from the given Date and Time.

◆ DateTime() [5/7]

DateTime ( const Date date)

Construct a DateTime for the given Date.

◆ DateTime() [6/7]

DateTime ( const Time time)

Construct a DateTime for the given Time.

◆ DateTime() [7/7]

DateTime ( const DateTime other)

Copy constructor.

◆ ~DateTime()

~DateTime ( )
virtual

Destructor.

Member Function Documentation

◆ getDay()

uint_t getDay ( ) const
inlineinherited

Get the day-of-month component of the date.

◆ getDayOfYear()

uint_t getDayOfYear ( ) const
inherited

Get the day of the year.

◆ getGMTOffset()

int getGMTOffset ( )
static

Get the offset, in seconds, between local time and GMT.

◆ getHour()

uint_t getHour ( ) const
inlineinherited

Get the hour component of the time.

◆ getHour12()

uint_t getHour12 ( ) const
inlineinherited

Get the hour component of the time (12-hour clock).

◆ getMillisecond()

uint_t getMillisecond ( ) const
inlineinherited

Get the millisecond component of the time.

◆ getMinute()

uint_t getMinute ( ) const
inlineinherited

Get the minute component of the time.

◆ getMonth()

uint_t getMonth ( ) const
inlineinherited

Get the month component of the date.

◆ getSecond()

uint_t getSecond ( ) const
inlineinherited

Get the second component of the time.

◆ getTimeZone()

String getTimeZone ( )
static

Get the name of the local time zone.

◆ getWeekday()

Date::Weekday getWeekday ( ) const
inherited

Get the weekday of the date.

◆ getWeekOfYear()

uint_t getWeekOfYear ( ) const
inherited

Get the week number of the year, where weeks are defined as beginning on Monday (ISO standard).

◆ getYear()

uint_t getYear ( ) const
inlineinherited

Get the year component of the date.

◆ isAM()

bool isAM ( ) const
inlineinherited

Test if the hour is ante meridiem.

◆ isDSTActive()

bool isDSTActive ( )
static

Test if Daylight Saving Time is in effect for the current local time.

◆ isLeapYear()

bool isLeapYear ( uint_t  year)
staticinherited

Test if a year is a leap year.

◆ isPM()

bool isPM ( ) const
inlineinherited

Test if the hour is post meridiem.

◆ isValid()

bool isValid ( ) const
inherited

Test if the date is valid.

◆ normalize()

DateTime & normalize ( )

Normalize the DateTime.

This method converts invalid dates into valid dates. For example, a date of "February 31, 2000" is normalized to "March 2, 2000".

◆ operator time_ms_t()

operator time_ms_t ( ) const

Cast operator.

◆ operator time_s_t()

operator time_s_t ( ) const

Cast operator.

◆ operator!=() [1/3]

bool operator!= ( const DateTime other) const
inline

◆ operator!=() [2/3]

bool operator!= ( const Time other) const
inlineinherited

◆ operator!=() [3/3]

bool operator!= ( const Date other) const
inlineinherited

◆ operator+=()

DateTime & operator+= ( const TimeSpan span)

Add a TimeSpan to this DateTime.

◆ operator-=()

DateTime & operator-= ( const TimeSpan span)

Subtract a TimeSpan from this DateTime.

◆ operator<() [1/3]

bool operator< ( const DateTime other) const

◆ operator<() [2/3]

bool operator< ( const Time other) const
inherited

◆ operator<() [3/3]

bool operator< ( const Date other) const
inherited

◆ operator<=() [1/3]

bool operator<= ( const DateTime other) const

◆ operator<=() [2/3]

bool operator<= ( const Time other) const
inherited

◆ operator<=() [3/3]

bool operator<= ( const Date other) const
inherited

◆ operator=() [1/3]

DateTime & operator= ( time_s_t  other)

◆ operator=() [2/3]

DateTime & operator= ( time_ms_t  other)

◆ operator=() [3/3]

DateTime & operator= ( const DateTime other)

◆ operator==() [1/3]

bool operator== ( const DateTime other) const

◆ operator==() [2/3]

bool operator== ( const Time other) const
inherited

◆ operator==() [3/3]

bool operator== ( const Date other) const
inherited

◆ operator>() [1/3]

bool operator> ( const DateTime other) const
inline

◆ operator>() [2/3]

bool operator> ( const Time other) const
inlineinherited

◆ operator>() [3/3]

bool operator> ( const Date other) const
inlineinherited

◆ operator>=() [1/3]

bool operator>= ( const DateTime other) const
inline

◆ operator>=() [2/3]

bool operator>= ( const Time other) const
inlineinherited

◆ operator>=() [3/3]

bool operator>= ( const Date other) const
inlineinherited

◆ setDate() [1/2]

void setDate ( uint_t  day,
uint_t  month,
uint_t  year 
)
inline

Set the day, month, and year components of the date.

◆ setDate() [2/2]

DateTime & setDate ( const Date other)

Set the date portion of the DateTime.

◆ setDay()

void setDay ( uint_t  day)
inherited

Set the day-of-month component of the date.

◆ setHour()

void setHour ( uint_t  hour)
inherited

Set the hour component of the time.

◆ setHour12()

void setHour12 ( uint_t  hour,
bool  pm = false 
)
inherited

Set the hour component of the time (12-hour clock).

◆ setMillisecond()

void setMillisecond ( uint_t  msec)
inherited

Set the millisecond component of the time.

◆ setMinute()

void setMinute ( uint_t  minute)
inherited

Set the minute component of the time.

◆ setMonth()

void setMonth ( uint_t  month)
inherited

Set the month component of the date.

◆ setSecond()

void setSecond ( uint_t  second)
inherited

Set the second component of the time.

◆ setTime() [1/2]

void setTime ( uint_t  hour,
uint_t  minute,
uint_t  second = 0,
uint_t  msec = 0 
)
inline

Set the hour, minute, second, and millisecond components of the time.

◆ setTime() [2/2]

DateTime & setTime ( const Time other)

Set the time portion of the DateTime.

◆ setYear()

void setYear ( uint_t  year)
inherited

Set the year component of the date.

Member Data Documentation

◆ APR

const uint_t APR = 4
staticinherited

The month of April.

◆ AUG

const uint_t AUG = 8
staticinherited

The month of August.

◆ DEC

const uint_t DEC = 12
staticinherited

The month of December.

◆ FEB

const uint_t FEB = 2
staticinherited

The month of February.

◆ JAN

const uint_t JAN = 1
staticinherited

The month of January.

◆ JUL

const uint_t JUL = 7
staticinherited

The month of July.

◆ JUN

const uint_t JUN = 6
staticinherited

The month of June.

◆ MAR

const uint_t MAR = 3
staticinherited

The month of March.

◆ MAY

const uint_t MAY = 5
staticinherited

The month of May.

◆ NOV

const uint_t NOV = 11
staticinherited

The month of November.

◆ OCT

const uint_t OCT = 10
staticinherited

The month of October.

◆ SEP

const uint_t SEP = 9
staticinherited

The month of September.


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