With the Q3 2013 release of UI for Silverlight RadDateTimePicker provides new parsing logic which will allow the end users to enter dates in the input field directly without separators - the entered date will be parsed following the same rules as in a military format.
This feature can be enabled by setting AllowParsingWithoutSeparator property of the control to True:
<telerik:RadDateTimePicker x:Name="radDateTimePicker" AllowParsingWithoutSeparator="True" />
this.radDateTimePicker.AllowParsingWithoutSeparator = true;
The default value of AllowParsingWithoutSeparator is False.
Check below how the entered text is handled in both cases:
In the first case the text is parsed as a month and day while in the second case - as a year as no separators are entered.
The following table lists the rules applied when using parsing without separators:
|“1” or “12”||Sets the day in the month and year of the SelectedDate (if SelectedDate is null, the current month and current year are set). Here is how it looks with different formats:
|“120”||Depending on the format, it will try to parse it as a day and month in the year of the SelectedDate (if SelectedDate is null, current year is used).
The parser works from right to left, in the first case it tries to parse Month=20, as this returns false, it switches to the default parser and parses it as a year. In both the second and third case the parsed date is January 20, current year.
|“1205”||Again, depending on the format, it will try to parse it as a day and a month in the year of the SelectedDate (or current year if SelectedDate is null).
In the first case the parsed date is May 12, while in the second and third cases it is December 5.
|“12051”||False, until it fulfills the format’s length.|
|“120511”||it should be parsed according to the set format:
In the first case the entered string has not reached the format's length, that's why it returns False. Note that in the second case the parsed date is May 11, 2012, while in the third case it is - December 5, 2011.
|“Jan”||Sets the year and day of the SelectedDate and the month parsed.|
|“Jan21”||Sets the year of the SelectedDate and the day and month parsed.|
The DateTimePicker should match first the short abbreviations of the month names:
Jan, Feb, Mar, Apr, May, June, July, Aug, Sept, Oct, Nov, Dec.
And then the whole word of the month - in between an error will be displayed. The date which is going to be set once the month is recognized will be the first day of the month the currently selected year.
If the user enters digits inside the TextBox after the DatePart or in the TimePicker alone, they should be parsed as the hour part.
|“1” or “3”||Parses it as an hour.
|“14” or “34”||Again, tries to parse it as an hour. If it doesn’t fit for the hour part, for example is greater than 24, the first digit is used as an hour with added 0 in front and the second one as minutes.
|“144” or “344”||Parses it as an hour and minutes until reaches the set Time format.
Check out the RadDateTimePicker Configurator online demo to see AllowParsingWithoutSeparator in action.