Class: QgsInterval

class qgis.core.QgsInterval

Bases: sip.wrapper

Default constructor for QgsInterval. Creates an invalid interval.

QgsInterval(seconds: float) Constructor for QgsInterval.

Parameters

seconds – duration of interval in seconds

QgsInterval(QgsInterval)

A representation of the interval between two datetime values.

Methods

days

Returns the interval duration in days.

fromString

Converts a string to an interval

hours

Returns the interval duration in hours.

isValid

Returns True if the interval is valid.

minutes

Returns the interval duration in minutes.

months

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

seconds

Returns the interval duration in seconds.

setDays

Sets the interval duration in days.

setHours

Sets the interval duration in hours.

setMinutes

Sets the interval duration in minutes.

setMonths

Sets the interval duration in months.

setSeconds

Sets the interval duration in seconds.

setValid

Sets whether the interval is valid.

setWeeks

Sets the interval duration in weeks.

setYears

Sets the interval duration in years.

weeks

Returns the interval duration in weeks.

years

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

Attributes

DAY

HOUR

MINUTE

MONTHS

WEEKS

YEARS

DAY = 86400
HOUR = 3600
MINUTE = 60
MONTHS = 2592000
WEEKS = 604800
YEARS = 31557600
days(self) → float

Returns the interval duration in days.

See also

setDays()

Return type

float

fromString(string: str) → QgsInterval

Converts a string to an interval

Parameters

string (str) – string to parse

Return type

QgsInterval

Returns

interval, or invalid interval if string could not be parsed

hours(self) → float

Returns the interval duration in hours.

See also

setHours()

Return type

float

isValid(self) → bool

Returns True if the interval is valid.

See also

setValid()

Return type

bool

minutes(self) → float

Returns the interval duration in minutes.

See also

setMinutes()

Return type

float

months(self) → float

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

See also

setMonths()

Return type

float

seconds(self) → float

Returns the interval duration in seconds.

See also

setSeconds()

Return type

float

setDays(self, days: float)

Sets the interval duration in days.

Parameters

days (float) – duration in days

See also

days()

setHours(self, hours: float)

Sets the interval duration in hours.

Parameters

hours (float) – duration in hours

See also

hours()

setMinutes(self, minutes: float)

Sets the interval duration in minutes.

Parameters

minutes (float) – duration in minutes

See also

minutes()

setMonths(self, months: float)

Sets the interval duration in months.

Parameters

months (float) – duration in months (based on a 30 day month)

See also

months()

setSeconds(self, seconds: float)

Sets the interval duration in seconds.

Parameters

seconds (float) – duration in seconds

See also

seconds()

setValid(self, valid: bool)

Sets whether the interval is valid.

Parameters

valid (bool) – set to True to set the interval as valid.

See also

isValid()

setWeeks(self, weeks: float)

Sets the interval duration in weeks.

Parameters

weeks (float) – duration in weeks

See also

weeks()

setYears(self, years: float)

Sets the interval duration in years.

Parameters

years (float) – duration in years (based on average year length)

See also

years()

weeks(self) → float

Returns the interval duration in weeks.

See also

setWeeks()

Return type

float

years(self) → float

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

See also

setYears()

Return type

float