QGIS API Documentation
3.18.1-Zürich (202f1bf7e5)
|
A representation of the interval between two datetime values. More...
#include <qgsinterval.h>
Public Member Functions | |
QgsInterval ()=default | |
Default constructor for QgsInterval. More... | |
QgsInterval (double duration, QgsUnitTypes::TemporalUnit unit) | |
Constructor for QgsInterval, using the specified duration and units. More... | |
QgsInterval (double seconds) | |
Constructor for QgsInterval. More... | |
QgsInterval (double years, double months, double weeks, double days, double hours, double minutes, double seconds) | |
Constructor for QgsInterval, using the specified years, months, weeks, days, hours, minutes and seconds. More... | |
double | days () const |
Returns the interval duration in days. More... | |
double | hours () const |
Returns the interval duration in hours. More... | |
bool | isValid () const |
Returns true if the interval is valid. More... | |
double | minutes () const |
Returns the interval duration in minutes. More... | |
double | months () const |
Returns the interval duration in months (based on a 30 day month). More... | |
operator QVariant () const | |
Allows direct construction of QVariants from intervals. More... | |
bool | operator!= (QgsInterval other) const |
bool | operator== (QgsInterval other) const |
double | originalDuration () const |
Returns the original interval duration. More... | |
QgsUnitTypes::TemporalUnit | originalUnit () const |
Returns the original interval temporal unit. More... | |
double | seconds () const |
Returns the interval duration in seconds. More... | |
void | setDays (double days) |
Sets the interval duration in days. More... | |
void | setHours (double hours) |
Sets the interval duration in hours. More... | |
void | setMinutes (double minutes) |
Sets the interval duration in minutes. More... | |
void | setMonths (double months) |
Sets the interval duration in months. More... | |
void | setSeconds (double seconds) |
Sets the interval duration in seconds. More... | |
void | setValid (bool valid) |
Sets whether the interval is valid. More... | |
void | setWeeks (double weeks) |
Sets the interval duration in weeks. More... | |
void | setYears (double years) |
Sets the interval duration in years. More... | |
double | weeks () const |
Returns the interval duration in weeks. More... | |
double | years () const |
Returns the interval duration in years (based on an average year length) More... | |
Static Public Member Functions | |
static QgsInterval | fromString (const QString &string) |
Converts a string to an interval. More... | |
Static Public Attributes | |
static const int | DAY = 60 * 60 * 24 |
Seconds per day. More... | |
static const int | HOUR = 60 * 60 |
Seconds per hour. More... | |
static const int | MINUTE = 60 |
Seconds per minute. More... | |
static const int | MONTHS = 60 * 60 * 24 * 30 |
Seconds per month, based on 30 day month. More... | |
static const int | WEEKS = 60 * 60 * 24 * 7 |
Seconds per week. More... | |
static const int | YEARS = 31557600 |
Seconds per year (average) More... | |
A representation of the interval between two datetime values.
Definition at line 41 of file qgsinterval.h.
|
default |
Default constructor for QgsInterval.
Creates an invalid interval.
QgsInterval::QgsInterval | ( | double | seconds | ) |
Constructor for QgsInterval.
seconds | duration of interval in seconds |
Definition at line 30 of file qgsinterval.cpp.
QgsInterval::QgsInterval | ( | double | duration, |
QgsUnitTypes::TemporalUnit | unit | ||
) |
Constructor for QgsInterval, using the specified duration and units.
Definition at line 38 of file qgsinterval.cpp.
QgsInterval::QgsInterval | ( | double | years, |
double | months, | ||
double | weeks, | ||
double | days, | ||
double | hours, | ||
double | minutes, | ||
double | seconds | ||
) |
Constructor for QgsInterval, using the specified years, months, weeks, days, hours, minutes and seconds.
Definition at line 46 of file qgsinterval.cpp.
double QgsInterval::days | ( | ) | const |
Returns the interval duration in days.
If the originalUnit() is QgsUnitTypes::TemporalDays then this value will match the exact number of days as returned by originalDuration(), otherwise it will be calculated using the QgsInterval::DAY constant.
Definition at line 151 of file qgsinterval.cpp.
|
static |
Converts a string to an interval.
string | string to parse |
Definition at line 209 of file qgsinterval.cpp.
double QgsInterval::hours | ( | ) | const |
Returns the interval duration in hours.
If the originalUnit() is QgsUnitTypes::TemporalHours then this value will match the exact number of hours as returned by originalDuration(), otherwise it will be calculated using the QgsInterval::HOUR constant.
Definition at line 168 of file qgsinterval.cpp.
|
inline |
Returns true
if the interval is valid.
Definition at line 255 of file qgsinterval.h.
double QgsInterval::minutes | ( | ) | const |
Returns the interval duration in minutes.
If the originalUnit() is QgsUnitTypes::TemporalMinutes then this value will match the exact number of minutes as returned by originalDuration(), otherwise it will be calculated using the QgsInterval::MINUTE constant.
Definition at line 185 of file qgsinterval.cpp.
double QgsInterval::months | ( | ) | const |
Returns the interval duration in months (based on a 30 day month).
If the originalUnit() is QgsUnitTypes::TemporalMonths then this value will match the exact number of months as returned by originalDuration(), otherwise it will be calculated using the assumption that a month consists of exactly 30 days.
Definition at line 118 of file qgsinterval.cpp.
|
inline |
Allows direct construction of QVariants from intervals.
Definition at line 322 of file qgsinterval.h.
|
inline |
Definition at line 309 of file qgsinterval.h.
|
inline |
Definition at line 297 of file qgsinterval.h.
|
inline |
Returns the original interval duration.
This original interval duration can be updated through calling QgsInterval setter methods.
If the original interval duration is not available or interval was set with a mix of units, calling originalUnit() will return QgsUnitTypes::TemporalUnknownUnit
Returns 0.0 if the original duration was not set.
Definition at line 280 of file qgsinterval.h.
|
inline |
Returns the original interval temporal unit.
The interval temporal unit can be set through the QgsInterval constructors or through the available setter methods.
Returns QgsUnitTypes::TemporalUnknownUnit if unit was not set when creating the QgsInterval instance or interval was set with a mix of units.
Definition at line 295 of file qgsinterval.h.
|
inline |
Returns the interval duration in seconds.
Definition at line 236 of file qgsinterval.h.
void QgsInterval::setDays | ( | double | days | ) |
Sets the interval duration in days.
Replaces the interval size and changes the original interval unit and duration,
Changes the original unit to QgsUnitTypes::TemporalDays
days | duration in days |
Definition at line 160 of file qgsinterval.cpp.
void QgsInterval::setHours | ( | double | hours | ) |
Sets the interval duration in hours.
Replaces the interval size and changes the original interval unit and duration,
The original unit to QgsUnitTypes::TemporalHours
hours | duration in hours |
Definition at line 177 of file qgsinterval.cpp.
void QgsInterval::setMinutes | ( | double | minutes | ) |
Sets the interval duration in minutes.
Replaces the interval size and changes the original interval unit and duration,
Changes the original unit to QgsUnitTypes::TemporalMinutes
minutes | duration in minutes |
Definition at line 193 of file qgsinterval.cpp.
void QgsInterval::setMonths | ( | double | months | ) |
Sets the interval duration in months.
Replaces the interval size and changes the original interval unit and duration,
Changes the original unit to QgsUnitTypes::TemporalMonths
months | duration in months (based on a 30 day month) |
Definition at line 126 of file qgsinterval.cpp.
void QgsInterval::setSeconds | ( | double | seconds | ) |
Sets the interval duration in seconds.
Replaces the interval size and changes the original interval unit and duration,
Changes the original unit to QgsUnitTypes::TemporalSeconds
seconds | duration in seconds |
Definition at line 201 of file qgsinterval.cpp.
|
inline |
Sets whether the interval is valid.
valid | set to true to set the interval as valid. |
Definition at line 262 of file qgsinterval.h.
void QgsInterval::setWeeks | ( | double | weeks | ) |
Sets the interval duration in weeks.
Replaces the interval size and changes the original interval unit and duration,
Changes the original unit to QgsUnitTypes::TemporalWeeks
weeks | duration in weeks |
Definition at line 143 of file qgsinterval.cpp.
void QgsInterval::setYears | ( | double | years | ) |
Sets the interval duration in years.
Replaces the interval size and changes the original interval unit and duration,
Changes the original unit to QgsUnitTypes::TemporalYears
years | duration in years (based on average year length) |
Definition at line 110 of file qgsinterval.cpp.
double QgsInterval::weeks | ( | ) | const |
Returns the interval duration in weeks.
If the originalUnit() is QgsUnitTypes::TemporalWeeks then this value will match the exact number of weeks as returned by originalDuration(), otherwise it will be calculated using the QgsInterval::WEEKS constant.
Definition at line 134 of file qgsinterval.cpp.
double QgsInterval::years | ( | ) | const |
Returns the interval duration in years (based on an average year length)
If the originalUnit() is QgsUnitTypes::TemporalYears then this value will match the exact number of months as returned by originalDuration(), otherwise it will be calculated using the average year length (31557600 seconds).
Definition at line 102 of file qgsinterval.cpp.
|
static |
Seconds per day.
Definition at line 54 of file qgsinterval.h.
|
static |
Seconds per hour.
Definition at line 56 of file qgsinterval.h.
|
static |
Seconds per minute.
Definition at line 58 of file qgsinterval.h.
|
static |
Seconds per month, based on 30 day month.
Definition at line 50 of file qgsinterval.h.
|
static |
Seconds per week.
Definition at line 52 of file qgsinterval.h.
|
static |
Seconds per year (average)
Definition at line 48 of file qgsinterval.h.