summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRainer Keller <Rainer.Keller@qt.io>2018-10-08 10:55:33 +0200
committerRainer Keller <Rainer.Keller@qt.io>2018-10-11 08:03:56 +0000
commit9a9ac65defef1b42888ad19ba0aa38f1fe2b239e (patch)
treea27c00d879641c5ed50e329850baaa6b6d44e1b2 /src
parent33b653e4d6882431e909dcb6c4f76309a3719fc9 (diff)
uacpp: Fix time converterv5.12.0-beta3v5.12.0-beta2
Change-Id: I9cc924f6ca834bebb4afd29255c5c63a7c6130eb Reviewed-by: Jannis Völker <jannis.voelker@basyskom.com> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/opcua/uacpp/quacppvalueconverter.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/plugins/opcua/uacpp/quacppvalueconverter.cpp b/src/plugins/opcua/uacpp/quacppvalueconverter.cpp
index 58d0eb1..5aa4f5c 100644
--- a/src/plugins/opcua/uacpp/quacppvalueconverter.cpp
+++ b/src/plugins/opcua/uacpp/quacppvalueconverter.cpp
@@ -478,7 +478,8 @@ void scalarFromQVariant<OpcUa_DateTime, QDateTime>(const QVariant &var, OpcUa_Da
{
// OPC-UA part 3, Table C.9
const QDateTime uaEpochStart(QDate(1601, 1, 1), QTime(0, 0), Qt::UTC);
- const UaDateTime dt = UaDateTime(var.toDateTime().toMSecsSinceEpoch() - uaEpochStart.toMSecsSinceEpoch());
+ // OpcUa time is defined in part 6, 5.2.2.5 in 100ns which need to be converted to milliseconds.
+ const UaDateTime dt = UaDateTime((var.toDateTime().toMSecsSinceEpoch() - uaEpochStart.toMSecsSinceEpoch()) * 10000);
*ptr = dt;
}
@@ -952,7 +953,9 @@ QDateTime toQDateTime(const OpcUa_DateTime *dt)
// OPC-UA part 3, Table C.9
const QDateTime uaEpochStart(QDate(1601, 1, 1), QTime(0, 0), Qt::UTC);
const UaDateTime temp(*dt);
- return uaEpochStart.addMSecs(temp).toLocalTime();
+
+ // OpcUa time is defined in part 6, 5.2.2.5 in 100ns which need to be converted to milliseconds.
+ return uaEpochStart.addMSecs(((quint64)temp) / 10000).toLocalTime();
}
}