Skip to content

Commit

Permalink
Sipify core.QgsInterval
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-morvan authored and 3nids committed May 4, 2017
1 parent 716fe52 commit d56eef1
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 82 deletions.
1 change: 0 additions & 1 deletion python/auto_sip.blacklist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ core/qgsgeometryvalidator.sip
core/qgsgml.sip
core/qgsgmlschema.sip
core/qgshistogram.sip
core/qgsinterval.sip
core/qgsjsonutils.sip
core/qgsmaptopixelgeometrysimplifier.sip
core/qgstransaction.sip
Expand Down
226 changes: 145 additions & 81 deletions python/core/qgsinterval.sip
Original file line number Diff line number Diff line change
@@ -1,139 +1,203 @@
/** \ingroup core
* \class QgsInterval
* \brief A representation of the interval between two datetime values.
* \note Added in version 2.16
*/
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsinterval.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/







class QgsInterval
{
%TypeHeaderCode
#include <qgsinterval.h>
%Docstring
A representation of the interval between two datetime values.
.. versionadded:: 2.16
%End

%TypeHeaderCode
#include "qgsinterval.h"
%End
public:

// YEAR const value taken from postgres query
// SELECT EXTRACT(EPOCH FROM interval '1 year')
//! Seconds per year (average)
static const int YEARS;
//! Seconds per month, based on 30 day month
%Docstring
Seconds per year (average)
%End
static const int MONTHS;
//! Seconds per week
%Docstring
Seconds per month, based on 30 day month
%End
static const int WEEKS;
//! Seconds per day
%Docstring
Seconds per week
%End
static const int DAY;
//! Seconds per hour
%Docstring
Seconds per day
%End
static const int HOUR;
//! Seconds per minute
%Docstring
Seconds per hour
%End
static const int MINUTE;
%Docstring
Seconds per minute
%End

/** Default constructor for QgsInterval. Creates an invalid interval.
*/
QgsInterval();
%Docstring
Default constructor for QgsInterval. Creates an invalid interval.
%End

/** Constructor for QgsInterval.
* @param seconds duration of interval in seconds
*/
QgsInterval( double seconds );
%Docstring
Constructor for QgsInterval.
\param seconds duration of interval in seconds
%End

/** Returns the interval duration in years (based on an average year length)
* @see setYears()
*/
double years() const;
%Docstring
Returns the interval duration in years (based on an average year length)
.. seealso:: setYears()
:rtype: float
%End

/** Sets the interval duration in years.
* @param years duration in years (based on average year length)
* @see years()
*/
void setYears( double years );
%Docstring
Sets the interval duration in years.
\param years duration in years (based on average year length)
.. seealso:: years()
%End

/** Returns the interval duration in months (based on a 30 day month).
* @see setMonths()
*/
double months() const;
%Docstring
Returns the interval duration in months (based on a 30 day month).
.. seealso:: setMonths()
:rtype: float
%End

/** Sets the interval duration in months.
* @param months duration in months (based on a 30 day month)
* @see months()
*/
void setMonths( double months );
%Docstring
Sets the interval duration in months.
\param months duration in months (based on a 30 day month)
.. seealso:: months()
%End

/** Returns the interval duration in weeks.
* @see setWeeks()
*/
double weeks() const;
%Docstring
Returns the interval duration in weeks.
.. seealso:: setWeeks()
:rtype: float
%End

/** Sets the interval duration in weeks.
* @param weeks duration in weeks
* @see weeks()
*/
void setWeeks( double weeks );
%Docstring
Sets the interval duration in weeks.
\param weeks duration in weeks
.. seealso:: weeks()
%End

/** Returns the interval duration in days.
* @see setDays()
*/
double days() const;
%Docstring
Returns the interval duration in days.
.. seealso:: setDays()
:rtype: float
%End

/** Sets the interval duration in days.
* @param days duration in days
* @see days()
*/
void setDays( double days );
%Docstring
Sets the interval duration in days.
\param days duration in days
.. seealso:: days()
%End

/** Returns the interval duration in hours.
* @see setHours()
*/
double hours() const;
%Docstring
Returns the interval duration in hours.
.. seealso:: setHours()
:rtype: float
%End

/** Sets the interval duration in hours.
* @param hours duration in hours
* @see hours()
*/
void setHours( double hours );
%Docstring
Sets the interval duration in hours.
\param hours duration in hours
.. seealso:: hours()
%End

/** Returns the interval duration in minutes.
* @see setMinutes()
*/
double minutes() const;
%Docstring
Returns the interval duration in minutes.
.. seealso:: setMinutes()
:rtype: float
%End

/** Sets the interval duration in minutes.
* @param minutes duration in minutes
* @see minutes()
*/
void setMinutes( double minutes );
%Docstring
Sets the interval duration in minutes.
\param minutes duration in minutes
.. seealso:: minutes()
%End

/** Returns the interval duration in seconds.
* @see setSeconds()
*/
double seconds() const;
%Docstring
Returns the interval duration in seconds.
.. seealso:: setSeconds()
:rtype: float
%End

/** Sets the interval duration in seconds.
* @param seconds duration in seconds
* @see seconds()
*/
void setSeconds( double seconds );
%Docstring
Sets the interval duration in seconds.
\param seconds duration in seconds
.. seealso:: seconds()
%End

/** Returns true if the interval is valid.
* @see setValid()
*/
bool isValid() const;
%Docstring
Returns true if the interval is valid.
.. seealso:: setValid()
:rtype: bool
%End

/** Sets whether the interval is valid.
* @param valid set to true to set the interval as valid.
* @see isValid()
*/
void setValid( bool valid );
%Docstring
Sets whether the interval is valid.
\param valid set to true to set the interval as valid.
.. seealso:: isValid()
%End

bool operator==( QgsInterval other ) const;
%Docstring
:rtype: bool
%End

/** Converts a string to an interval
* @param string string to parse
* @returns interval, or invalid interval if string could not be parsed
*/
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
:rtype: QgsInterval
%End

//! Allows direct construction of QVariants from intervals.
operator QVariant() const;
%Docstring
Allows direct construction of QVariants from intervals.
%End

};



/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsinterval.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
5 changes: 5 additions & 0 deletions src/core/qgsinterval.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <QVariant>

#include "qgis.h"
#include "qgis_core.h"

class QString;
Expand Down Expand Up @@ -175,6 +176,8 @@ class CORE_EXPORT QgsInterval

Q_DECLARE_METATYPE( QgsInterval )

#ifndef SIP_RUN

/** Returns the interval between two datetimes.
* \param datetime1 start datetime
* \param datetime2 datetime to subtract, ie subtract datetime2 from datetime1
Expand Down Expand Up @@ -210,4 +213,6 @@ QDateTime CORE_EXPORT operator+( const QDateTime &start, const QgsInterval &inte
//! Debug string representation of interval
QDebug operator<<( QDebug dbg, const QgsInterval &interval );
\
#endif

#endif // QGSINTERVAL_H

0 comments on commit d56eef1

Please sign in to comment.