It’s quite nice that this control is available to use in my own pages/web parts, but there are issues:
- As Sven De Bont noticed, it ignores regional settings for the SPWeb it is within. Set the Locale in code yourself based on the current SPContext.
- If it’s left blank, it still returns a selected date – today! You have to check the DateTimeControl.isDateEmpty property first, and if it is false then you can use the DateTimeControl.SelectedDate property.
- It has it’s own validation, and doesn’t play nicely with standard ASP.NET validators – but can be made to do so.
Here we have in microcosm my problems with Microsoft and date/times – an assumption of the local region, and date time controls that would never be empty, right? I had exactly these same problems when writing an Outlook 2003 to SharePoint 2007 integration too. Makes me a bit annoyed! Especially as we have nullable types! Quit screwing around with DateTimes being structs, make them objects and just return me a bloody null if nothing has been selected!