aboutsummaryrefslogtreecommitdiffstats
path: root/src/shared/trk/trkutils.cpp
diff options
context:
space:
mode:
authorRobert Loehning <[email protected]>2009-12-02 14:42:03 +0100
committerRobert Loehning <[email protected]>2009-12-02 14:43:22 +0100
commite494864b08f094d0efe2bb49208ae316f97cbc6d (patch)
tree282d5a222211aa7bbff737e40a16d60aceca5515 /src/shared/trk/trkutils.cpp
parent7057584f982e1a607140f267995c7352a1356cd8 (diff)
Trk: Setting correct date and time when closing remote file.
Reviewed-by: Friedemann Kleint
Diffstat (limited to 'src/shared/trk/trkutils.cpp')
-rw-r--r--src/shared/trk/trkutils.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/shared/trk/trkutils.cpp b/src/shared/trk/trkutils.cpp
index 458390d8893..256d4ad1e19 100644
--- a/src/shared/trk/trkutils.cpp
+++ b/src/shared/trk/trkutils.cpp
@@ -32,6 +32,9 @@
#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
+#include <QtCore/QDate>
+#include <QtCore/QDateTime>
+#include <QtCore/QTime>
#define logMessage(s) do { qDebug() << "TRKCLIENT: " << s; } while (0)
@@ -400,6 +403,18 @@ void appendString(QByteArray *ba, const QByteArray &str, Endianness endian, bool
ba->append('\0');
}
+void appendDateTime(QByteArray *ba, QDateTime dateTime, Endianness endian)
+{
+ // convert the QDateTime to UTC and append its representation to QByteArray
+ // format is the same as in FAT file system
+ dateTime = dateTime.toUTC();
+ const QTime utcTime = dateTime.time();
+ const QDate utcDate = dateTime.date();
+ uint fatDateTime = (utcTime.hour() << 11 | utcTime.minute() << 5 | utcTime.second()/2) << 16;
+ fatDateTime |= (utcDate.year()-1980) << 9 | utcDate.month() << 5 | utcDate.day();
+ appendInt(ba, fatDateTime, endian);
+}
+
QByteArray errorMessage(byte code)
{
switch (code) {