• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

KCalCore Library

  • KCalCore
  • Duration
Public Types | Public Member Functions | Friends | List of all members
KCalCore::Duration Class Reference

#include <duration.h>

Public Types

enum  Type { Seconds, Days }
 

Public Member Functions

 Duration ()
 
 Duration (const KDateTime &start, const KDateTime &end)
 
 Duration (const KDateTime &start, const KDateTime &end, Type type)
 
 Duration (int duration, Type type=Seconds)
 
 Duration (const Duration &duration)
 
 ~Duration ()
 
int asDays () const
 
int asSeconds () const
 
KDateTime end (const KDateTime &start) const
 
bool isDaily () const
 
 operator bool () const
 
bool operator! () const
 
bool operator!= (const Duration &other) const
 
Duration operator* (int value) const
 
Duration & operator*= (int value)
 
Duration operator+ (const Duration &other) const
 
Duration & operator+= (const Duration &other)
 
Duration operator- () const
 
Duration operator- (const Duration &other) const
 
Duration & operator-= (const Duration &other)
 
Duration operator/ (int value) const
 
Duration & operator/= (int value)
 
bool operator< (const Duration &other) const
 
bool operator<= (const Duration &other) const
 
Duration & operator= (const Duration &duration)
 
bool operator== (const Duration &other) const
 
bool operator> (const Duration &other) const
 
bool operator>= (const Duration &other) const
 
Type type () const
 
int value () const
 

Friends

KCALCORE_EXPORT QDataStream & operator<< (QDataStream &s, const KCalCore::Duration &)
 
KCALCORE_EXPORT QDataStream & operator>> (QDataStream &s, KCalCore::Duration &)
 

Detailed Description

Represents a span of time measured in seconds or days.

A duration is a span of time measured in seconds or days. Construction can be done by specifying a stop and end time, or simply by specifying the number of seconds or days.

Much of the time, it does not matter whether a duration is specified in seconds or in days. But it does make a difference when a duration is used to define a time period encompassing a daylight saving time change.

Definition at line 55 of file duration.h.

Member Enumeration Documentation

enum KCalCore::Duration::Type

The unit of time used to define the duration.

Enumerator
Seconds 

duration is a number of seconds

Days 

duration is a number of days

Definition at line 61 of file duration.h.

Constructor & Destructor Documentation

Duration::Duration ( )

Constructs a duration of 0 seconds.

Private class that helps to provide binary compatibility between releases.

Definition at line 56 of file duration.cpp.

Duration::Duration ( const KDateTime &  start,
const KDateTime &  end 
)

Constructs a duration from start to end.

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.

Parameters
startis the time the duration begins.
endis the time the duration ends.

Definition at line 61 of file duration.cpp.

Duration::Duration ( const KDateTime &  start,
const KDateTime &  end,
Type  type 
)

Constructs a duration from start to end.

If type is Days, and the time of day in start's time zone differs between start and end, the duration will be rounded down to the nearest whole number of days.

Parameters
startis the time the duration begins.
endis the time the duration ends.
typethe unit of time to use (seconds or days)

Definition at line 73 of file duration.cpp.

Duration::Duration ( int  duration,
Type  type = Seconds 
)

Constructs a duration with a number of seconds or days.

Parameters
durationthe number of seconds or days in the duration
typethe unit of time to use (seconds or days)

Definition at line 98 of file duration.cpp.

Duration::Duration ( const Duration &  duration)

Constructs a duration by copying another duration object.

Parameters
durationis the duration to copy.

Definition at line 105 of file duration.cpp.

Duration::~Duration ( )

Destroys a duration.

Definition at line 110 of file duration.cpp.

Member Function Documentation

int Duration::asDays ( ) const

Returns the length of the duration in days.

If the duration is not an exact number of days, it is rounded down to return the number of whole days.

Definition at line 205 of file duration.cpp.

int Duration::asSeconds ( ) const

Returns the length of the duration in seconds.

Definition at line 200 of file duration.cpp.

KDateTime Duration::end ( const KDateTime &  start) const

Computes a duration end time by adding the number of seconds or days in the duration to the specified start time.

Parameters
startis the start time.
Returns
end time.

Definition at line 184 of file duration.cpp.

bool Duration::isDaily ( ) const

Returns whether the duration is specified in terms of days rather than seconds.

Definition at line 195 of file duration.cpp.

Duration::operator bool ( ) const

Returns true if this duration is non-zero.

Definition at line 126 of file duration.cpp.

bool KCalCore::Duration::operator! ( ) const
inline

Returns true if this duration is zero.

Definition at line 133 of file duration.h.

bool KCalCore::Duration::operator!= ( const Duration &  other) const
inline

Returns true if this duration is not equal to the other.

Daily and non-daily durations are always considered unequal, since a day's duration may differ from 24 hours if it happens to span a daylight saving time change.

Parameters
otheris the other duration to compare.

Definition at line 186 of file duration.h.

Duration KCalCore::Duration::operator* ( int  value) const
inline

Multiplies a duration by a value.

Parameters
valuevalue to multiply by
Returns
resultant duration

Definition at line 251 of file duration.h.

Duration & Duration::operator*= ( int  value)

Multiplies this duration by a value.

Parameters
valuevalue to multiply by

Definition at line 172 of file duration.cpp.

Duration KCalCore::Duration::operator+ ( const Duration &  other) const
inline

Adds two durations.

If one is in terms of days and the other in terms of seconds, the result is in terms of seconds.

Parameters
otherthe other duration to add
Returns
combined duration

Definition at line 207 of file duration.h.

Duration & Duration::operator+= ( const Duration &  other)

Adds another duration to this one.

If one is in terms of days and the other in terms of seconds, the result is in terms of seconds.

Parameters
otherthe other duration to add

Definition at line 149 of file duration.cpp.

Duration Duration::operator- ( ) const

Returns the negative of this duration.

Definition at line 162 of file duration.cpp.

Duration KCalCore::Duration::operator- ( const Duration &  other) const
inline

Returns the difference between another duration and this.

If one is in terms of days and the other in terms of seconds, the result is in terms of seconds.

Parameters
otherthe other duration to subtract
Returns
difference in durations

Definition at line 234 of file duration.h.

Duration & Duration::operator-= ( const Duration &  other)

Subtracts another duration from this one.

If one is in terms of days and the other in terms of seconds, the result is in terms of seconds.

Parameters
otherthe other duration to subtract

Definition at line 167 of file duration.cpp.

Duration KCalCore::Duration::operator/ ( int  value) const
inline

Divides a duration by a value.

Parameters
valuevalue to divide by
Returns
resultant duration

Definition at line 268 of file duration.h.

Duration & Duration::operator/= ( int  value)

Divides this duration by a value.

Parameters
valuevalue to divide by

Definition at line 178 of file duration.cpp.

bool Duration::operator< ( const Duration &  other) const

Returns true if this duration is smaller than the other.

Parameters
otheris the other duration to compare.

Definition at line 131 of file duration.cpp.

bool KCalCore::Duration::operator<= ( const Duration &  other) const
inline

Returns true if this duration is smaller than or equal to the other.

Parameters
otheris the other duration to compare.

Definition at line 147 of file duration.h.

Duration & Duration::operator= ( const Duration &  duration)

Sets this duration equal to duration.

Parameters
durationis the duration to copy.

Definition at line 115 of file duration.cpp.

bool Duration::operator== ( const Duration &  other) const

Returns true if this duration is equal to the other.

Daily and non-daily durations are always considered unequal, since a day's duration may differ from 24 hours if it happens to span a daylight saving time change.

Parameters
otherthe other duration to compare

Definition at line 140 of file duration.cpp.

bool KCalCore::Duration::operator> ( const Duration &  other) const
inline

Returns true if this duration is greater than the other.

Parameters
otheris the other duration to compare.

Definition at line 156 of file duration.h.

bool KCalCore::Duration::operator>= ( const Duration &  other) const
inline

Returns true if this duration is greater than or equal to the other.

Parameters
otheris the other duration to compare.

Definition at line 165 of file duration.h.

Duration::Type Duration::type ( ) const

Returns the time units (seconds or days) used to specify the duration.

Definition at line 190 of file duration.cpp.

int Duration::value ( ) const

Returns the length of the duration in seconds or days.

Returns
if isDaily(), duration in days, else duration in seconds

Definition at line 210 of file duration.cpp.

Friends And Related Function Documentation

KCALCORE_EXPORT QDataStream& operator<< ( QDataStream &  s,
const KCalCore::Duration &   
)
friend

Duration serializer.

Since
4.12
KCALCORE_EXPORT QDataStream& operator>> ( QDataStream &  s,
KCalCore::Duration &   
)
friend

Duration deserializer.

Since
4.12

The documentation for this class was generated from the following files:
  • duration.h
  • duration.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:59:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KCalCore Library

Skip menu "KCalCore Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal