48 static const int YEARS = 31557600;
50 static const int MONTHS = 60 * 60 * 24 * 30;
52 static const int WEEKS = 60 * 60 * 24 * 7;
54 static const int DAY = 60 * 60 * 24;
56 static const int HOUR = 60 * 60;
58 static const int MINUTE = 60;
91 QgsInterval(
double years,
double months,
double weeks,
double days,
double hours,
double minutes,
double seconds );
102 double years()
const;
115 void setYears(
double years );
127 double months()
const;
140 void setMonths(
double months );
151 double weeks()
const;
164 void setWeeks(
double weeks );
188 void setDays(
double days );
199 double hours()
const;
212 void setHours(
double hours );
223 double minutes()
const;
236 void setMinutes(
double minutes );
255 void setSeconds(
double seconds );
305 if ( !mValid && !other.mValid )
307 else if ( mValid && other.mValid && ( mOriginalUnit != Qgis::TemporalUnit::Unknown || other.mOriginalUnit != Qgis::TemporalUnit::Unknown ) )
308 return mOriginalUnit == other.mOriginalUnit && mOriginalDuration == other.mOriginalDuration;
309 else if ( mValid && other.mValid )
317 return !( *
this == other );
325 static QgsInterval fromString(
const QString &
string );
328 operator QVariant()
const
330 return QVariant::fromValue( *
this );
336 double mSeconds = 0.0;
342 double mOriginalDuration = 0.0;
352#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
TemporalUnit
Temporal units.
A representation of the interval between two datetime values.
double originalDuration() const
Returns the original interval duration.
bool isValid() const
Returns true if the interval is valid.
void setValid(bool valid)
Sets whether the interval is valid.
QgsInterval()=default
Default constructor for QgsInterval.
bool operator==(QgsInterval other) const
double seconds() const
Returns the interval duration in seconds.
Qgis::TemporalUnit originalUnit() const
Returns the original interval temporal unit.
bool operator!=(QgsInterval other) const
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
QDateTime CORE_EXPORT operator+(const QDateTime &start, const QgsInterval &interval)
Adds an interval to a datetime.
QgsInterval CORE_EXPORT operator-(QDate date1, QDate date2)
Returns the interval between two dates.
QDebug CORE_EXPORT operator<<(QDebug dbg, const QgsInterval &interval)
Debug string representation of interval.