libkcal
duration.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KCAL_DURATION_H
00022 #define KCAL_DURATION_H
00023
00024 #include <qdatetime.h>
00025
00026 #include "libkcal_export.h"
00027
00028 namespace KCal {
00029
00033 class LIBKCAL_EXPORT Duration
00034 {
00035 public:
00039 enum Type {
00040 Seconds,
00041 Days
00042 };
00043
00047 Duration();
00048
00060 Duration( const QDateTime &start, const QDateTime &end );
00061
00073 Duration( const QDateTime &start, const QDateTime &end, Type type );
00074
00081 Duration( int duration, Type type = Seconds );
00082
00088 Duration( const Duration &duration );
00089
00095 Duration &operator=( const Duration &duration );
00096
00100 operator bool() const;
00101
00105 bool operator!() const { return !operator bool(); }
00106
00111 bool operator<( const Duration &other ) const;
00112
00117 bool operator<=( const Duration &other ) const
00118 { return !other.operator<( *this ); }
00119
00120
00125 bool operator>( const Duration &other ) const
00126 { return other.operator<( *this ); }
00127
00132 bool operator>=( const Duration &other ) const
00133 { return !operator<( other ); }
00134
00142 bool operator==( const Duration &other ) const;
00143
00151 bool operator!=( const Duration &other ) const
00152 { return !operator==( other ); }
00153
00160 Duration &operator+=( const Duration &other );
00161
00170 Duration operator+( const Duration &other ) const
00171 { return Duration( *this ) += other; }
00172
00176 Duration operator-() const;
00177
00185 Duration &operator-=( const Duration &other );
00186
00195 Duration operator-( const Duration &other ) const
00196 { return Duration( *this ) += other; }
00197
00202 Duration &operator*=( int value );
00203
00210 Duration operator*( int value ) const
00211 { return Duration( *this ) *= value; }
00212
00217 Duration &operator/=( int value );
00218
00225 Duration operator/( int value ) const
00226 { return Duration( *this ) /= value; }
00227
00235 QDateTime end( const QDateTime &start ) const;
00236
00240 Type type() const;
00241
00246 bool isDaily() const;
00247
00251 int asSeconds() const;
00252
00258 int asDays() const;
00259
00265 int value() const;
00266
00267 private:
00268 int seconds() const { return mDaily ? mDuration * 86400 : mDuration; }
00269 int mDuration;
00270 bool mDaily;
00271
00272 class Private;
00273 Private *d;
00274 };
00275
00276 }
00277
00278 #endif
|