52 static const int YEARS = 31557600;
54 static const int MONTHS = 60 * 60 * 24 * 30;
56 static const int WEEKS = 60 * 60 * 24 * 7;
58 static const int DAY = 60 * 60 * 24;
60 static const int HOUR = 60 * 60;
62 static const int MINUTE = 60;
95 QgsInterval(
double years,
double months,
double weeks,
double days,
double hours,
double minutes,
double seconds );
98 SIP_PYOBJECT __repr__();
101 if ( ! sipCpp->isValid() )
102 str = QStringLiteral(
"<QgsInterval: invalid>" );
104 str = QStringLiteral(
"<QgsInterval: %1 %2>" ).arg( sipCpp->originalDuration() ).arg(
QgsUnitTypes::toString( sipCpp->originalUnit() ) );
106 str = QStringLiteral(
"<QgsInterval: %1 seconds>" ).arg( sipCpp->seconds() );
107 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
120 double years()
const;
133 void setYears(
double years );
145 double months()
const;
158 void setMonths(
double months );
169 double weeks()
const;
182 void setWeeks(
double weeks );
206 void setDays(
double days );
217 double hours()
const;
230 void setHours(
double hours );
241 double minutes()
const;
254 void setMinutes(
double minutes );
273 void setSeconds(
double seconds );
323 if ( !mValid && !other.mValid )
326 return mOriginalUnit == other.mOriginalUnit && mOriginalDuration == other.mOriginalDuration;
327 else if ( mValid && other.mValid )
335 return !( *
this == other );
343 static QgsInterval fromString(
const QString &
string );
346 operator QVariant()
const
348 return QVariant::fromValue( *
this );
354 double mSeconds = 0.0;
360 double mOriginalDuration = 0.0;
370#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.
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
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.