QGIS/python/PyQt6/core/auto_generated/qgsinterval.sip.in
Nyall Dawson 3f6b490218 Sipify
2025-04-02 11:11:10 +10:00

343 lines
9.3 KiB
Plaintext

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsinterval.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
%ModuleHeaderCode
#include "qgsunittypes.h"
%End
class QgsInterval
{
%Docstring(signature="appended")
A representation of the interval between two datetime values.
%End
%TypeHeaderCode
#include "qgsinterval.h"
%End
public:
static const int YEARS;
static const int MONTHS;
static const int WEEKS;
static const int DAY;
static const int HOUR;
static const int MINUTE;
QgsInterval();
%Docstring
Default constructor for QgsInterval. Creates an invalid interval.
%End
QgsInterval( double seconds );
%Docstring
Constructor for QgsInterval.
:param seconds: duration of interval in seconds
%End
QgsInterval( double duration, Qgis::TemporalUnit unit );
%Docstring
Constructor for QgsInterval, using the specified ``duration`` and
``units``.
%End
QgsInterval( double years, double months, double weeks, double days, double hours, double minutes, double seconds );
%Docstring
Constructor for QgsInterval, using the specified ``years``, ``months``,
``weeks``, ``days``, ``hours``, ``minutes`` and ``seconds``.
.. note::
Month units assumes a 30 day month length.
.. note::
Year units assumes a 365.25 day year length.
.. versionadded:: 3.14
%End
SIP_PYOBJECT __repr__();
%MethodCode
QString str;
if ( ! sipCpp->isValid() )
str = QStringLiteral( "<QgsInterval: invalid>" );
else if ( sipCpp->originalUnit() != Qgis::TemporalUnit::Unknown )
str = QStringLiteral( "<QgsInterval: %1 %2>" ).arg( sipCpp->originalDuration() ).arg( QgsUnitTypes::toString( sipCpp->originalUnit() ) );
else
str = QStringLiteral( "<QgsInterval: %1 seconds>" ).arg( sipCpp->seconds() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End
double years() const;
%Docstring
Returns the interval duration in years (based on an average year length)
If the :py:func:`~QgsInterval.originalUnit` is
:py:class:`QgsUnitTypes`.TemporalYears then this value will match the
exact number of months as returned by
:py:func:`~QgsInterval.originalDuration`, otherwise it will be
calculated using the average year length (31557600 seconds).
.. seealso:: :py:func:`setYears`
%End
void setYears( double years );
%Docstring
Sets the interval duration in years.
Replaces the interval size and changes the original interval unit and
duration, :py:func:`originalDuration` and :py:func:`originalUnit`.
Changes the original unit to :py:class:`QgsUnitTypes`.TemporalYears
:param years: duration in years (based on average year length)
.. seealso:: :py:func:`years`
%End
double months() const;
%Docstring
Returns the interval duration in months (based on a 30 day month).
If the :py:func:`~QgsInterval.originalUnit` is
:py:class:`QgsUnitTypes`.TemporalMonths then this value will match the
exact number of months as returned by
:py:func:`~QgsInterval.originalDuration`, otherwise it will be
calculated using the assumption that a month consists of exactly 30
days.
.. seealso:: :py:func:`setMonths`
%End
void setMonths( double months );
%Docstring
Sets the interval duration in months.
Replaces the interval size and changes the original interval unit and
duration, :py:func:`originalDuration` and :py:func:`originalUnit`.
Changes the original unit to :py:class:`QgsUnitTypes`.TemporalMonths
:param months: duration in months (based on a 30 day month)
.. seealso:: :py:func:`months`
%End
double weeks() const;
%Docstring
Returns the interval duration in weeks.
If the :py:func:`~QgsInterval.originalUnit` is
:py:class:`QgsUnitTypes`.TemporalWeeks then this value will match the
exact number of weeks as returned by
:py:func:`~QgsInterval.originalDuration`, otherwise it will be
calculated using the QgsInterval.WEEKS constant.
.. seealso:: :py:func:`setWeeks`
%End
void setWeeks( double weeks );
%Docstring
Sets the interval duration in weeks.
Replaces the interval size and changes the original interval unit and
duration, :py:func:`originalDuration` and :py:func:`originalUnit`.
Changes the original unit to :py:class:`QgsUnitTypes`.TemporalWeeks
:param weeks: duration in weeks
.. seealso:: :py:func:`weeks`
%End
double days() const;
%Docstring
Returns the interval duration in days.
If the :py:func:`~QgsInterval.originalUnit` is
:py:class:`QgsUnitTypes`.TemporalDays then this value will match the
exact number of days as returned by
:py:func:`~QgsInterval.originalDuration`, otherwise it will be
calculated using the QgsInterval.DAY constant.
.. seealso:: :py:func:`setDays`
%End
void setDays( double days );
%Docstring
Sets the interval duration in days.
Replaces the interval size and changes the original interval unit and
duration, :py:func:`originalDuration` and :py:func:`originalUnit`.
Changes the original unit to :py:class:`QgsUnitTypes`.TemporalDays
:param days: duration in days
.. seealso:: :py:func:`days`
%End
double hours() const;
%Docstring
Returns the interval duration in hours.
If the :py:func:`~QgsInterval.originalUnit` is
:py:class:`QgsUnitTypes`.TemporalHours then this value will match the
exact number of hours as returned by
:py:func:`~QgsInterval.originalDuration`, otherwise it will be
calculated using the QgsInterval.HOUR constant.
.. seealso:: :py:func:`setHours`
%End
void setHours( double hours );
%Docstring
Sets the interval duration in hours.
Replaces the interval size and changes the original interval unit and
duration, :py:func:`originalDuration` and :py:func:`originalUnit`.
The original unit to :py:class:`QgsUnitTypes`.TemporalHours
:param hours: duration in hours
.. seealso:: :py:func:`hours`
%End
double minutes() const;
%Docstring
Returns the interval duration in minutes.
If the :py:func:`~QgsInterval.originalUnit` is
:py:class:`QgsUnitTypes`.TemporalMinutes then this value will match the
exact number of minutes as returned by
:py:func:`~QgsInterval.originalDuration`, otherwise it will be
calculated using the QgsInterval.MINUTE constant.
.. seealso:: :py:func:`setMinutes`
%End
void setMinutes( double minutes );
%Docstring
Sets the interval duration in minutes.
Replaces the interval size and changes the original interval unit and
duration, :py:func:`originalDuration` and :py:func:`originalUnit`.
Changes the original unit to :py:class:`QgsUnitTypes`.TemporalMinutes
:param minutes: duration in minutes
.. seealso:: :py:func:`minutes`
%End
double seconds() const;
%Docstring
Returns the interval duration in seconds.
.. seealso:: :py:func:`setSeconds`
%End
void setSeconds( double seconds );
%Docstring
Sets the interval duration in seconds.
Replaces the interval size and changes the original interval unit and
duration, :py:func:`originalDuration` and :py:func:`originalUnit`.
Changes the original unit to :py:class:`QgsUnitTypes`.TemporalSeconds
:param seconds: duration in seconds
.. seealso:: :py:func:`seconds`
%End
bool isValid() const;
%Docstring
Returns ``True`` if the interval is valid.
.. seealso:: :py:func:`setValid`
%End
void setValid( bool valid );
%Docstring
Sets whether the interval is valid.
:param valid: set to ``True`` to set the interval as valid.
.. seealso:: :py:func:`isValid`
%End
double originalDuration() const;
%Docstring
Returns the original interval duration.
This original interval duration can be updated through calling
QgsInterval setter methods.
.. seealso:: :py:func:`originalUnit` for the corresponding unit.
If the original interval duration is not available or interval was set
with a mix of units, calling :py:func:`~QgsInterval.originalUnit` will
return :py:class:`QgsUnitTypes`.TemporalUnknownUnit
Returns 0.0 if the original duration was not set.
.. versionadded:: 3.18
%End
Qgis::TemporalUnit originalUnit() const;
%Docstring
Returns the original interval temporal unit.
The interval temporal unit can be set through the QgsInterval
constructors or through the available setter methods.
Returns :py:class:`QgsUnitTypes`.TemporalUnknownUnit if unit was not set
when creating the QgsInterval instance or interval was set with a mix of
units.
.. seealso:: :py:func:`originalDuration`
.. versionadded:: 3.18
%End
bool operator==( QgsInterval other ) const;
bool operator!=( QgsInterval other ) const;
static QgsInterval fromString( const QString &string );
%Docstring
Converts a string to an interval
:param string: string to parse
:return: interval, or invalid interval if string could not be parsed
%End
operator QVariant() const;
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsinterval.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/