26using namespace Qt::StringLiterals;
55 if ( fieldIndex < 0 || fieldIndex >= layer->
fields().
size() )
57 return value.toString();
61 const bool fieldIsoFormat = config.value( u
"field_iso_format"_s,
false ).toBool();
62 const QString fieldFormat = config.value( u
"field_format"_s,
defaultFormat( field.
type() ) ).toString();
66 bool showTimeZone =
false;
67 if (
static_cast<QMetaType::Type
>( value.userType() ) == QMetaType::QDate )
69 date = value.toDateTime();
71 else if (
static_cast<QMetaType::Type
>( value.userType() ) == QMetaType::QDateTime )
73 date = value.toDateTime();
77 else if (
static_cast<QMetaType::Type
>( value.userType() ) == QMetaType::QTime )
79 return value.toTime().toString( displayFormat );
85 date = QDateTime::fromString( value.toString(), Qt::ISODate );
89 date = QDateTime::fromString( value.toString(), fieldFormat );
98 result = u
"%1 (%2)"_s.arg( date.toString( displayFormat ), date.timeZoneAbbreviation() );
103 if ( displayFormat.indexOf(
"Z" ) > 0 )
106 result = date.toString( displayFormat );
111 result = value.toString();
121 case QMetaType::Type::QDateTime:
123 case QMetaType::Type::QTime:
140 case QMetaType::Type::QDateTime:
142 case QMetaType::Type::QTime:
156 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 dataset.