Skip to content
Permalink
Browse files

Fix AFS datetime value handling

  • Loading branch information
nyalldawson committed May 13, 2020
1 parent e82aa17 commit 72a9ef5a33d08cbd2a5d6a5586f03a37df01dd7b
Showing with 9 additions and 3 deletions.
  1. +2 −2 src/providers/arcgisrest/qgsarcgisrestutils.cpp
  2. +7 −1 tests/src/python/test_provider_afs.py
@@ -54,7 +54,7 @@ QVariant::Type QgsArcGisRestUtils::mapEsriFieldType( const QString &esriFieldTyp
if ( esriFieldType == QLatin1String( "esriFieldTypeString" ) )
return QVariant::String;
if ( esriFieldType == QLatin1String( "esriFieldTypeDate" ) )
return QVariant::Date;
return QVariant::DateTime;
if ( esriFieldType == QLatin1String( "esriFieldTypeGeometry" ) )
return QVariant::Invalid; // Geometry column should not appear as field
if ( esriFieldType == QLatin1String( "esriFieldTypeOID" ) )
@@ -1070,7 +1070,7 @@ QDateTime QgsArcGisRestUtils::parseDateTime( const QVariant &value )
if ( value.isNull() )
return QDateTime();
bool ok = false;
QDateTime dt = QDateTime::fromMSecsSinceEpoch( value.toLongLong( &ok ), Qt::UTC );
QDateTime dt = QDateTime::fromMSecsSinceEpoch( value.toLongLong( &ok ) );
if ( !ok )
{
QgsDebugMsg( QStringLiteral( "Invalid value %1 for datetime" ).arg( value.toString() ) );
@@ -244,6 +244,9 @@ def setUpClass(cls):
{"name":"name","type":"esriFieldTypeString","alias":"name","length":100,"domain":null},
{"name":"name2","type":"esriFieldTypeString","alias":"name2","length":100,"domain":null},
{"name":"num_char","type":"esriFieldTypeString","alias":"num_char","length":100,"domain":null},
{"name":"dt","type":"esriFieldTypeDate","alias":"num_char","length":100,"domain":null},
{"name":"date","type":"esriFieldTypeDate","alias":"num_char","length":100,"domain":null},
{"name":"time","type":"esriFieldTypeDate","alias":"num_char","length":100,"domain":null},
{"name":"Shape","type":"esriFieldTypeGeometry","alias":"Shape","domain":null}],
"features": [
{
@@ -336,6 +339,9 @@ def setUpClass(cls):
{"name":"name","type":"esriFieldTypeString","alias":"name","length":100,"domain":null},
{"name":"name2","type":"esriFieldTypeString","alias":"name2","length":100,"domain":null},
{"name":"num_char","type":"esriFieldTypeString","alias":"num_char","length":100,"domain":null},
{"name":"dt","type":"esriFieldTypeDate","alias":"num_char","length":100,"domain":null},
{"name":"date","type":"esriFieldTypeDate","alias":"num_char","length":100,"domain":null},
{"name":"time","type":"esriFieldTypeDate","alias":"num_char","length":100,"domain":null},
{"name":"Shape","type":"esriFieldTypeGeometry","alias":"Shape","domain":null}],
"features": [
{
@@ -607,7 +613,7 @@ def testDateTime(self):

features = [f for f in vl.getFeatures()]
self.assertEqual(len(features), 2)
self.assertEqual([f['dt'] for f in features], [QDate(2017, 5, 3), NULL])
self.assertEqual([f['dt'] for f in features], [QDateTime(2017, 5, 3, 0, 0, 0, 0, Qt.UTC).toLocalTime(), NULL])

def testMetadata(self):
""" Test that metadata is correctly acquired from provider """

0 comments on commit 72a9ef5

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