53 static const int YEARS = 31557600;
55 static const int MONTHS = 60 * 60 * 24 * 30;
57 static const int WEEKS = 60 * 60 * 24 * 7;
59 static const int DAY = 60 * 60 * 24;
61 static const int HOUR = 60 * 60;
99 SIP_PYOBJECT __repr__();
102 if ( ! sipCpp->isValid() )
103 str = QStringLiteral(
"<QgsInterval: invalid>" );
105 str = QStringLiteral(
"<QgsInterval: %1 %2>" ).arg( sipCpp->originalDuration() ).arg(
QgsUnitTypes::toString( sipCpp->originalUnit() ) );
107 str = QStringLiteral(
"<QgsInterval: %1 seconds>" ).arg( sipCpp->seconds() );
108 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
121 double years()
const;
170 double weeks()
const;
218 double hours()
const;
274 void setSeconds(
double seconds );
324 if ( !mValid && !other.mValid )
327 return mOriginalUnit == other.mOriginalUnit && mOriginalDuration == other.mOriginalDuration;
328 else if ( mValid && other.mValid )
336 return !( *
this == other );
344 static QgsInterval fromString(
const QString &
string );
347 operator QVariant()
const
349 return QVariant::fromValue( *
this );
355 double mSeconds = 0.0;
361 double mOriginalDuration = 0.0;
371#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
TemporalUnit
Temporal units.
@ Unknown
Unknown time unit.
A representation of the interval between two datetime values.
static const int MINUTE
Seconds per minute.
double originalDuration() const
Returns the original interval duration.
bool isValid() const
Returns true if the interval is valid.
double days() const
Returns the interval duration in days.
void setMinutes(double minutes)
Sets the interval duration in minutes.
void setValid(bool valid)
Sets whether the interval is valid.
void setWeeks(double weeks)
Sets the interval duration in weeks.
QgsInterval()=default
Default constructor for QgsInterval.
double weeks() const
Returns the interval duration in weeks.
static const int MONTHS
Seconds per month, based on 30 day month.
double months() const
Returns the interval duration in months (based on a 30 day month).
bool operator==(QgsInterval other) const
double seconds() const
Returns the interval duration in seconds.
Qgis::TemporalUnit originalUnit() const
Returns the original interval temporal unit.
double years() const
Returns the interval duration in years (based on an average year length).
static const int HOUR
Seconds per hour.
static const int WEEKS
Seconds per week.
static const int DAY
Seconds per day.
double hours() const
Returns the interval duration in hours.
void setHours(double hours)
Sets the interval duration in hours.
bool operator!=(QgsInterval other) const
static const int YEARS
Seconds per year (average).
void setYears(double years)
Sets the interval duration in years.
void setDays(double days)
Sets the interval duration in days.
double minutes() const
Returns the interval duration in minutes.
void setMonths(double months)
Sets the interval duration in months.
static Q_INVOKABLE QString toString(Qgis::DistanceUnit unit)
Returns a translated string representing a distance unit.
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.