Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions app/filter/filtercontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,14 @@ QString FilterController::buildFieldExpression( const FieldFilter &filter ) cons

if ( value.typeId() == QMetaType::QDateTime )
if ( isDateFilterDateTime( filter.filterId ) )
expressionCopy.replace( QStringLiteral( "@@value@@" ), QgsExpression::quotedString( value.toDateTime().toUTC().toString( TIMESTAMP_FORMAT ) ) );
{
// check if the DateTime contains milliseconds
const QDateTime utcDateTime = value.toDateTime().toUTC();
const QString dateTimeFormat = utcDateTime.time().msec() != 0
? TIMESTAMP_FORMAT
: QStringLiteral( "yyyy-MM-ddTHH:mm:ssZ" );
expressionCopy.replace( QStringLiteral( "@@value@@" ), QgsExpression::quotedString( utcDateTime.toString( dateTimeFormat ) ) );
}
else
expressionCopy.replace( QStringLiteral( "@@value@@" ), QgsExpression::quotedString( value.toDate().toString( DATE_FORMAT ) ) );
else
Expand Down Expand Up @@ -358,7 +365,14 @@ QString FilterController::buildFieldExpression( const FieldFilter &filter ) cons
// QML always returns QDateTime so we can't differentiate based on type
if ( value.typeId() == QMetaType::QDateTime )
if ( isDateFilterDateTime( filter.filterId ) )
expressionTemplate.replace( QStringLiteral( "@@value@@" ), QgsExpression::quotedString( value.toDateTime().toUTC().toString( TIMESTAMP_FORMAT ) ) );
{
// check if the DateTime contains milliseconds
const QDateTime utcDateTime = value.toDateTime().toUTC();
const QString dateTimeFormat = utcDateTime.time().msec() != 0
? TIMESTAMP_FORMAT
: QStringLiteral( "yyyy-MM-ddTHH:mm:ssZ" );
expressionTemplate.replace( QStringLiteral( "@@value@@" ), QgsExpression::quotedString( utcDateTime.toString( dateTimeFormat ) ) );
}
else
expressionTemplate.replace( QStringLiteral( "@@value@@" ), QgsExpression::quotedString( value.toDate().toString( DATE_FORMAT ) ) );
else
Expand Down
Loading