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.type() ) == QMetaType::QDate )
65 date = value.toDateTime();
67 else if (
static_cast<QMetaType::Type
>( value.type() ) == QMetaType::QDateTime )
69 date = value.toDateTime();
73 else if (
static_cast<QMetaType::Type
>( value.type() ) == 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() );
98 result = date.toString( displayFormat );
103 result = value.toString();
113 case QVariant::DateTime:
126 case QVariant::DateTime:
137 QString dateFormat = QLocale().dateFormat( QLocale::FormatType::ShortFormat );
static QString nullRepresentation()
This string is 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 bool isNull(const QVariant &variant)
Returns true if the specified variant should be considered a NULL value.
Represents a vector layer which manages a vector based data sets.
QgsFields fields() const FINAL
Returns the list of fields of this layer.