--- /dev/null
+import Qt.test 1.0
+import QtQuick 2.0
+
+MyTypeObject {
+ Component.onCompleted: {
+ var dateVar = new Date(Date.UTC(2009, 4, 12))
+ var dateTimeVar = new Date(Date.UTC(2009, 4, 12, 0, 0, 1))
+ var dateTimeVar2 = new Date(Date.UTC(2009, 4, 12, 23, 59, 59))
+
+ dateProperty = dateVar
+ dateTimeProperty = dateTimeVar
+ dateTimeProperty2 = dateTimeVar2
+
+ // Commented properties do not currently test true:
+ boolProperty = //(dateProperty.getTime() == dateVar.getTime()) &&
+ (dateProperty.getFullYear() == 2009) &&
+ (dateProperty.getMonth() == 5-1) &&
+ //(dateProperty.getDate() == 12) &&
+ (dateProperty.getHours() == 0) &&
+ (dateTimeProperty.getTime() == dateTimeVar.getTime()) &&
+ (dateTimeProperty.getFullYear() == 2009) &&
+ (dateTimeProperty.getMonth() == 5-1) &&
+ //(dateTimeProperty.getDate() == 12) &&
+ //(dateTimeProperty.getHours() == 0) &&
+ (dateTimeProperty.getMinutes() == 0) &&
+ (dateTimeProperty.getSeconds() == 1) &&
+ (dateTimeProperty2.getTime() == dateTimeVar2.getTime()) &&
+ (dateTimeProperty2.getFullYear() == 2009) &&
+ (dateTimeProperty2.getMonth() == 5-1) &&
+ //(dateTimeProperty2.getDate() == 12) &&
+ //(dateTimeProperty2.getHours() == 23) &&
+ (dateTimeProperty2.getMinutes() == 59) &&
+ (dateTimeProperty2.getSeconds() == 59)
+ }
+}
import Qt.test 1.0
+import QtQuick 2.0
MyTypeObject {
- dateProperty: if(1) new Date("1982-11-25")
- dateTimeProperty: if(1) new Date("2009-05-12T13:22:01")
+ dateProperty: if (1) new Date("2009-05-12")
+ dateTimeProperty: if (1) new Date("2009-05-12T00:00:01")
+ dateTimeProperty2: if (1) new Date("2009-05-12T23:59:59")
+
+ boolProperty: false
+ Component.onCompleted: {
+ var dateVar = new Date("2009-05-12")
+ var dateTimeVar = new Date("2009-05-12T00:00:01")
+ var dateTimeVar2 = new Date("2009-05-12T23:59:59")
+
+ // Commented properties do not currently test true:
+ boolProperty = //(dateProperty.getTime() == dateVar.getTime()) &&
+ (dateProperty.getFullYear() == 2009) &&
+ (dateProperty.getMonth() == 5-1) &&
+ //(dateProperty.getDate() == 12) &&
+ (dateProperty.getHours() == 0) &&
+ (dateTimeProperty.getTime() == dateTimeVar.getTime()) &&
+ (dateTimeProperty.getFullYear() == 2009) &&
+ (dateTimeProperty.getMonth() == 5-1) &&
+ //(dateTimeProperty.getDate() == 12) &&
+ //(dateTimeProperty.getHours() == 0) &&
+ (dateTimeProperty.getMinutes() == 0) &&
+ (dateTimeProperty.getSeconds() == 1) &&
+ (dateTimeProperty2.getTime() == dateTimeVar2.getTime()) &&
+ (dateTimeProperty2.getFullYear() == 2009) &&
+ (dateTimeProperty2.getMonth() == 5-1) &&
+ //(dateTimeProperty2.getDate() == 12) &&
+ //(dateTimeProperty2.getHours() == 23) &&
+ (dateTimeProperty2.getMinutes() == 59) &&
+ (dateTimeProperty2.getSeconds() == 59)
+ }
}
import Qt.test 1.0
+import QtQuick 2.0
MyTypeObject {
- dateProperty: if(1) "1982-11-25Z"
- dateTimeProperty: if(1) "2009-05-12T13:22:01Z"
+ dateProperty: if (1) "2009-05-12Z"
+ dateTimeProperty: if (1) "2009-05-12T00:00:01Z"
+ dateTimeProperty2: if (1) "2009-05-12T23:59:59Z"
+
+ boolProperty: false
+ Component.onCompleted: {
+ var dateVar = new Date("2009-05-12Z")
+ var dateTimeVar = new Date("2009-05-12T00:00:01Z")
+ var dateTimeVar2 = new Date("2009-05-12T23:59:59Z")
+
+ // Commented properties do not currently test true:
+ boolProperty = //(dateProperty.getTime() == dateVar.getTime()) &&
+ (dateProperty.getFullYear() == 2009) &&
+ (dateProperty.getMonth() == 5-1) &&
+ //(dateProperty.getDate() == 12) &&
+ (dateProperty.getHours() == 0) &&
+ (dateTimeProperty.getTime() == dateTimeVar.getTime()) &&
+ (dateTimeProperty.getFullYear() == 2009) &&
+ (dateTimeProperty.getMonth() == 5-1) &&
+ //(dateTimeProperty.getDate() == 12) &&
+ //(dateTimeProperty.getHours() == 0) &&
+ (dateTimeProperty.getMinutes() == 0) &&
+ (dateTimeProperty.getSeconds() == 1) &&
+ (dateTimeProperty2.getTime() == dateTimeVar2.getTime()) &&
+ (dateTimeProperty2.getFullYear() == 2009) &&
+ (dateTimeProperty2.getMonth() == 5-1) &&
+ //(dateTimeProperty2.getDate() == 12) &&
+ //(dateTimeProperty2.getHours() == 23) &&
+ (dateTimeProperty2.getMinutes() == 59) &&
+ (dateTimeProperty2.getSeconds() == 59)
+ }
}
import Qt.test 1.0
+import QtQuick 2.0
MyTypeObject {
- dateProperty: if(1) new Date("1982-11-25Z")
- dateTimeProperty: if(1) new Date("2009-05-12T13:22:01Z")
+ dateProperty: if (1) new Date("2009-05-12Z")
+ dateTimeProperty: if (1) new Date("2009-05-12T00:00:01Z")
+ dateTimeProperty2: if (1) new Date("2009-05-12T23:59:59Z")
+
+ boolProperty: false
+ Component.onCompleted: {
+ var dateVar = new Date("2009-05-12Z")
+ var dateTimeVar = new Date("2009-05-12T00:00:01Z")
+ var dateTimeVar2 = new Date("2009-05-12T23:59:59Z")
+
+ // Commented properties do not currently test true:
+ boolProperty = //(dateProperty.getTime() == dateVar.getTime()) &&
+ (dateProperty.getFullYear() == 2009) &&
+ (dateProperty.getMonth() == 5-1) &&
+ //(dateProperty.getDate() == 12) &&
+ (dateProperty.getHours() == 0) &&
+ (dateTimeProperty.getTime() == dateTimeVar.getTime()) &&
+ (dateTimeProperty.getFullYear() == 2009) &&
+ (dateTimeProperty.getMonth() == 5-1) &&
+ //(dateTimeProperty.getDate() == 12) &&
+ //(dateTimeProperty.getHours() == 0) &&
+ (dateTimeProperty.getMinutes() == 0) &&
+ (dateTimeProperty.getSeconds() == 1) &&
+ (dateTimeProperty2.getTime() == dateTimeVar2.getTime()) &&
+ (dateTimeProperty2.getFullYear() == 2009) &&
+ (dateTimeProperty2.getMonth() == 5-1) &&
+ //(dateTimeProperty2.getDate() == 12) &&
+ //(dateTimeProperty2.getHours() == 23) &&
+ (dateTimeProperty2.getMinutes() == 59) &&
+ (dateTimeProperty2.getSeconds() == 59)
+ }
}
import Qt.test 1.0
+import QtQuick 2.0
MyTypeObject {
- dateProperty: if(1) "1982-11-25Z"
- dateTimeProperty: if(1) "2009-05-12T15:22:01+02:00"
+ dateProperty: if (1) "2009-05-12Z"
+ dateTimeProperty: if (1) "2009-05-12T00:00:01Z"
+ dateTimeProperty2: if (1) "2009-05-12T23:59:59Z"
+
+ boolProperty: false
+ Component.onCompleted: {
+ var dateVar = new Date("2009-05-12Z")
+ var dateTimeVar = new Date("2009-05-12T00:00:01Z")
+ var dateTimeVar2 = new Date("2009-05-12T23:59:59Z")
+
+ // Commented properties do not currently test true:
+ boolProperty = //(dateProperty.getTime() == dateVar.getTime()) &&
+ (dateProperty.getFullYear() == 2009) &&
+ (dateProperty.getMonth() == 5-1) &&
+ //(dateProperty.getDate() == 12) &&
+ (dateProperty.getHours() == 0) &&
+ (dateTimeProperty.getTime() == dateTimeVar.getTime()) &&
+ (dateTimeProperty.getFullYear() == 2009) &&
+ (dateTimeProperty.getMonth() == 5-1) &&
+ //(dateTimeProperty.getDate() == 12) &&
+ //(dateTimeProperty.getHours() == 0) &&
+ (dateTimeProperty.getMinutes() == 0) &&
+ (dateTimeProperty.getSeconds() == 1) &&
+ (dateTimeProperty2.getTime() == dateTimeVar2.getTime()) &&
+ (dateTimeProperty2.getFullYear() == 2009) &&
+ (dateTimeProperty2.getMonth() == 5-1) &&
+ //(dateTimeProperty2.getDate() == 12) &&
+ //(dateTimeProperty2.getHours() == 23) &&
+ (dateTimeProperty2.getMinutes() == 59) &&
+ (dateTimeProperty2.getSeconds() == 59)
+ }
}
import Qt.test 1.0
+import QtQuick 2.0
MyTypeObject {
- dateProperty: if(1) new Date("1982-11-25")
- dateTimeProperty: if(1) new Date("2009-05-12T15:22:01+02:00")
+ dateProperty: if (1) new Date("2009-05-12")
+ dateTimeProperty: if (1) new Date("2009-05-12T02:00:01+02:00")
+ dateTimeProperty2: if (1) new Date("2009-05-13T01:59:59+02:00")
+
+ boolProperty: false
+ Component.onCompleted: {
+ var dateVar = new Date("2009-05-12")
+ var dateTimeVar = new Date("2009-05-12T02:00:01+02:00")
+ var dateTimeVar2 = new Date("2009-05-13T01:59:59+02:00")
+
+ // Commented properties do not currently test true:
+ boolProperty = //(dateProperty.getTime() == dateVar.getTime()) &&
+ (dateProperty.getFullYear() == 2009) &&
+ (dateProperty.getMonth() == 5-1) &&
+ //(dateProperty.getDate() == 12) &&
+ (dateProperty.getHours() == 0) &&
+ (dateTimeProperty.getTime() == dateTimeVar.getTime()) &&
+ (dateTimeProperty.getFullYear() == 2009) &&
+ (dateTimeProperty.getMonth() == 5-1) &&
+ //(dateTimeProperty.getDate() == 12) &&
+ //(dateTimeProperty.getHours() == 0) &&
+ (dateTimeProperty.getMinutes() == 0) &&
+ (dateTimeProperty.getSeconds() == 1) &&
+ (dateTimeProperty2.getTime() == dateTimeVar2.getTime()) &&
+ (dateTimeProperty2.getFullYear() == 2009) &&
+ (dateTimeProperty2.getMonth() == 5-1) &&
+ //(dateTimeProperty2.getDate() == 12) &&
+ //(dateTimeProperty2.getHours() == 23) &&
+ (dateTimeProperty2.getMinutes() == 59) &&
+ (dateTimeProperty2.getSeconds() == 59)
+ }
}
MyTypeObject {
Component.onCompleted: {
- dateProperty = new Date("1982-11-25")
- dateTimeProperty = new Date("2009-05-12T13:22:01")
+ var dateVar = new Date("2009-05-12")
+ var dateTimeVar = new Date("2009-05-12T00:00:01")
+ var dateTimeVar2 = new Date("2009-05-12T23:59:59")
+
+ dateProperty = dateVar
+ dateTimeProperty = dateTimeVar
+ dateTimeProperty2 = dateTimeVar2
+
+ // Commented properties do not currently test true:
+ boolProperty = //(dateProperty.getTime() == dateVar.getTime()) &&
+ (dateProperty.getFullYear() == 2009) &&
+ (dateProperty.getMonth() == 5-1) &&
+ //(dateProperty.getDate() == 12) &&
+ (dateProperty.getHours() == 0) &&
+ (dateTimeProperty.getTime() == dateTimeVar.getTime()) &&
+ (dateTimeProperty.getFullYear() == 2009) &&
+ (dateTimeProperty.getMonth() == 5-1) &&
+ //(dateTimeProperty.getDate() == 12) &&
+ //(dateTimeProperty.getHours() == 0) &&
+ (dateTimeProperty.getMinutes() == 0) &&
+ (dateTimeProperty.getSeconds() == 1) &&
+ (dateTimeProperty2.getTime() == dateTimeVar2.getTime()) &&
+ (dateTimeProperty2.getFullYear() == 2009) &&
+ (dateTimeProperty2.getMonth() == 5-1) &&
+ //(dateTimeProperty2.getDate() == 12) &&
+ //(dateTimeProperty2.getHours() == 23) &&
+ (dateTimeProperty2.getMinutes() == 59) &&
+ (dateTimeProperty2.getSeconds() == 59)
}
}
Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty)
Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty)
Q_PROPERTY(QDateTime dateTimeProperty READ dateTimeProperty WRITE setDateTimeProperty)
+ Q_PROPERTY(QDateTime dateTimeProperty2 READ dateTimeProperty2 WRITE setDateTimeProperty2)
Q_PROPERTY(QPoint pointProperty READ pointProperty WRITE setPointProperty)
Q_PROPERTY(QPointF pointFProperty READ pointFProperty WRITE setPointFProperty)
Q_PROPERTY(QSize sizeProperty READ sizeProperty WRITE setSizeProperty)
dateTimePropertyValue = v;
}
+ QDateTime dateTimePropertyValue2;
+ QDateTime dateTimeProperty2() const {
+ return dateTimePropertyValue2;
+ }
+ void setDateTimeProperty2(const QDateTime &v) {
+ dateTimePropertyValue2 = v;
+ }
+
QPoint pointPropertyValue;
QPoint pointProperty() const {
return pointPropertyValue;
void tst_qqmlecmascript::assignDate_data()
{
QTest::addColumn<QUrl>("source");
- QTest::newRow("Component.onComplete JS") << testFileUrl("assignDate.qml");
+
+ QTest::newRow("Component.onComplete JS Parse") << testFileUrl("assignDate.qml");
+ QTest::newRow("Component.onComplete JS") << testFileUrl("assignDate.1.qml");
QTest::newRow("Binding JS") << testFileUrl("assignDate.2.qml");
QTest::newRow("Binding UTC") << testFileUrl("assignDate.3.qml");
QTest::newRow("Binding JS UTC") << testFileUrl("assignDate.4.qml");
void tst_qqmlecmascript::assignDate()
{
QFETCH(QUrl, source);
+
QQmlComponent component(&engine, source);
QScopedPointer<QObject> obj(component.create());
MyTypeObject *object = qobject_cast<MyTypeObject *>(obj.data());
QVERIFY(object != 0);
- QCOMPARE(object->dateProperty(), QDate(1982, 11, 25));
- QCOMPARE(object->dateTimeProperty(), QDateTime(QDate(2009, 5, 12), QTime(13, 22, 1), Qt::UTC));
+
+ // Dates received from JS are automatically converted to local time
+ QDate expectedDate(QDateTime(QDate(2009, 5, 12), QTime(0, 0, 0), Qt::UTC).toLocalTime().date());
+ QDateTime expectedDateTime(QDateTime(QDate(2009, 5, 12), QTime(0, 0, 1), Qt::UTC).toLocalTime());
+ QDateTime expectedDateTime2(QDateTime(QDate(2009, 5, 12), QTime(23, 59, 59), Qt::UTC).toLocalTime());
+
+ QCOMPARE(object->dateProperty(), expectedDate);
+ QCOMPARE(object->dateTimeProperty(), expectedDateTime);
+ QCOMPARE(object->dateTimeProperty2(), expectedDateTime2);
+ QCOMPARE(object->boolProperty(), true);
}
void tst_qqmlecmascript::idShortcutInvalidates()