33 if ( start.time() == end.time() ) {
34 mDuration = start.daysTo( end );
37 mDuration = start.secsTo( end );
45 mDuration = start.daysTo( end );
49 if ( end.time() < start.time() ) {
53 if ( end.time() > start.time() ) {
60 mDuration = start.secsTo( end );
68 mDaily = ( type ==
Days );
73 mDuration = duration.mDuration;
74 mDaily = duration.mDaily;
80 if ( &duration ==
this ) {
84 mDuration = duration.mDuration;
85 mDaily = duration.mDaily;
90 Duration::operator bool()
const
97 if ( mDaily == other.mDaily ) {
99 return mDuration < other.mDuration;
101 return seconds() < other.seconds();
110 mDuration == other.mDuration &&
111 mDaily == other.mDaily;
117 if ( mDaily == other.mDaily ) {
118 mDuration += other.mDuration;
119 }
else if ( mDaily ) {
120 mDuration = mDuration * 86400 + other.mDuration;
123 mDuration += other.mDuration + 86400;
152 return mDaily ? start.addDays( mDuration )
153 : start.addSecs( mDuration );
172 return mDaily ? mDuration : mDuration / 86400;
bool operator<(const Duration &other) const
Returns true if this duration is smaller than the other.
Type type() const
Returns the time units (seconds or days) used to specify the duration.
int asDays() const
Returns the length of the duration in days.
int asSeconds() const
Returns the length of the duration in seconds.
duration is a number of days
TQDateTime end(const TQDateTime &start) const
Computes a duration end time by adding the number of seconds or days in the duration to the specified...
bool isDaily() const
Returns whether the duration is specified in terms of days rather than seconds.
Duration()
Constructs a duration of 0 seconds.
Duration & operator+=(const Duration &other)
Adds another duration to this one.
duration is a number of seconds
Duration & operator*=(int value)
Multiplies this duration by a value.
Duration & operator=(const Duration &duration)
Sets this duration equal to duration.
int value() const
Returns the length of the duration in seconds or days.
Type
The unit of time used to define the duration.
This class represents a duration.
bool operator==(const Duration &other) const
Returns true if this duration is equal to the other.
Duration operator-() const
Returns the negative of this duration.
Duration & operator/=(int value)
Divides this duration by a value.
Duration & operator-=(const Duration &other)
Subtracts another duration from this one.