@@ -1157,6 +1157,19 @@ static QVariant fcnMakeDateTime( const QVariantList &values, const QgsExpression
1157
1157
return QVariant ( QDateTime ( date, time ) );
1158
1158
}
1159
1159
1160
+ static QVariant fcnMakeInterval ( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
1161
+ {
1162
+ const int years = QgsExpressionUtils::getIntValue ( values.at ( 0 ), parent );
1163
+ const int months = QgsExpressionUtils::getIntValue ( values.at ( 1 ), parent );
1164
+ const int weeks = QgsExpressionUtils::getIntValue ( values.at ( 2 ), parent );
1165
+ const int days = QgsExpressionUtils::getIntValue ( values.at ( 3 ), parent );
1166
+ const int hours = QgsExpressionUtils::getIntValue ( values.at ( 4 ), parent );
1167
+ const int minutes = QgsExpressionUtils::getIntValue ( values.at ( 5 ), parent );
1168
+ const double seconds = QgsExpressionUtils::getDoubleValue ( values.at ( 6 ), parent );
1169
+
1170
+ return QVariant::fromValue ( QgsInterval ( years, months, weeks, days, hours, minutes, seconds ) );
1171
+ }
1172
+
1160
1173
static QVariant fcnCoalesce ( const QVariantList &values, const QgsExpressionContext *, QgsExpression *, const QgsExpressionNodeFunction * )
1161
1174
{
1162
1175
for ( const QVariant &value : values )
@@ -5807,6 +5820,14 @@ const QList<QgsExpressionFunction *> &QgsExpression::Functions()
5807
5820
<< QgsExpressionFunction::Parameter ( QStringLiteral ( " minute" ) )
5808
5821
<< QgsExpressionFunction::Parameter ( QStringLiteral ( " second" ) ),
5809
5822
fcnMakeDateTime, QStringLiteral ( " Date and Time" ) )
5823
+ << new QgsStaticExpressionFunction ( QStringLiteral ( " make_interval" ), QgsExpressionFunction::ParameterList () << QgsExpressionFunction::Parameter ( QStringLiteral ( " years" ), true , 0 )
5824
+ << QgsExpressionFunction::Parameter ( QStringLiteral ( " months" ), true , 0 )
5825
+ << QgsExpressionFunction::Parameter ( QStringLiteral ( " weeks" ), true , 0 )
5826
+ << QgsExpressionFunction::Parameter ( QStringLiteral ( " days" ), true , 0 )
5827
+ << QgsExpressionFunction::Parameter ( QStringLiteral ( " hours" ), true , 0 )
5828
+ << QgsExpressionFunction::Parameter ( QStringLiteral ( " minutes" ), true , 0 )
5829
+ << QgsExpressionFunction::Parameter ( QStringLiteral ( " seconds" ), true , 0 ),
5830
+ fcnMakeInterval, QStringLiteral ( " Date and Time" ) )
5810
5831
<< new QgsStaticExpressionFunction ( QStringLiteral ( " lower" ), QgsExpressionFunction::ParameterList () << QgsExpressionFunction::Parameter ( QStringLiteral ( " string" ) ), fcnLower, QStringLiteral ( " String" ) )
5811
5832
<< new QgsStaticExpressionFunction ( QStringLiteral ( " upper" ), QgsExpressionFunction::ParameterList () << QgsExpressionFunction::Parameter ( QStringLiteral ( " string" ) ), fcnUpper, QStringLiteral ( " String" ) )
5812
5833
<< new QgsStaticExpressionFunction ( QStringLiteral ( " title" ), QgsExpressionFunction::ParameterList () << QgsExpressionFunction::Parameter ( QStringLiteral ( " string" ) ), fcnTitle, QStringLiteral ( " String" ) )
0 commit comments