KDE PIM / Developers / API Docs / kalarm

DateTime Class Reference

A QDateTime with date-only option. More...

#include <datetime.h>

List of all members.

Public Member Functions

Friends


Detailed Description

A QDateTime with date-only option.

The DateTime class holds a date, with or without a time. DateTime is very similar to the QDateTime 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.

Author:
David Jarvie <software@astrojar.org.uk>


Constructor & Destructor Documentation

DateTime::DateTime  )  [inline]
 

Default constructor.

Constructs a null date-time.

DateTime::DateTime const QDate &  d  )  [inline]
 

Constructor for a date-only value.

DateTime::DateTime const QDate &  d,
const QTime &  t
[inline]
 

Constructor for a date-time value.

DateTime::DateTime const QDateTime &  dt,
bool  dateOnly = false
[inline]
 

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

Parameters:
dateOnly True to construct a date-only value; false to construct a date-time value.

Member Function Documentation

DateTime& DateTime::operator= const DateTime dt  )  [inline]
 

Assignment operator.

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

DateTime& DateTime::operator= const QDateTime &  dt  )  [inline]
 

Assignment operator.

Sets the value to a specified date-time.

DateTime& DateTime::operator= const QDate &  d  )  [inline]
 

Assignment operator.

Sets the value to a specified date-only value.

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.

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.

bool DateTime::isDateOnly  )  const [inline]
 

Returns true if it is date-only value.

void DateTime::setDateOnly bool  d  )  [inline]
 

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

Parameters:
d True to set the value to be date-only; false to set it to a date-time value.

QDate DateTime::date  )  const [inline]
 

Returns the date part of the value.

QTime 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 in the Preferences dialogue.

QDateTime 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 in the KAlarm Preferences dialogue.

void DateTime::set const QDateTime &  dt,
bool  dateOnly = false
[inline]
 

Sets a date-time or date-only value.

Parameters:
dateOnly True to set a date-only value; false to set a date-time value.

void DateTime::set const QDate &  d,
const QTime &  t
[inline]
 

Sets a date-time value.

void DateTime::setTime const QTime &  t  )  [inline]
 

Sets the time component of the value.

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

void DateTime::setTime_t uint  secs  )  [inline]
 

Sets the value to a specified date-time value.

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

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.

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.

DateTime DateTime::addDays int  n  )  const [inline]
 

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

DateTime DateTime::addMonths int  n  )  const [inline]
 

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

DateTime DateTime::addYears int  n  )  const [inline]
 

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

int DateTime::daysTo const DateTime dt  )  const [inline]
 

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

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.

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.

QString DateTime::toString Qt::DateFormat  f = Qt::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.

QString DateTime::toString const QString &  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.

QString 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.


Friends And Related Function Documentation

bool operator== const DateTime dt1,
const DateTime dt2
[friend]
 

Returns true if the two values are equal.

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.


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