Skip to content

Commit

Permalink
Fix timezone handling issue when getting min/max value of datetime fr…
Browse files Browse the repository at this point in the history
…om gpkg
  • Loading branch information
nyalldawson committed May 14, 2020
1 parent 05e959f commit 9165b1c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/core/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 9165b1c

Please sign in to comment.