Microsoft's DateTimePicker
common control shows ShortDate's according to the configured Locale settings. The customer's computer is configured with a 2-digit year ShortDateFormat (d/M/yy
), so the DateTimePicker shows 2-digit years:
When the user puts focus in the year block of the datetime picker, Microsoft points out the issue, and shows the full 4-digit year:
But then the user, wanting to enter 1929
as a year, types a 2-digit year:
And then when they tab out they're confused when Windows interprets their 2-digit years as being between 1930
and 2029
, and it is assumed to be 2029:
The customer has a global corporate policy in place which dictates that Windows regional settings be configured for 2-digit years.
So as a workaround i need to force every DateTimePicker
control to use a custom date-format, using the handy DateTime_SetFormat
macro:
DateTime_SetFormat(hwnd_DateOfEventPicker, "d/M/yyyy");
This helps, so that now the DateTimePicker
now always shows a 4-digit year:
The problem is that the user can still type in an "invalid" 2-digit year:
Which Windows is still intpreting, according to the rules, as 2029:
i need the date-time picker to reject 2-digit years.
If this can't work, then i'm going to be forced to replace every DateTimePicker with 3 edit boxes:
22 6 29
Where i can color invalid numbers red, and point out the invalid data entry by the user.
How can i prevent the DateTimePicker from accept y2k bugs?