QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 seconds)
 Constructor for QgsInterval. 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 39 of file qgsinterval.h.

Constructor & Destructor Documentation

QgsInterval::QgsInterval ( )
default

Default constructor for QgsInterval.

Creates an invalid interval.

QgsInterval::QgsInterval ( double  seconds)

Constructor for QgsInterval.

Parameters
secondsduration of interval in seconds

Definition at line 30 of file qgsinterval.cpp.

Member Function Documentation

double QgsInterval::days ( ) const
inline

Returns the interval duration in days.

See also
setDays()

Definition at line 112 of file qgsinterval.h.

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 45 of file qgsinterval.cpp.

double QgsInterval::hours ( ) const
inline

Returns the interval duration in hours.

See also
setHours()

Definition at line 125 of file qgsinterval.h.

bool QgsInterval::isValid ( ) const
inline

Returns true if the interval is valid.

See also
setValid()

Definition at line 164 of file qgsinterval.h.

double QgsInterval::minutes ( ) const
inline

Returns the interval duration in minutes.

See also
setMinutes()

Definition at line 138 of file qgsinterval.h.

double QgsInterval::months ( ) const
inline

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

See also
setMonths()

Definition at line 86 of file qgsinterval.h.

QgsInterval::operator QVariant ( ) const
inline

Allows direct construction of QVariants from intervals.

Definition at line 183 of file qgsinterval.h.

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

Definition at line 35 of file qgsinterval.cpp.

double QgsInterval::seconds ( ) const
inline

Returns the interval duration in seconds.

See also
setSeconds()

Definition at line 151 of file qgsinterval.h.

void QgsInterval::setDays ( double  days)
inline

Sets the interval duration in days.

Parameters
daysduration in days
See also
days()

Definition at line 119 of file qgsinterval.h.

void QgsInterval::setHours ( double  hours)
inline

Sets the interval duration in hours.

Parameters
hoursduration in hours
See also
hours()

Definition at line 132 of file qgsinterval.h.

void QgsInterval::setMinutes ( double  minutes)
inline

Sets the interval duration in minutes.

Parameters
minutesduration in minutes
See also
minutes()

Definition at line 145 of file qgsinterval.h.

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 93 of file qgsinterval.h.

void QgsInterval::setSeconds ( double  seconds)
inline

Sets the interval duration in seconds.

Parameters
secondsduration in seconds
See also
seconds()

Definition at line 158 of file qgsinterval.h.

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 171 of file qgsinterval.h.

void QgsInterval::setWeeks ( double  weeks)
inline

Sets the interval duration in weeks.

Parameters
weeksduration in weeks
See also
weeks()

Definition at line 106 of file qgsinterval.h.

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 80 of file qgsinterval.h.

double QgsInterval::weeks ( ) const
inline

Returns the interval duration in weeks.

See also
setWeeks()

Definition at line 99 of file qgsinterval.h.

double QgsInterval::years ( ) const
inline

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

See also
setYears()

Definition at line 73 of file qgsinterval.h.

Member Data Documentation

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

Seconds per day.

Definition at line 52 of file qgsinterval.h.

const int QgsInterval::HOUR = 60 * 60
static

Seconds per hour.

Definition at line 54 of file qgsinterval.h.

const int QgsInterval::MINUTE = 60
static

Seconds per minute.

Definition at line 56 of file qgsinterval.h.

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

Seconds per month, based on 30 day month.

Definition at line 48 of file qgsinterval.h.

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

Seconds per week.

Definition at line 50 of file qgsinterval.h.

const int QgsInterval::YEARS = 31557600
static

Seconds per year (average)

Definition at line 46 of file qgsinterval.h.


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