QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
QgsInterval Class Reference

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
 
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...
 

Detailed Description

A representation of the interval between two datetime values.

Since
QGIS 2.16

Definition at line 40 of file qgsinterval.h.

Constructor & Destructor Documentation

◆ QgsInterval() [1/4]

QgsInterval::QgsInterval ( )
default

Default constructor for QgsInterval.

Creates an invalid interval.

◆ QgsInterval() [2/4]

QgsInterval::QgsInterval ( double  seconds)

Constructor for QgsInterval.

Parameters
secondsduration of interval in seconds

Definition at line 31 of file qgsinterval.cpp.

◆ QgsInterval() [3/4]

QgsInterval::QgsInterval ( double  duration,
QgsUnitTypes::TemporalUnit  unit 
)

Constructor for QgsInterval, using the specified duration and units.

Definition at line 36 of file qgsinterval.cpp.

◆ QgsInterval() [4/4]

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.

Note
Month units assumes a 30 day month length.
Year units assumes a 365.25 day year length.
Since
QGIS 3.14

Definition at line 43 of file qgsinterval.cpp.

Member Function Documentation

◆ days()

double QgsInterval::days ( ) const
inline

Returns the interval duration in days.

See also
setDays()

Definition at line 129 of file qgsinterval.h.

◆ fromString()

QgsInterval QgsInterval::fromString ( const QString &  string)
static

Converts a string to an interval.

Parameters
stringstring to parse
Returns
interval, or invalid interval if string could not be parsed

Definition at line 66 of file qgsinterval.cpp.

◆ hours()

double QgsInterval::hours ( ) const
inline

Returns the interval duration in hours.

See also
setHours()

Definition at line 142 of file qgsinterval.h.

◆ isValid()

bool QgsInterval::isValid ( ) const
inline

Returns true if the interval is valid.

See also
setValid()

Definition at line 181 of file qgsinterval.h.

◆ minutes()

double QgsInterval::minutes ( ) const
inline

Returns the interval duration in minutes.

See also
setMinutes()

Definition at line 155 of file qgsinterval.h.

◆ months()

double QgsInterval::months ( ) const
inline

Returns the interval duration in months (based on a 30 day month).

See also
setMonths()

Definition at line 103 of file qgsinterval.h.

◆ operator QVariant()

QgsInterval::operator QVariant ( ) const
inline

Allows direct construction of QVariants from intervals.

Definition at line 200 of file qgsinterval.h.

◆ operator==()

bool QgsInterval::operator== ( QgsInterval  other) const

Definition at line 56 of file qgsinterval.cpp.

◆ seconds()

double QgsInterval::seconds ( ) const
inline

Returns the interval duration in seconds.

See also
setSeconds()

Definition at line 168 of file qgsinterval.h.

◆ setDays()

void QgsInterval::setDays ( double  days)
inline

Sets the interval duration in days.

Parameters
daysduration in days
See also
days()

Definition at line 136 of file qgsinterval.h.

◆ setHours()

void QgsInterval::setHours ( double  hours)
inline

Sets the interval duration in hours.

Parameters
hoursduration in hours
See also
hours()

Definition at line 149 of file qgsinterval.h.

◆ setMinutes()

void QgsInterval::setMinutes ( double  minutes)
inline

Sets the interval duration in minutes.

Parameters
minutesduration in minutes
See also
minutes()

Definition at line 162 of file qgsinterval.h.

◆ setMonths()

void QgsInterval::setMonths ( double  months)
inline

Sets the interval duration in months.

Parameters
monthsduration in months (based on a 30 day month)
See also
months()

Definition at line 110 of file qgsinterval.h.

◆ setSeconds()

void QgsInterval::setSeconds ( double  seconds)
inline

Sets the interval duration in seconds.

Parameters
secondsduration in seconds
See also
seconds()

Definition at line 175 of file qgsinterval.h.

◆ setValid()

void QgsInterval::setValid ( bool  valid)
inline

Sets whether the interval is valid.

Parameters
validset to true to set the interval as valid.
See also
isValid()

Definition at line 188 of file qgsinterval.h.

◆ setWeeks()

void QgsInterval::setWeeks ( double  weeks)
inline

Sets the interval duration in weeks.

Parameters
weeksduration in weeks
See also
weeks()

Definition at line 123 of file qgsinterval.h.

◆ setYears()

void QgsInterval::setYears ( double  years)
inline

Sets the interval duration in years.

Parameters
yearsduration in years (based on average year length)
See also
years()

Definition at line 97 of file qgsinterval.h.

◆ weeks()

double QgsInterval::weeks ( ) const
inline

Returns the interval duration in weeks.

See also
setWeeks()

Definition at line 116 of file qgsinterval.h.

◆ years()

double QgsInterval::years ( ) const
inline

Returns the interval duration in years (based on an average year length)

See also
setYears()

Definition at line 90 of file qgsinterval.h.

Member Data Documentation

◆ DAY

const int QgsInterval::DAY = 60 * 60 * 24
static

Seconds per day.

Definition at line 53 of file qgsinterval.h.

◆ HOUR

const int QgsInterval::HOUR = 60 * 60
static

Seconds per hour.

Definition at line 55 of file qgsinterval.h.

◆ MINUTE

const int QgsInterval::MINUTE = 60
static

Seconds per minute.

Definition at line 57 of file qgsinterval.h.

◆ MONTHS

const int QgsInterval::MONTHS = 60 * 60 * 24 * 30
static

Seconds per month, based on 30 day month.

Definition at line 49 of file qgsinterval.h.

◆ WEEKS

const int QgsInterval::WEEKS = 60 * 60 * 24 * 7
static

Seconds per week.

Definition at line 51 of file qgsinterval.h.

◆ YEARS

const int QgsInterval::YEARS = 31557600
static

Seconds per year (average)

Definition at line 47 of file qgsinterval.h.


The documentation for this class was generated from the following files: