[Interest] Strange behaviour on aliased Date object
Dmitrii Volosnykh
dmitrii.volosnykh at gmail.com
Sun Nov 9 18:02:03 CET 2014
Hi,
I have encountered troubles when trying to declare readonly property alias
to an internal var (which actually is a Date object). Here is an example
which reproduces it on my laptop:
import QtQuick 2.0
Rectangle {
width: 100
height: 62
color: time.getTime() === internal.time.getTime() ? "green" : "red"
readonly property alias time: internal.time
onTimeChanged: {
if (typeof time === "undefined") return
console.log("time:", Qt.formatDateTime(time), time.getTime())
console.assert(time.getTime() === internal.time.getTime(), "not
equal")
}
Component.onCompleted: internal.time = new Date(1403621359000)
QtObject {
id: internal
property var time: undefined
}
}
The value reported by outer time property is indeed a strictly one hour
earlier what leads me to a conclusion that, probably, day saving time
mechanism may be involved.
If I replace "alias" with "var", the value is as expected, though.
Are there any pitfalls I should be aware of? What could cause such
behaviour? The expectation is that alias should not do any
transformations/conversions on aliased value.
Regards,
Dmitrii.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20141109/524d08ec/attachment.html>
More information about the Interest
mailing list