Skip to content

Commit

Permalink
Merge pull request #2829 from MerginMaps/fix_datetime
Browse files Browse the repository at this point in the history
calendar widget fixes
  • Loading branch information
tomasMizera authored Oct 5, 2023
2 parents 6775145 + 0abc397 commit 5a64427
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion app/qml/components/DateTimePicker.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 Thu Oct 12 00:00:00 2023 GMT-0600
// pickedDate.getDate(): 12
calendar.selectDate(pickedDate)
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion app/qml/editor/inputdatetime.qml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,17 @@ AbstractEditor {

onSelected: function( selectedDate ) {
if ( selectedDate )
root.editorValueChanged(selectedDate, false)
{
if ( root.parentField.isDateOrTime )
{
root.editorValueChanged(selectedDate, false)
}
else
{
let dateStr = selectedDate.toLocaleString(Qt.locale(), config['field_format'])
root.editorValueChanged(dateStr, false)
}
}

dateTimeDrawer.close()
}
Expand Down

0 comments on commit 5a64427

Please sign in to comment.