Skip to content

KDatePicker: Avoid usage of ambiguous two-digit year in date picker

This makes the date picker show the date in short date format but with a four-digit year. Moreover, it adds support for entering a date in this format. This solves the problem that two-digit years are ambiguous and that Qt is stuck in the last century (probably for good reasons), so that it interprets the two-digit year 22 as meaning 1922 which is highly unlikely in the year 2022.

To reproduce the problem that this MR fixes open a date picker (e.g. by running the kdatecomboboxtestapp in this repo). The date picker will show the current date in short format with a 2-digit year (at least, for most locales), currently "22". Give input focus to the date input field and then press Enter. The date picker should close and the date combo box will show a date 100 years in the past instead of the current date. By using a 4-digit year this problem is avoided.

Edited by Ingo Klöcker

Merge request reports