diff options
author | Felix Geyer <debfx@fobos.de> | 2012-06-24 13:25:06 +0400 |
---|---|---|
committer | Felix Geyer <debfx@fobos.de> | 2012-06-24 13:25:06 +0400 |
commit | 38d2b124d86bfc33df6baf368b2b65696f260b93 (patch) | |
tree | 1c9a7d539fb6ac69d401e6e98b9623119115ae2c /src | |
parent | 513ba6d19d7fef988482c6e6fa2067831600aca0 (diff) |
Fix datetime serialization appending two 'Z' at the end with Qt >= 4.8.
Diffstat (limited to 'src')
-rw-r--r-- | src/format/KeePass2XmlWriter.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/format/KeePass2XmlWriter.cpp b/src/format/KeePass2XmlWriter.cpp index 9a9b28d43..c64ba796a 100644 --- a/src/format/KeePass2XmlWriter.cpp +++ b/src/format/KeePass2XmlWriter.cpp @@ -440,8 +440,16 @@ void KeePass2XmlWriter::writeBool(const QString& qualifiedName, bool b) void KeePass2XmlWriter::writeDateTime(const QString& qualifiedName, const QDateTime& dateTime) { Q_ASSERT(dateTime.isValid()); + Q_ASSERT(dateTime.timeSpec() == Qt::UTC); - writeString(qualifiedName, dateTime.toUTC().toString(Qt::ISODate).append('Z')); + QString dateTimeStr = dateTime.toString(Qt::ISODate); + + // Qt < 4.8 doesn't append a 'Z' at the end + if (!dateTimeStr.isEmpty() && dateTimeStr[dateTimeStr.size() - 1] != 'Z') { + dateTimeStr.append('Z'); + } + + writeString(qualifiedName, dateTimeStr); } void KeePass2XmlWriter::writeUuid(const QString& qualifiedName, const Uuid& uuid) |