kalarm/lib

#include <datetime.h>

Public Member Functions

 DateTime ()
 
 DateTime (const TQDate &d)
 
 DateTime (const TQDate &d, const TQTime &t)
 
 DateTime (const TQDateTime &dt, bool dateOnly=false)
 
DateTimeoperator= (const DateTime &dt)
 
DateTimeoperator= (const TQDateTime &dt)
 
DateTimeoperator= (const TQDate &d)
 
bool isNull () const
 
bool isValid () const
 
bool isDateOnly () const
 
void setDateOnly (bool d)
 
TQDate date () const
 
TQTime time () const
 
TQDateTime dateTime () const
 
TQDateTime rawDateTime () const
 
void set (const TQDateTime &dt, bool dateOnly=false)
 
void set (const TQDate &d, const TQTime &t)
 
void setTime (const TQTime &t)
 
void setTime_t (uint secs)
 
DateTime addSecs (int n) const
 
DateTime addMins (int n) const
 
DateTime addDays (int n) const
 
DateTime addMonths (int n) const
 
DateTime addYears (int n) const
 
int daysTo (const DateTime &dt) const
 
int minsTo (const DateTime &dt) const
 
int secsTo (const DateTime &dt) const
 
TQString toString (TQt::DateFormat f=TQt::TextDate) const
 
TQString toString (const TQString &format) const
 
TQString formatLocale (bool shortFormat=true) const
 

Static Public Member Functions

static void setStartOfDay (const TQTime &sod)
 
static TQTime startOfDay ()
 

Friends

bool operator== (const DateTime &dt1, const DateTime &dt2)
 
bool operator< (const DateTime &dt1, const DateTime &dt2)
 

Detailed Description

A TQDateTime with date-only option.

The DateTime class holds a date, with or without a time.

DateTime is very similar to the TQDateTime class, with the additional option to hold a date-only value. This allows a single date-time representation to be used for both an event having a specific date and time, and an all-day event.

The time assumed for date-only values is the start-of-day time set by setStartOfDay().

Author
David Jarvie softw.nosp@m.are@.nosp@m.astro.nosp@m.jar..nosp@m.org.u.nosp@m.k

Definition at line 39 of file datetime.h.

Constructor & Destructor Documentation

◆ DateTime() [1/4]

DateTime::DateTime ( )
inline

Default constructor.

Constructs an invalid date-time.

Definition at line 45 of file datetime.h.

◆ DateTime() [2/4]

DateTime::DateTime ( const TQDate &  d)
inline

Constructor for a date-only value.

Definition at line 47 of file datetime.h.

◆ DateTime() [3/4]

DateTime::DateTime ( const TQDate &  d,
const TQTime &  t 
)
inline

Constructor for a date-time value.

Definition at line 49 of file datetime.h.

◆ DateTime() [4/4]

DateTime::DateTime ( const TQDateTime &  dt,
bool  dateOnly = false 
)
inline

Constructor for a date-time or date-only value.

Parameters
dtthe date and time to use.
dateOnlyTrue to construct a date-only value; false to construct a date-time value.

Definition at line 55 of file datetime.h.

Member Function Documentation

◆ addDays()

DateTime DateTime::addDays ( int  n) const
inline

Returns a DateTime value n days later than the value of this object.

Definition at line 148 of file datetime.h.

◆ addMins()

DateTime DateTime::addMins ( int  n) const
inline

Returns a DateTime value mins minutes later than the value of this object.

If this object is date-only, mins is first rounded down to a whole number of days before adding the value.

Definition at line 140 of file datetime.h.

◆ addMonths()

DateTime DateTime::addMonths ( int  n) const
inline

Returns a DateTime value n months later than the value of this object.

Definition at line 150 of file datetime.h.

◆ addSecs()

DateTime DateTime::addSecs ( int  n) const
inline

Returns a DateTime value secs seconds later than the value of this object.

If this object is date-only, secs is first rounded down to a whole number of days before adding the value.

Definition at line 129 of file datetime.h.

◆ addYears()

DateTime DateTime::addYears ( int  n) const
inline

Returns a DateTime value n years later than the value of this object.

Definition at line 152 of file datetime.h.

◆ date()

TQDate DateTime::date ( ) const
inline

Returns the date part of the value.

Definition at line 87 of file datetime.h.

◆ dateTime()

TQDateTime DateTime::dateTime ( ) const

Returns the date and time of the value.

If the value is date-only, the time part returned is equal to the start-of-day time set by setStartOfDay().

Definition at line 34 of file datetime.cpp.

◆ daysTo()

int DateTime::daysTo ( const DateTime dt) const
inline

Returns the number of days from this date or date-time to dt.

Definition at line 154 of file datetime.h.

◆ formatLocale()

TQString DateTime::formatLocale ( bool  shortFormat = true) const

Returns the value as a string, formatted according to the user's locale.

If it is a date-time, both time and date are included in the output. If it is date-only, only the date is included in the output.

Definition at line 39 of file datetime.cpp.

◆ isDateOnly()

bool DateTime::isDateOnly ( ) const
inline

Returns true if it is date-only value.

Definition at line 78 of file datetime.h.

◆ isNull()

bool DateTime::isNull ( ) const
inline

Returns true if the date is null and, if it is a date-time value, the time is also null.

Definition at line 74 of file datetime.h.

◆ isValid()

bool DateTime::isValid ( ) const
inline

Returns true if the date is valid and, if it is a date-time value, the time is also valid.

Definition at line 76 of file datetime.h.

◆ minsTo()

int DateTime::minsTo ( const DateTime dt) const
inline

Returns the number of minutes from this date or date-time to dt.

If either of the values is date-only, the result is calculated by simply taking the difference in dates and ignoring the times.

Definition at line 160 of file datetime.h.

◆ operator=() [1/3]

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

Assignment operator.

Sets the value to a specified date-time or date-only value.

Definition at line 61 of file datetime.h.

◆ operator=() [2/3]

DateTime& DateTime::operator= ( const TQDate &  d)
inline

Assignment operator.

Sets the value to a specified date-only value.

Definition at line 71 of file datetime.h.

◆ operator=() [3/3]

DateTime& DateTime::operator= ( const TQDateTime &  dt)
inline

Assignment operator.

Sets the value to a specified date-time.

Definition at line 66 of file datetime.h.

◆ rawDateTime()

TQDateTime DateTime::rawDateTime ( ) const
inline

Returns the date and time of the value.

if the value is date-only, the time part returned is 00:00:00.

Definition at line 100 of file datetime.h.

◆ secsTo()

int DateTime::secsTo ( const DateTime dt) const
inline

Returns the number of seconds from this date or date-time to dt.

If either of the values is date-only, the result is calculated by simply taking the difference in dates and ignoring the times.

Definition at line 166 of file datetime.h.

◆ set() [1/2]

void DateTime::set ( const TQDate &  d,
const TQTime &  t 
)
inline

Sets a date-time value.

Definition at line 114 of file datetime.h.

◆ set() [2/2]

void DateTime::set ( const TQDateTime &  dt,
bool  dateOnly = false 
)
inline

Sets a date-time or date-only value.

Parameters
dtthe date-time to use.
dateOnlyTrue to set a date-only value; false to set a date-time value.

Definition at line 105 of file datetime.h.

◆ setDateOnly()

void DateTime::setDateOnly ( bool  d)
inline

Sets the value to be either date-only or date-time.

Parameters
dTrue to set the value to be date-only; false to set it to a date-time value.

Definition at line 82 of file datetime.h.

◆ setStartOfDay()

static void DateTime::setStartOfDay ( const TQTime &  sod)
inlinestatic

Sets the start-of-day time.

The default value is midnight (0000 hrs).

Definition at line 202 of file datetime.h.

◆ setTime()

void DateTime::setTime ( const TQTime &  t)
inline

Sets the time component of the value.

The value is converted if necessary to be a date-time value.

Definition at line 119 of file datetime.h.

◆ setTime_t()

void DateTime::setTime_t ( uint  secs)
inline

Sets the value to a specified date-time value.

Parameters
secsThe time_t date-time value, expressed as the number of seconds elapsed since 1970-01-01 00:00:00 UTC.

Definition at line 124 of file datetime.h.

◆ startOfDay()

static TQTime DateTime::startOfDay ( )
inlinestatic

Returns the start-of-day time.

Definition at line 204 of file datetime.h.

◆ time()

TQTime DateTime::time ( ) const

Returns the time part of the value.

If the value is date-only, the time returned is the start-of-day time set by setStartOfDay().

Definition at line 29 of file datetime.cpp.

◆ toString() [1/2]

TQString DateTime::toString ( const TQString &  format) const
inline

Returns the value as a string.

If it is a date-time, both time and date are included in the output. If it is date-only, only the date is included in the output.

Definition at line 185 of file datetime.h.

◆ toString() [2/2]

TQString DateTime::toString ( TQt::DateFormat  f = TQt::TextDate) const
inline

Returns the value as a string.

If it is a date-time, both time and date are included in the output. If it is date-only, only the date is included in the output.

Definition at line 172 of file datetime.h.

Friends And Related Function Documentation

◆ operator<

bool operator< ( const DateTime dt1,
const DateTime dt2 
)
friend

Returns true if the dt1 is earlier than dt2.

If the two values have the same date, and one value is date-only while the other is a date-time, the time used for the date-only value is the start-of-day time set in the KAlarm Preferences dialogue.

Definition at line 68 of file datetime.cpp.

◆ operator==

bool operator== ( const DateTime dt1,
const DateTime dt2 
)
friend

Returns true if the two values are equal.

Definition at line 49 of file datetime.cpp.


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