QGIS API Documentation 3.41.0-Master (cea29feecf2)
|
A representation of the interval between two datetime values. More...
#include <qgsinterval.h>
Public Member Functions | |
QgsInterval ()=default | |
Default constructor for QgsInterval. | |
QgsInterval (double duration, Qgis::TemporalUnit unit) | |
Constructor for QgsInterval, using the specified duration and units. | |
QgsInterval (double seconds) | |
Constructor for 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. | |
QgsInterval (std::chrono::milliseconds milliseconds) | |
Constructor for QgsInterval. | |
double | days () const |
Returns the interval duration in days. | |
double | hours () const |
Returns the interval duration in hours. | |
bool | isValid () const |
Returns true if the interval is valid. | |
double | minutes () const |
Returns the interval duration in minutes. | |
double | months () const |
Returns the interval duration in months (based on a 30 day month). | |
operator QVariant () const | |
Allows direct construction of QVariants from intervals. | |
bool | operator!= (QgsInterval other) const |
bool | operator== (QgsInterval other) const |
double | originalDuration () const |
Returns the original interval duration. | |
Qgis::TemporalUnit | originalUnit () const |
Returns the original interval temporal unit. | |
double | seconds () const |
Returns the interval duration in seconds. | |
void | setDays (double days) |
Sets the interval duration in days. | |
void | setHours (double hours) |
Sets the interval duration in hours. | |
void | setMinutes (double minutes) |
Sets the interval duration in minutes. | |
void | setMonths (double months) |
Sets the interval duration in months. | |
void | setSeconds (double seconds) |
Sets the interval duration in seconds. | |
void | setValid (bool valid) |
Sets whether the interval is valid. | |
void | setWeeks (double weeks) |
Sets the interval duration in weeks. | |
void | setYears (double years) |
Sets the interval duration in years. | |
double | weeks () const |
Returns the interval duration in weeks. | |
double | years () const |
Returns the interval duration in years (based on an average year length) | |
Static Public Member Functions | |
static QgsInterval | fromString (const QString &string) |
Converts a string to an interval. | |
Static Public Attributes | |
static const int | DAY = 60 * 60 * 24 |
Seconds per day. | |
static const int | HOUR = 60 * 60 |
Seconds per hour. | |
static const int | MINUTE = 60 |
Seconds per minute. | |
static const int | MONTHS = 60 * 60 * 24 * 30 |
Seconds per month, based on 30 day month. | |
static const int | WEEKS = 60 * 60 * 24 * 7 |
Seconds per week. | |
static const int | YEARS = 31557600 |
Seconds per year (average) | |
A representation of the interval between two datetime values.
Definition at line 45 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 33 of file qgsinterval.cpp.
QgsInterval::QgsInterval | ( | std::chrono::milliseconds | milliseconds | ) |
Constructor for QgsInterval.
milliseconds | duration of interval in milliseconds |
Definition at line 41 of file qgsinterval.cpp.
QgsInterval::QgsInterval | ( | double | duration, |
Qgis::TemporalUnit | unit | ||
) |
Constructor for QgsInterval, using the specified duration and units.
Definition at line 49 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 57 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 162 of file qgsinterval.cpp.
|
static |
Converts a string to an interval.
string | string to parse |
Definition at line 220 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 179 of file qgsinterval.cpp.
|
inline |
Returns true
if the interval is valid.
Definition at line 279 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 196 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 129 of file qgsinterval.cpp.
|
inline |
Allows direct construction of QVariants from intervals.
Definition at line 346 of file qgsinterval.h.
|
inline |
Definition at line 333 of file qgsinterval.h.
|
inline |
Definition at line 321 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 304 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 319 of file qgsinterval.h.
|
inline |
Returns the interval duration in seconds.
Definition at line 260 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 171 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 188 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 204 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 137 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 212 of file qgsinterval.cpp.
|
inline |
Sets whether the interval is valid.
valid | set to true to set the interval as valid. |
Definition at line 286 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 154 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 121 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 145 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 113 of file qgsinterval.cpp.
|
static |
Seconds per day.
Definition at line 58 of file qgsinterval.h.
|
static |
Seconds per hour.
Definition at line 60 of file qgsinterval.h.
|
static |
Seconds per minute.
Definition at line 62 of file qgsinterval.h.
|
static |
Seconds per month, based on 30 day month.
Definition at line 54 of file qgsinterval.h.
|
static |
Seconds per week.
Definition at line 56 of file qgsinterval.h.
|
static |
Seconds per year (average)
Definition at line 52 of file qgsinterval.h.