KCalendarCore::Period

KCalendarCore::Period Class Reference

#include <period.h>

Inheritance diagram for KCalendarCore::Period:

Public Types

typedef QVector< PeriodList
 

Public Member Functions

 Period ()
 
 Period (const QDateTime &start, const QDateTime &end)
 
 Period (const QDateTime &start, const Duration &duration)
 
 Period (const Period &period)
 
 ~Period ()
 
Duration duration () const
 
Duration duration (Duration::Type type) const
 
QDateTime end () const
 
bool hasDuration () const
 
bool operator!= (const Period &other) const
 
bool operator< (const Period &other) const
 
Periodoperator= (const Period &other)
 
bool operator== (const Period &other) const
 
bool operator> (const Period &other) const
 
void shiftTimes (const QTimeZone &oldZone, const QTimeZone &newZone)
 
QDateTime start () const
 

Friends

KCALENDARCORE_EXPORT QDataStreamoperator<< (QDataStream &stream, const KCalendarCore::Period &period)
 
KCALENDARCORE_EXPORT QDataStreamoperator>> (QDataStream &stream, KCalendarCore::Period &period)
 

Detailed Description

The period can be defined by either a start time and an end time or by a start time and a duration.

Definition at line 38 of file period.h.

Member Typedef Documentation

List of periods.

Definition at line 44 of file period.h.

Constructor & Destructor Documentation

Period::Period ( )

Constructs a period without a duration.

Definition at line 46 of file period.cpp.

Period::Period ( const QDateTime start,
const QDateTime end 
)

Constructs a period from start to end.

Parameters
startthe time the period begins.
endthe time the period ends.

Definition at line 50 of file period.cpp.

Period::Period ( const QDateTime start,
const Duration duration 
)

Constructs a period from start and lasting duration.

Parameters
startthe time when the period starts.
durationhow long the period lasts.

Definition at line 55 of file period.cpp.

Period::Period ( const Period period)

Constructs a period by copying another period object.

Parameters
periodthe period to copy

Definition at line 61 of file period.cpp.

Period::~Period ( )

Destroys a period.

Definition at line 66 of file period.cpp.

Member Function Documentation

Duration Period::duration ( ) const

Returns the duration of the period.

If the period is defined in terms of a start and end time, the duration is computed from these. In this case, if the time of day in start and end is equal, and their time specifications (i.e. time zone etc.) are the same, the duration will be set in terms of days. Otherwise, the duration will be set in terms of seconds.

If the period is defined in terms of a duration, that duration is returned unchanged.

Definition at line 107 of file period.cpp.

Duration Period::duration ( Duration::Type  type) const

Returns the duration of the period.

If the period is defined in terms of a start and end time, the duration is first computed from these.

If type is Days, and the duration is not an exact number of days, the duration will be rounded down to the nearest whole number of days.

Parameters
typethe unit of time to use (seconds or days)

Definition at line 117 of file period.cpp.

QDateTime Period::end ( ) const

Returns when this period ends.

Definition at line 102 of file period.cpp.

bool Period::hasDuration ( ) const

Returns true if this period has a set duration, false if it just has a start and an end.

Definition at line 122 of file period.cpp.

bool KCalendarCore::Period::operator!= ( const Period other) const
inline

Returns true if this period is not equal to the other one.

Parameters
otherthe other period to compare
See also
operator==()

Definition at line 115 of file period.h.

bool Period::operator< ( const Period other) const

Returns true if the start of this period is earlier than the start of the other one.

Parameters
otheris the other period to compare.

Definition at line 71 of file period.cpp.

Period & Period::operator= ( const Period other)

Sets this period equal to the other one.

Parameters
otheris the other period to compare.

Definition at line 86 of file period.cpp.

bool Period::operator== ( const Period other) const

Returns true if this period is equal to the other one.

Even if their start and end times are the same, two periods are considered not equal if one is defined in terms of a duration and the other in terms of a start and end time.

Parameters
otherthe other period to compare

Definition at line 76 of file period.cpp.

bool KCalendarCore::Period::operator> ( const Period other) const
inline

Returns true if the start of this period is later than the start of the other one.

Parameters
otherthe other period to compare

Definition at line 94 of file period.h.

void Period::shiftTimes ( const QTimeZone oldZone,
const QTimeZone newZone 
)

Shift the times of the period so that they appear at the same clock time as before but in a new time zone.

The shift is done from a viewing time zone rather than from the actual period time zone.

For example, shifting a period whose start time is 09:00 America/New York, using an old viewing time zone (oldSpec) of Europe/London, to a new time zone (newSpec) of Europe/Paris, will result in the time being shifted from 14:00 (which is the London time of the period start) to 14:00 Paris time.

Parameters
oldZonethe time zone which provides the clock times
newZonethe new time zone

Definition at line 127 of file period.cpp.

QDateTime Period::start ( ) const

Returns when this period starts.

Definition at line 97 of file period.cpp.

Friends And Related Function Documentation

KCALENDARCORE_EXPORT QDataStream& operator<< ( QDataStream stream,
const KCalendarCore::Period period 
)
friend

Write period to the datastream stream, in binary format.

KCALENDARCORE_EXPORT QDataStream& operator>> ( QDataStream stream,
KCalendarCore::Period period 
)
friend

Read a Period object into period from stream, in binary format.


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 Sun Aug 2 2020 22:49:47 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.