From 39bc3743d7aa9f03f694f692e6e8874c7c6e7bd6 Mon Sep 17 00:00:00 2001 From: PeterPetrik Date: Thu, 5 Oct 2023 09:40:10 +0200 Subject: [PATCH] fix #1671 wrong calendar day with TZ=America/Mexico_City --- app/qml/components/DateTimePicker.qml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/qml/components/DateTimePicker.qml b/app/qml/components/DateTimePicker.qml index 7aea3431d9..ebfeb2533d 100644 --- a/app/qml/components/DateTimePicker.qml +++ b/app/qml/components/DateTimePicker.qml @@ -392,7 +392,17 @@ Item { MouseArea { anchors.fill: parent onClicked: { - calendar.selectDate(model.date) + let pickedDate = new Date( model.year, model.month, model.day); + // Do NOT use model.date!! + // see https://bugreports.qt.io/browse/QTBUG-72208 + // For some timezones model.date.getDate() != model.day + // e.g. you are in timezone TZ=America/Mexico_City + // model.date: Wed Oct 11 18:00:00 2023 GMT-0600 + // model.day: 12 + // model.date.getDate(): 11 + // pickedDate Fri Oct 12 00:00:00 2023 GMT-0600 + // pickedDate.getDate(): 12 + calendar.selectDate(pickedDate) } } }