35 return QStringLiteral(
"DateTime" );
49 if ( fieldIndex < 0 || fieldIndex >= layer->
fields().
size() )
51 return value.toString();
55 const bool fieldIsoFormat = config.value( QStringLiteral(
"field_iso_format" ),
false ).toBool();
56 const QString fieldFormat = config.value( QStringLiteral(
"field_format" ),
defaultFormat(
field.
type() ) ).toString();
57 const QString displayFormat = config.value( QStringLiteral(
"display_format" ),
defaultFormat(
field.
type() ) ).toString();
60 bool showTimeZone =
false;
61 if (
static_cast<QMetaType::Type
>( value.type() ) == QMetaType::QDate )
63 date = value.toDateTime();
65 else if (
static_cast<QMetaType::Type
>( value.type() ) == QMetaType::QDateTime )
67 date = value.toDateTime();
71 else if (
static_cast<QMetaType::Type
>( value.type() ) == QMetaType::QTime )
73 return value.toTime().toString( displayFormat );
79 date = QDateTime::fromString( value.toString(), Qt::ISODate );
83 date = QDateTime::fromString( value.toString(), fieldFormat );
92 result = QStringLiteral(
"%1 (%2)" ).arg( date.toString( displayFormat ), date.timeZoneAbbreviation() );
96 result = date.toString( displayFormat );
101 result = value.toString();
111 case QVariant::DateTime:
122 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.