28 #include "qgis_core.h" 46 static const int YEARS = 31557600;
48 static const int MONTHS = 60 * 60 * 24 * 30;
50 static const int WEEKS = 60 * 60 * 24 * 7;
52 static const int DAY = 60 * 60 * 24;
54 static const int HOUR = 60 * 60;
56 static const int MINUTE = 60;
73 double years()
const {
return mSeconds / YEARS; }
80 void setYears(
double years ) { mSeconds = years * YEARS; mValid =
true; }
86 double months()
const {
return mSeconds / MONTHS; }
93 void setMonths(
double months ) { mSeconds = months * MONTHS; mValid =
true; }
99 double weeks()
const {
return mSeconds / WEEKS; }
106 void setWeeks(
double weeks ) { mSeconds = weeks * WEEKS; mValid =
true; }
112 double days()
const {
return mSeconds / DAY; }
119 void setDays(
double days ) { mSeconds = days * DAY; mValid =
true; }
125 double hours()
const {
return mSeconds / HOUR; }
132 void setHours(
double hours ) { mSeconds = hours * HOUR; mValid =
true; }
138 double minutes()
const {
return mSeconds / MINUTE; }
145 void setMinutes(
double minutes ) { mSeconds = minutes * MINUTE; mValid =
true; }
158 void setSeconds(
double seconds ) { mSeconds = seconds; mValid =
true; }
180 static QgsInterval fromString(
const QString &
string );
183 operator QVariant()
const 185 return QVariant::fromValue( *
this );
191 double mSeconds = 0.0;
242 #endif // QGSINTERVAL_H double months() const
Returns the interval duration in months (based on a 30 day month).
void setMinutes(double minutes)
Sets the interval duration in minutes.
void setYears(double years)
Sets the interval duration in years.
bool isValid() const
Returns true if the interval is valid.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
double years() const
Returns the interval duration in years (based on an average year length)
void setHours(double hours)
Sets the interval duration in hours.
QDebug operator<<(QDebug dbg, const QgsInterval &interval)
Debug string representation of interval.
Q_DECLARE_METATYPE(QModelIndex)
double days() const
Returns the interval duration in days.
QDateTime CORE_EXPORT operator+(const QDateTime &start, const QgsInterval &interval)
Adds an interval to a datetime.
double hours() const
Returns the interval duration in hours.
void setWeeks(double weeks)
Sets the interval duration in weeks.
double weeks() const
Returns the interval duration in weeks.
void setMonths(double months)
Sets the interval duration in months.
double seconds() const
Returns the interval duration in seconds.
void setDays(double days)
Sets the interval duration in days.
A representation of the interval between two datetime values.
double minutes() const
Returns the interval duration in minutes.
void setValid(bool valid)
Sets whether the interval is valid.
QgsInterval CORE_EXPORT operator-(const QDateTime &datetime1, const QDateTime &datetime2)
Returns the interval between two datetimes.
void setSeconds(double seconds)
Sets the interval duration in seconds.