Class: QgsDateTimeRange

class qgis.core.QgsDateTimeRange(begin: QDateTime | datetime.datetime, end: QDateTime | datetime.datetime, includeBeginning: bool = True, includeEnd: bool = True)

Bases: sip.wrapper

Constructor for QgsTemporalRange. The begin and end are specified, and optionally whether or not these bounds are included in the range.

Note

in Python begin and end must be provided.

QgsDateTimeRange(QgsDateTimeRange)

QgsRange which stores a range of date times.

Invalid QDateTimes as the beginning or end are permitted. In this case, the bound is considered to be infinite. E.g. QgsDateTimeRange(QDateTime(),QDateTime(2017,1,1)) is treated as a range containing all dates before 2017-1-1. QgsDateTimeRange(QDateTime(2017,1,1),QDateTime()) is treated as a range containing all dates after 2017-1-1.

See also

QgsDateRange

Methods

begin

Returns the beginning of the range.

contains

Returns True if this range contains another range.

end

Returns the upper bound of the range.

extend

Extends the range in place by extending this range out to include an other range.

includeBeginning

Returns True if the beginning is inclusive, or False if the beginning is exclusive.

includeEnd

Returns True if the end is inclusive, or False if the end is exclusive.

isEmpty

Returns True if the range is empty, ie the beginning equals (or exceeds) the end and either of the bounds are exclusive.

isInfinite

Returns True if the range consists of all possible values.

isInstant

Returns True if the range consists only of a single instant.

overlaps

Returns True if this range overlaps another range.

begin(self) QDateTime

Returns the beginning of the range.

See also

end()

Return type:

QDateTime

contains(self, other: QgsDateTimeRange) bool

Returns True if this range contains another range.

contains(self, element: Union[QDateTime, datetime.datetime]) -> bool Returns True if this range contains a specified element.

Parameters:

other (QgsDateTimeRange) –

Return type:

bool

end(self) QDateTime

Returns the upper bound of the range.

See also

begin()

See also

includeEnd()

Return type:

QDateTime

extend(self, other: QgsDateTimeRange) bool

Extends the range in place by extending this range out to include an other range. If other is empty the range is not changed. If the range is empty and other is not, the range is changed and set to other.

See also

isEmpty()

Return type:

bool

Returns:

True if the range was extended

New in version 3.12.

Parameters:

other (QgsDateTimeRange) –

includeBeginning(self) bool

Returns True if the beginning is inclusive, or False if the beginning is exclusive.

See also

begin()

See also

includeEnd()

Return type:

bool

includeEnd(self) bool

Returns True if the end is inclusive, or False if the end is exclusive.

See also

end()

Return type:

bool

isEmpty(self) bool

Returns True if the range is empty, ie the beginning equals (or exceeds) the end and either of the bounds are exclusive. A range with both invalid beginning and end is considered infinite and not empty.

Return type:

bool

isInfinite(self) bool

Returns True if the range consists of all possible values.

See also

isEmpty()

See also

isInstant()

Return type:

bool

isInstant(self) bool

Returns True if the range consists only of a single instant.

See also

isEmpty()

See also

isInfinite()

Return type:

bool

overlaps(self, other: QgsDateTimeRange) bool

Returns True if this range overlaps another range.

Parameters:

other (QgsDateTimeRange) –

Return type:

bool