34using namespace Qt::StringLiterals;
56 static const int YEARS = 31557600;
58 static const int MONTHS = 60 * 60 * 24 * 30;
60 static const int WEEKS = 60 * 60 * 24 * 7;
62 static const int DAY = 60 * 60 * 24;
64 static const int HOUR = 60 * 60;
102 SIP_PYOBJECT __repr__();
105 if ( ! sipCpp->isValid() )
106 str = u
"<QgsInterval: invalid>"_s;
108 str = u
"<QgsInterval: %1 %2>"_s.arg( sipCpp->originalDuration() ).arg(
QgsUnitTypes::toString( sipCpp->originalUnit() ) );
110 str = u
"<QgsInterval: %1 seconds>"_s.arg( sipCpp->seconds() );
111 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
124 double years()
const;
173 double weeks()
const;
221 double hours()
const;
277 void setSeconds(
double seconds );
327 if ( !mValid && !other.mValid )
330 return mOriginalUnit == other.mOriginalUnit && mOriginalDuration == other.mOriginalDuration;
331 else if ( mValid && other.mValid )
339 return !( *
this == other );
347 static QgsInterval fromString(
const QString &
string );
350 operator QVariant()
const
352 return QVariant::fromValue( *
this );
358 double mSeconds = 0.0;
364 double mOriginalDuration = 0.0;
374#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.