37 return QStringLiteral(
"DateTime" );
51 if ( fieldIndex < 0 || fieldIndex >= layer->
fields().
size() )
53 return value.toString();
57 const bool fieldIsoFormat = config.value( QStringLiteral(
"field_iso_format" ),
false ).toBool();
58 const QString fieldFormat = config.value( QStringLiteral(
"field_format" ),
defaultFormat( field.
type() ) ).toString();
59 const QString displayFormat = config.value( QStringLiteral(
"display_format" ),
defaultDisplayFormat( field.
type() ) ).toString();
62 bool showTimeZone =
false;
63 if (
static_cast<QMetaType::Type
>( value.userType() ) == QMetaType::QDate )
65 date = value.toDateTime();
67 else if (
static_cast<QMetaType::Type
>( value.userType() ) == QMetaType::QDateTime )
69 date = value.toDateTime();
73 else if (
static_cast<QMetaType::Type
>( value.userType() ) == QMetaType::QTime )
75 return value.toTime().toString( displayFormat );
81 date = QDateTime::fromString( value.toString(), Qt::ISODate );
85 date = QDateTime::fromString( value.toString(), fieldFormat );
94 result = QStringLiteral(
"%1 (%2)" ).arg( date.toString( displayFormat ), date.timeZoneAbbreviation() );
99 if ( displayFormat.indexOf(
"Z" ) > 0 )
102 result = date.toString( displayFormat );
107 result = value.toString();
117 case QMetaType::Type::QDateTime:
119 case QMetaType::Type::QTime:
136 case QMetaType::Type::QDateTime:
138 case QMetaType::Type::QTime:
152 QString dateFormat = QLocale().dateFormat( QLocale::FormatType::ShortFormat );
static QString nullRepresentation()
Returns the string used to represent the value NULL throughout QGIS.
Encapsulate a field in an attribute table or data source.
int size() const
Returns number of items.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
static QMetaType::Type variantTypeToMetaType(QVariant::Type variantType)
Converts a QVariant::Type to a QMetaType::Type.
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
Represents a vector layer which manages a vector based data sets.