19 #include <QStringList>
22 #include <QVariantList>
32 : mStatistics( stats )
51 const auto constValues = values;
52 for (
const QVariant &variant : constValues )
61 if ( value.type() == QVariant::DateTime )
63 testDateTime( value.toDateTime() );
65 else if ( value.type() == QVariant::Date )
67 QDate date = value.toDate();
68 testDateTime( date.isValid() ? QDateTime( date, QTime( 0, 0, 0 ) )
71 else if ( value.type() == QVariant::Time )
74 QTime time = value.toTime();
75 testDateTime( time.isValid() ? QDateTime( QDate::fromJulianDay( 0 ), time )
92 void QgsDateTimeStatisticalSummary::testDateTime(
const QDateTime &dateTime )
96 if ( !dateTime.isValid() )
103 if ( mStatistics &
Min || mStatistics &
Range )
105 if ( mMin.isValid() && dateTime.isValid() )
107 mMin = std::min( mMin, dateTime );
109 else if ( !mMin.isValid() && dateTime.isValid() )
114 if ( mStatistics &
Max || mStatistics &
Range )
116 if ( mMax.isValid() && dateTime.isValid() )
118 mMax = std::max( mMax, dateTime );
120 else if ( !mMax.isValid() && dateTime.isValid() )
134 return mValues.count();
136 return mCountMissing;
138 return mIsTimes ? QVariant( mMin.time() ) : QVariant( mMin );
140 return mIsTimes ? QVariant( mMax.time() ) : QVariant( mMax );
142 return mIsTimes ? QVariant::fromValue( mMax.time() - mMin.time() ) : QVariant::fromValue( mMax - mMin );
154 return QObject::tr(
"Count" );
156 return QObject::tr(
"Count (distinct)" );
158 return QObject::tr(
"Count (missing)" );
160 return QObject::tr(
"Minimum (earliest)" );
162 return QObject::tr(
"Maximum (latest)" );
164 return QObject::tr(
"Range (interval)" );