QGIS API Documentation  3.24.2-Tisler (13c1a02865)
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
QgsTimeDuration Class Reference

Contains utility methods for working with temporal layers and projects. More...

#include <qgstemporalutils.h>

Public Member Functions

QDateTime addToDateTime (const QDateTime &dateTime)
 Adds this duration to a starting dateTime value. More...
 
bool isNull () const
 Returns true if the duration is null, i.e. More...
 
bool operator!= (const QgsTimeDuration &other) const
 
bool operator== (const QgsTimeDuration &other) const
 
QgsInterval toInterval () const
 Converts the duration to an interval value. More...
 
long long toSeconds () const
 Returns the total duration in seconds. More...
 
QString toString () const
 Converts the duration to an ISO8601 duration string. More...
 

Static Public Member Functions

static QgsTimeDuration fromString (const QString &string, bool &ok)
 Creates a QgsTimeDuration from a string value. More...
 

Public Attributes

int days = 0
 Days. More...
 
int hours = 0
 Hours. More...
 
int minutes = 0
 Minutes. More...
 
int months = 0
 Months. More...
 
double seconds = 0
 Seconds. More...
 
int weeks = 0
 Weeks. More...
 
int years = 0
 Years. More...
 

Detailed Description

Contains utility methods for working with temporal layers and projects.

Designed for storage of ISO8601 duration values.

Note
Not available in Python bindings
Since
QGIS 3.20

Definition at line 40 of file qgstemporalutils.h.

Member Function Documentation

◆ addToDateTime()

QDateTime QgsTimeDuration::addToDateTime ( const QDateTime &  dateTime)

Adds this duration to a starting dateTime value.

Definition at line 347 of file qgstemporalutils.cpp.

◆ fromString()

QgsTimeDuration QgsTimeDuration::fromString ( const QString &  string,
bool &  ok 
)
static

Creates a QgsTimeDuration from a string value.

Definition at line 363 of file qgstemporalutils.cpp.

◆ isNull()

bool QgsTimeDuration::isNull ( ) const
inline

Returns true if the duration is null, i.e.

an empty duration.

Definition at line 62 of file qgstemporalutils.h.

◆ operator!=()

bool QgsTimeDuration::operator!= ( const QgsTimeDuration other) const
inline

Definition at line 76 of file qgstemporalutils.h.

◆ operator==()

bool QgsTimeDuration::operator== ( const QgsTimeDuration other) const
inline

Definition at line 69 of file qgstemporalutils.h.

◆ toInterval()

QgsInterval QgsTimeDuration::toInterval ( ) const

Converts the duration to an interval value.

Definition at line 278 of file qgstemporalutils.cpp.

◆ toSeconds()

long long QgsTimeDuration::toSeconds ( ) const

Returns the total duration in seconds.

Warning
If the duration contains year or month intervals then the returned value is approximate only, due to the variable length of these intervals.

Definition at line 327 of file qgstemporalutils.cpp.

◆ toString()

QString QgsTimeDuration::toString ( ) const

Converts the duration to an ISO8601 duration string.

Definition at line 283 of file qgstemporalutils.cpp.

Member Data Documentation

◆ days

int QgsTimeDuration::days = 0

Days.

Definition at line 51 of file qgstemporalutils.h.

◆ hours

int QgsTimeDuration::hours = 0

Hours.

Definition at line 53 of file qgstemporalutils.h.

◆ minutes

int QgsTimeDuration::minutes = 0

Minutes.

Definition at line 55 of file qgstemporalutils.h.

◆ months

int QgsTimeDuration::months = 0

Months.

Definition at line 47 of file qgstemporalutils.h.

◆ seconds

double QgsTimeDuration::seconds = 0

Seconds.

Definition at line 57 of file qgstemporalutils.h.

◆ weeks

int QgsTimeDuration::weeks = 0

Weeks.

Definition at line 49 of file qgstemporalutils.h.

◆ years

int QgsTimeDuration::years = 0

Years.

Definition at line 45 of file qgstemporalutils.h.


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