Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DateTimePicker: how to set MinDate before 1753

I am building a genealogical tree app, and I need to reach past this date. I would prefer DateTimePicker rather than TextBox + text-date conversion.

Is there anyway to circumvent this limitation?

like image 434
Xavier Peña Avatar asked Feb 13 '16 17:02

Xavier Peña


1 Answers

Unfortunately, the DateTimePicker control does not support dates before January 1, 1753. This is ultimately due to limitations in the Date and Time Picker and Month Calendar controls in the ComCtl32 Common Controls library. Those controls do not support dates before 1753 because that is the dividing line between the Gregorian and Julian calendars. Since the controls are based on the Gregorian calendar, they do not calculate dates consistent with the Julian calendar.

The reason this affects .NET code is because the DateTimePicker class is a wrapper around the lower-level comctl32 controls. The relevant code is here.

Sadly, this limitation is also carried over into the Mono implementation of the control, so even if you use DateTimePicker through Mono on Linux or Mac, it still will not allow dates before then, despite the lack of a comctl32.dll in the operating system.

It looks like Telerik has their own DateTimePicker control. That might be worthy of investigation. After a quick scan of the docs, though, I do not see what its limits are, if any.

like image 67
izrik Avatar answered Oct 01 '22 18:10

izrik