41 static const int YEARS = 31557600;
43 static const int MONTHS = 60 * 60 * 24 * 30;
45 static const int WEEKS = 60 * 60 * 24 * 7;
47 static const int DAY = 60 * 60 * 24;
49 static const int HOUR = 60 * 60;
51 static const int MINUTE = 60;
65 double years()
const {
return mSeconds / YEARS; }
71 void setYears(
double years ) { mSeconds = years * YEARS; mValid =
true; }
76 double months()
const {
return mSeconds / MONTHS; }
82 void setMonths(
double months ) { mSeconds = months * MONTHS; mValid =
true; }
87 double weeks()
const {
return mSeconds / WEEKS; }
93 void setWeeks(
double weeks ) { mSeconds = weeks * WEEKS; mValid =
true; }
98 double days()
const {
return mSeconds / DAY; }
104 void setDays(
double days ) { mSeconds = days * DAY; mValid =
true; }
109 double hours()
const {
return mSeconds / HOUR; }
115 void setHours(
double hours ) { mSeconds = hours * HOUR; mValid =
true; }
120 double minutes()
const {
return mSeconds / MINUTE; }
126 void setMinutes(
double minutes ) { mSeconds = minutes * MINUTE; mValid =
true; }
137 void setSeconds(
double seconds ) { mSeconds = seconds; mValid =
true; }
210 #endif // QGSINTERVAL_H void setMinutes(double minutes)
Sets the interval duration in minutes.
bool isValid() const
Returns true if the interval is valid.
double months() const
Returns the interval duration in months (based on a 30 day month).
void setYears(double years)
Sets the interval duration in years.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
double seconds() const
Returns the interval duration in seconds.
Q_DECLARE_METATYPE(QgsMimeDataUtils::UriList)
void setHours(double hours)
Sets the interval duration in hours.
QDebug operator<<(QDebug dbg, const QgsInterval &interval)
Debug string representation of interval.
QDateTime CORE_EXPORT operator+(const QDateTime &start, const QgsInterval &interval)
Adds an interval to a datetime.
void setWeeks(double weeks)
Sets the interval duration in weeks.
void setMonths(double months)
Sets the interval duration in months.
double weeks() const
Returns the interval duration in weeks.
void setDays(double days)
Sets the interval duration in days.
QVariant fromValue(const T &value)
A representation of the interval between two datetime values.
double days() const
Returns the interval duration in days.
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.
double years() const
Returns the interval duration in years (based on an average year length)
double minutes() const
Returns the interval duration in minutes.
double hours() const
Returns the interval duration in hours.
void setSeconds(double seconds)
Sets the interval duration in seconds.