Skip to content

Commit

Permalink
Show preview string for date/time/datetime expression results
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 28, 2016
1 parent ee5e1c7 commit 90718dd
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/core/qgsexpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4583,6 +4583,21 @@ QString QgsExpression::formatPreviewString( const QVariant& value )
QgsExpression::Interval interval = value.value<QgsExpression::Interval>();
return tr( "<i>&lt;interval: %1 days&gt;</i>" ).arg( interval.days() );
}
else if ( value.type() == QVariant::Date )
{
QDate dt = value.toDate();
return tr( "<i>&lt;date: %1&gt;</i>" ).arg( dt.toString( "yyyy-MM-dd" ) );
}
else if ( value.type() == QVariant::Time )
{
QTime tm = value.toTime();
return tr( "<i>&lt;time: %1&gt;</i>" ).arg( tm.toString( "hh:mm:ss" ) );
}
else if ( value.type() == QVariant::DateTime )
{
QDateTime dt = value.toDateTime();
return tr( "<i>&lt;datetime: %1&gt;</i>" ).arg( dt.toString( "yyyy-MM-dd hh:mm:ss" ) );
}
else if ( value.type() == QVariant::String )
{
QString previewString = value.toString();
Expand Down

0 comments on commit 90718dd

Please sign in to comment.