19 #include <QStringList>
22 #include <QVariantList>
32 : mStatistics( stats )
51 const auto constValues = values;
52 for (
const QVariant &variant : constValues )
62 if ( value.type() == QVariant::DateTime )
64 testDateTime( value.toDateTime(), value.isNull() );
66 else if ( value.type() == QVariant::Date )
68 const QDate date = value.toDate();
69 testDateTime( date.isValid() ? QDateTime( date, QTime( 0, 0, 0 ) )
70 : QDateTime(), value.isNull() );
72 else if ( value.type() == QVariant::Time )
75 const QTime time = value.toTime();
76 testDateTime( time.isValid() ? QDateTime( QDate::fromJulianDay( 0 ), time )
77 : QDateTime(), value.isNull() );
94 void QgsDateTimeStatisticalSummary::testDateTime(
const QDateTime &dateTime,
bool isNull )
98 if ( !dateTime.isValid() || isNull )
105 if ( mStatistics &
Min || mStatistics &
Range )
107 if ( mMin.isValid() && dateTime.isValid() )
109 mMin = std::min( mMin, dateTime );
111 else if ( !mMin.isValid() && dateTime.isValid() )
116 if ( mStatistics &
Max || mStatistics &
Range )
118 if ( mMax.isValid() && dateTime.isValid() )
120 mMax = std::max( mMax, dateTime );
122 else if ( !mMax.isValid() && dateTime.isValid() )
136 return mValues.count();
138 return mCountMissing;
140 return mIsTimes ? QVariant( mMin.time() ) : QVariant( mMin );
142 return mIsTimes ? QVariant( mMax.time() ) : QVariant( mMax );
144 return mIsTimes ? QVariant::fromValue( mMax.time() - mMin.time() ) : QVariant::fromValue( mMax - mMin );
156 return QObject::tr(
"Count" );
158 return QObject::tr(
"Count (distinct)" );
160 return QObject::tr(
"Count (missing)" );
162 return QObject::tr(
"Minimum (earliest)" );
164 return QObject::tr(
"Maximum (latest)" );
166 return QObject::tr(
"Range (interval)" );