All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Radiant::DateTime Class Reference

Combination of date and time information. More...

#include <Radiant/DateTime.hpp>

Public Types

enum  DateFormat { DATE_TIME_ISO, DATE_ISO }
 Format for date & time. More...
 

Public Member Functions

TimeStamp asTimeStamp () const
 Return the date and time as a TimeStamp. More...
 
void clearTime ()
 Reset the hour, minute and second values to zero.
 
 DateTime ()
 Constructor.
 
 DateTime (const TimeStamp &ts)
 Constructs an object from time stamp. More...
 
int daysInMonth ()
 Returns the number of days in the current month. More...
 
bool fromString (const QString &s, DateFormat format=DATE_ISO)
 Read time and date from a string. More...
 
int hour () const
 Hour since midnight (0-23) More...
 
int microSecond () const
 Microseconds since last full second (0-999999) More...
 
int milliSecond () const
 Milliseconds since last full second (0-999) More...
 
int minute () const
 Minutes since last full hour (0-59) More...
 
int month () const
 Month of year (January = 0) More...
 
int monthDay () const
 Day of month (0-30) More...
 
void print (char *buf, bool isotime=false)
 Print the date-time information to a string. More...
 
int second () const
 Seconds since last full minute (0-59) More...
 
void setHour (int hour)
 Set the hour. More...
 
void setMinute (int minute)
 Set the minute. More...
 
void setMonth (int month)
 Set the month. More...
 
void setMonthDay (int monthDay)
 Set the day of the month. More...
 
void setSecond (int second)
 Set the second. More...
 
void setWeekDay (int weekDay)
 Set the day of the week. More...
 
void setYear (int year)
 Set the year. More...
 
void toNextMonth ()
 Advance time to next month.
 
void toNextMonthDay ()
 Advance time to next day of the month.
 
void toNextYear ()
 Advance time to next year.
 
int weekDay () const
 Day of week (Sunday = 0) More...
 
int year () const
 Year (anno domini) More...
 
 ~DateTime ()
 Destructor.
 

Static Public Member Functions

static int daysInMonth (int month, int year)
 Returns the number of days in the month. More...
 

Detailed Description

Combination of date and time information.

Member Enumeration Documentation

Format for date & time.

Enumerator
DATE_TIME_ISO 

Date and time in ISO-8601 format (YYYY-MM-DD-hh-mm-ss)

DATE_ISO 

Just the date in ISO-8601 format (YYYY-MM-DD)

Constructor & Destructor Documentation

Radiant::DateTime::DateTime ( const TimeStamp ts)

Constructs an object from time stamp.

Parameters
tsTimeStamp to convert

Member Function Documentation

TimeStamp Radiant::DateTime::asTimeStamp ( ) const

Return the date and time as a TimeStamp.

Returns
the date as time-stamp
static int Radiant::DateTime::daysInMonth ( int  month,
int  year 
)
static

Returns the number of days in the month.

This function does take the leap years into account, so the length of Febuary changes between 28 and 29 days, depending on the year.

Parameters
monthmonth [0-11]
yearyear number
Returns
number of days in the month
int Radiant::DateTime::daysInMonth ( )

Returns the number of days in the current month.

This method takes the leap-years into account.

Returns
number of days in the month
bool Radiant::DateTime::fromString ( const QString &  s,
DateFormat  format = DATE_ISO 
)

Read time and date from a string.

Parameters
sString to parse
formatFormat of the date
Returns
True if parsing succeeded and the date was set to the object, false otherwise.
int Radiant::DateTime::hour ( ) const
inline

Hour since midnight (0-23)

Returns
Hour
See Also
setHour
int Radiant::DateTime::microSecond ( ) const
inline

Microseconds since last full second (0-999999)

Returns
Microseconds
int Radiant::DateTime::milliSecond ( ) const
inline

Milliseconds since last full second (0-999)

Returns
Milliseconds
int Radiant::DateTime::minute ( ) const
inline

Minutes since last full hour (0-59)

Returns
Minutes
See Also
setMinute
int Radiant::DateTime::month ( ) const
inline

Month of year (January = 0)

Returns
Month
See Also
setMonth
int Radiant::DateTime::monthDay ( ) const
inline

Day of month (0-30)

Returns
Day of month
See Also
setMonthDay
void Radiant::DateTime::print ( char *  buf,
bool  isotime = false 
)

Print the date-time information to a string.

Parameters
[out]bufbuffer to write to
isotimeuse ISO time format
int Radiant::DateTime::second ( ) const
inline

Seconds since last full minute (0-59)

Returns
Seconds
See Also
setSecond
void Radiant::DateTime::setHour ( int  hour)
inline

Set the hour.

Parameters
hourHour to set
See Also
hour
void Radiant::DateTime::setMinute ( int  minute)
inline

Set the minute.

Parameters
minuteMinute to set
See Also
minute
void Radiant::DateTime::setMonth ( int  month)
inline

Set the month.

Parameters
monthMonth to set
See Also
month
void Radiant::DateTime::setMonthDay ( int  monthDay)
inline

Set the day of the month.

Parameters
monthDayDay to set
See Also
monthDay
void Radiant::DateTime::setSecond ( int  second)
inline

Set the second.

Parameters
secondSecond to set
See Also
second
void Radiant::DateTime::setWeekDay ( int  weekDay)
inline

Set the day of the week.

Parameters
weekDayWeek day to set
See Also
weekDay
void Radiant::DateTime::setYear ( int  year)
inline

Set the year.

Parameters
yearYear to set
See Also
year
int Radiant::DateTime::weekDay ( ) const
inline

Day of week (Sunday = 0)

Returns
Day of week
See Also
setWeekDay
int Radiant::DateTime::year ( ) const
inline

Year (anno domini)

Returns
Year
See Also
setYear