KAlarmCal::DateTime

#include <datetime.h>

Public Member Functions

 DateTime ()
 
 DateTime (const QDate &d, const KADateTime::Spec &spec)
 
 DateTime (const QDate &d, const QTime &t, const KADateTime::Spec &spec)
 
 DateTime (const QDateTime &dt, const KADateTime::Spec &spec)
 
 DateTime (const QDateTime &dt)
 
 DateTime (const KADateTime &dt)
 
 DateTime (const DateTime &dt)
 
DateTime addDays (int n) const
 
DateTime addMins (qint64 n) const
 
DateTime addMonths (int n) const
 
DateTime addSecs (qint64 n) const
 
DateTime addYears (int n) const
 
QDateTime calendarDateTime () const
 
KADateTime calendarKDateTime () const
 
KADateTime::Comparison compare (const DateTime &other) const
 
QDate date () const
 
int daysTo (const DateTime &dt) const
 
QDateTime effectiveDateTime () const
 
KADateTime effectiveKDateTime () const
 
QTime effectiveTime () const
 
QString formatLocale (bool shortFormat=true) const
 
bool isDateOnly () const
 
bool isLocalZone () const
 
bool isNull () const
 
bool isOffsetFromUtc () const
 
bool isSecondOccurrence () const
 
bool isUtc () const
 
bool isValid () const
 
KADateTime kDateTime () const
 
int minsTo (const DateTime &dt) const
 
DateTimeoperator= (const DateTime &dt)
 
DateTimeoperator= (const KADateTime &dt)
 
QDateTime qDateTime () const
 
int secsTo (const DateTime &dt) const
 
qint64 secsTo_long (const DateTime &dt) const
 
void setDate (const QDate &d)
 
void setDateOnly (bool d)
 
void setSecondOccurrence (bool second)
 
void setSecsSinceEpoch (qint64 secs)
 
void setTime (const QTime &t)
 
KALARMCAL_DEPRECATED void setTime_t (uint secs)
 
void setTimeSpec (const KADateTime::Spec &spec)
 
KADateTime::Spec timeSpec () const
 
KADateTime::SpecType timeType () const
 
QTimeZone timeZone () const
 
DateTime toLocalZone () const
 
DateTime toOffsetFromUtc () const
 
DateTime toOffsetFromUtc (int utcOffset) const
 
qint64 toSecsSinceEpoch () const
 
QString toString (KADateTime::TimeFormat f=KADateTime::QtTextDate) const
 
QString toString (const QString &format) const
 
KALARMCAL_DEPRECATED uint toTime_t () const
 
DateTime toTimeSpec (const KADateTime::Spec &spec) const
 
DateTime toUtc () const
 
DateTime toZone (const QTimeZone &zone) const
 
int utcOffset () const
 

Static Public Member Functions

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

Friends

KALARMCAL_EXPORT friend bool operator< (const KAlarmCal::DateTime &dt1, const KAlarmCal::DateTime &dt2)
 
bool operator< (const KADateTime &dt1, const KAlarmCal::DateTime &dt2)
 
KALARMCAL_EXPORT friend bool operator== (const KAlarmCal::DateTime &dt1, const KAlarmCal::DateTime &dt2)
 
KALARMCAL_EXPORT friend bool operator== (const KADateTime &dt1, const KAlarmCal::DateTime &dt2)
 

Detailed Description

As KADateTime, but with a configurable start-of-day time for date-only values.

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

DateTime is very similar to the KADateTime class. The time assumed for date-only values is the start-of-day time set by setStartOfDay().

Author
David Jarvie djarv[email protected][email protected][email protected]de.or[email protected]g

Definition at line 29 of file datetime.h.

Constructor & Destructor Documentation

KAlarmCal::DateTime::DateTime ( )

Default constructor.

Constructs an invalid date-time.

Definition at line 33 of file datetime.cpp.

KAlarmCal::DateTime::DateTime ( const QDate d,
const KADateTime::Spec spec 
)

Constructor for a date-only value.

Definition at line 38 of file datetime.cpp.

KAlarmCal::DateTime::DateTime ( const QDate d,
const QTime t,
const KADateTime::Spec spec 
)

Constructor for a date-time value.

Definition at line 43 of file datetime.cpp.

KAlarmCal::DateTime::DateTime ( const QDateTime dt,
const KADateTime::Spec spec 
)

Constructor for a date-time value.

Definition at line 48 of file datetime.cpp.

KAlarmCal::DateTime::DateTime ( const QDateTime dt)
explicit

Constructor for a date-time value.

Definition at line 53 of file datetime.cpp.

KAlarmCal::DateTime::DateTime ( const KADateTime dt)

Constructor for a date-time value.

Definition at line 58 of file datetime.cpp.

KAlarmCal::DateTime::DateTime ( const DateTime dt)

Copy constructor.

Definition at line 63 of file datetime.cpp.

Member Function Documentation

DateTime KAlarmCal::DateTime::addDays ( int  n) const

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

Definition at line 287 of file datetime.cpp.

DateTime KAlarmCal::DateTime::addMins ( qint64  n) const

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

Definition at line 282 of file datetime.cpp.

DateTime KAlarmCal::DateTime::addMonths ( int  n) const

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

Definition at line 292 of file datetime.cpp.

DateTime KAlarmCal::DateTime::addSecs ( qint64  n) const

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

Definition at line 277 of file datetime.cpp.

DateTime KAlarmCal::DateTime::addYears ( int  n) const

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

Definition at line 297 of file datetime.cpp.

QDateTime KAlarmCal::DateTime::calendarDateTime ( ) const

Returns the date and time of the value as written in the calendar.

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

Definition at line 157 of file datetime.cpp.

KADateTime KAlarmCal::DateTime::calendarKDateTime ( ) const

Returns the date and time of the value as written in the calendar.

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

Definition at line 167 of file datetime.cpp.

KADateTime::Comparison KAlarmCal::DateTime::compare ( const DateTime other) const

Compare this value with another.

Definition at line 344 of file datetime.cpp.

QDate KAlarmCal::DateTime::date ( ) const

Returns the date part of the value.

Definition at line 107 of file datetime.cpp.

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

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

Definition at line 302 of file datetime.cpp.

QDateTime KAlarmCal::DateTime::effectiveDateTime ( ) 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 137 of file datetime.cpp.

KADateTime KAlarmCal::DateTime::effectiveKDateTime ( ) 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 147 of file datetime.cpp.

QTime KAlarmCal::DateTime::effectiveTime ( ) 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 127 of file datetime.cpp.

QString KAlarmCal::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 332 of file datetime.cpp.

bool KAlarmCal::DateTime::isDateOnly ( ) const

Returns true if it is date-only value.

Definition at line 97 of file datetime.cpp.

bool KAlarmCal::DateTime::isLocalZone ( ) const

Returns whether the time zone for the date/time is the current local system time zone.

Definition at line 197 of file datetime.cpp.

bool KAlarmCal::DateTime::isNull ( ) const

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

Definition at line 87 of file datetime.cpp.

bool KAlarmCal::DateTime::isOffsetFromUtc ( ) const

Returns whether the date/time is a local time at a fixed offset from UTC.

Definition at line 207 of file datetime.cpp.

bool KAlarmCal::DateTime::isSecondOccurrence ( ) const

Returns whether the date/time is the second occurrence of this time.

Definition at line 217 of file datetime.cpp.

bool KAlarmCal::DateTime::isUtc ( ) const

Returns whether the date/time is a UTC time.

Definition at line 202 of file datetime.cpp.

bool KAlarmCal::DateTime::isValid ( ) const

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

Definition at line 92 of file datetime.cpp.

KADateTime KAlarmCal::DateTime::kDateTime ( ) const

Returns the date and time of the value as a KADateTime.

Definition at line 122 of file datetime.cpp.

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

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

Definition at line 307 of file datetime.cpp.

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

Assignment operator.

Definition at line 73 of file datetime.cpp.

DateTime & KAlarmCal::DateTime::operator= ( const KADateTime dt)

Assignment operator.

Sets the value to a specified date-time.

Definition at line 81 of file datetime.cpp.

QDateTime KAlarmCal::DateTime::qDateTime ( ) const

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 117 of file datetime.cpp.

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

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

Warning
The return value can overflow if the two values are far enough apart. Use sectTo_long() to avoid this.

Definition at line 312 of file datetime.cpp.

qint64 KAlarmCal::DateTime::secsTo_long ( const DateTime dt) const

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

Definition at line 317 of file datetime.cpp.

void KAlarmCal::DateTime::setDate ( const QDate d)

Sets the date component of the value.

Definition at line 112 of file datetime.cpp.

void KAlarmCal::DateTime::setDateOnly ( bool  d)

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 102 of file datetime.cpp.

void KAlarmCal::DateTime::setSecondOccurrence ( bool  second)

Sets whether this is the second occurrence of this date/time.

Definition at line 222 of file datetime.cpp.

void KAlarmCal::DateTime::setSecsSinceEpoch ( qint64  secs)

Sets the value to a specified date-time value.

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

Definition at line 267 of file datetime.cpp.

void KAlarmCal::DateTime::setStartOfDay ( const QTime sod)
static

Sets the start-of-day time.

The default value is midnight (0000 hrs).

Definition at line 339 of file datetime.cpp.

void KAlarmCal::DateTime::setTime ( const QTime t)

Sets the time component of the value.

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

Definition at line 132 of file datetime.cpp.

void KAlarmCal::DateTime::setTime_t ( uint  secs)

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 272 of file datetime.cpp.

void KAlarmCal::DateTime::setTimeSpec ( const KADateTime::Spec spec)

Changes the time specification of the value.

This will usually change the absolute time which this instance represents.

Definition at line 187 of file datetime.cpp.

QTime KAlarmCal::DateTime::startOfDay ( )
static

Returns the start-of-day time.

Definition at line 349 of file datetime.cpp.

KADateTime::Spec KAlarmCal::DateTime::timeSpec ( ) const

Returns the time specification of the value.

Definition at line 182 of file datetime.cpp.

KADateTime::SpecType KAlarmCal::DateTime::timeType ( ) const

Returns the time specification type of the date/time, i.e.

whether it is UTC, has a time zone, etc.

Definition at line 192 of file datetime.cpp.

QTimeZone KAlarmCal::DateTime::timeZone ( ) const

Returns the time zone of the value.

Definition at line 177 of file datetime.cpp.

DateTime KAlarmCal::DateTime::toLocalZone ( ) const

Returns the time converted to the current local system time zone.

Definition at line 242 of file datetime.cpp.

DateTime KAlarmCal::DateTime::toOffsetFromUtc ( ) const

Returns the time expressed as an offset from UTC, using the UTC offset associated with this instance's date/time.

Definition at line 232 of file datetime.cpp.

DateTime KAlarmCal::DateTime::toOffsetFromUtc ( int  utcOffset) const

Returns the time expressed as a specified offset from UTC.

Definition at line 237 of file datetime.cpp.

qint64 KAlarmCal::DateTime::toSecsSinceEpoch ( ) const

Converts the time to a UTC time, measured in seconds since 00:00:00 UTC 1st January 1970 (as returned by time(2)).

Definition at line 257 of file datetime.cpp.

QString KAlarmCal::DateTime::toString ( KADateTime::TimeFormat  f = KADateTime::QtTextDate) const

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 322 of file datetime.cpp.

QString KAlarmCal::DateTime::toString ( const QString format) const

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 327 of file datetime.cpp.

uint KAlarmCal::DateTime::toTime_t ( ) const

Converts the time to a UTC time, measured in seconds since 00:00:00 UTC 1st January 1970 (as returned by time(2)).

Definition at line 262 of file datetime.cpp.

DateTime KAlarmCal::DateTime::toTimeSpec ( const KADateTime::Spec spec) const

Returns the time converted to a new time specification.

Definition at line 252 of file datetime.cpp.

DateTime KAlarmCal::DateTime::toUtc ( ) const

Returns the time converted to UTC.

Definition at line 227 of file datetime.cpp.

DateTime KAlarmCal::DateTime::toZone ( const QTimeZone zone) const

Returns the time converted to a specified time zone.

Definition at line 247 of file datetime.cpp.

int KAlarmCal::DateTime::utcOffset ( ) const

Returns the UTC offset associated with the date/time.

Definition at line 212 of file datetime.cpp.

Friends And Related Function Documentation

KALARMCAL_EXPORT friend bool operator< ( const KAlarmCal::DateTime dt1,
const KAlarmCal::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 dialog.

Definition at line 364 of file datetime.cpp.

KALARMCAL_EXPORT friend bool operator== ( const KAlarmCal::DateTime dt1,
const KAlarmCal::DateTime dt2 
)
friend

Returns true if the two values are equal.

Definition at line 354 of file datetime.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Sep 21 2020 23:10:35 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.