Skip to content
Permalink
Browse files

Fix timezone handling issue when getting min/max value of datetime fr…

…om gpkg
  • Loading branch information
nyalldawson committed May 14, 2020
1 parent 05e959f commit 9165b1cb4b362b4187782a4b2bd1a62abdeff493
Showing with 16 additions and 0 deletions.
  1. +16 −0 src/core/providers/ogr/qgsogrprovider.cpp
@@ -3908,6 +3908,14 @@ QVariant QgsOgrProvider::minimumValue( int index ) const
if ( res.type() != originalField.type() )
res = convertValue( originalField.type(), res.toString() );

if ( originalField.type() == QVariant::DateTime )
{
// ensure that we treat times as local time, to match behaviour when iterating features
QDateTime temp = res.toDateTime();
temp.setTimeSpec( Qt::LocalTime );
res = temp;
}

return res;
}

@@ -3956,6 +3964,14 @@ QVariant QgsOgrProvider::maximumValue( int index ) const
if ( res.type() != originalField.type() )
res = convertValue( originalField.type(), res.toString() );

if ( originalField.type() == QVariant::DateTime )
{
// ensure that we treat times as local time, to match behaviour when iterating features
QDateTime temp = res.toDateTime();
temp.setTimeSpec( Qt::LocalTime );
res = temp;
}

return res;
}

0 comments on commit 9165b1c

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