Skip to content
Permalink
Browse files

Show preview string for date/time/datetime expression results

  • Loading branch information
nyalldawson committed Jan 28, 2016
1 parent ee5e1c7 commit 90718ddfd4b0c009110b28e363e0abe348211309
Showing with 15 additions and 0 deletions.
  1. +15 −0 src/core/qgsexpression.cpp
@@ -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();

0 comments on commit 90718dd

Please sign in to comment.
You can’t perform that action at this time.