This is a migrated thread and some comments may be shown as answers.

RadDatePicker issue with Tuesday when set to April 2013

1 Answer 38 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Fabien
Top achievements
Rank 1
Fabien asked on 12 Apr 2013, 12:22 AM
Dear Telerik Team,

  I experienced a very strange bug when using RadDatePicker with following settings : Culture="fr-FR" & DateInput-DateFormat="ddd dd MMM yyyy".

  Whatever Tuesday I try to select in april 2013, it automatically select the right day and year but set Month to March.

  Best Regards,
Fabien.

It can be reproduced with IE9 and .Net Framework 3.5 and Telerik releases : 2011.3.1115.35, 2013.1.403.35

here is extract of declaration in .aspx file.

            <telerik:RadDatePicker ID="RadDatePickerMaxDate" runat="server"
                Culture="fr-FR"
                DateInput-DateFormat="ddd dd MMM yyyy"
                AutoPostBackControl="Calendar" 
                AutoPostBack="True"
                >
            </telerik:RadDatePicker>

when used as following, no problem at all :
                <telerik:RadDatePicker ID="RadDatePickerMaxDate" runat="server"
                AutoPostBackControl="Calendar" 
                AutoPostBack="True"
                >
                </telerik:RadDatePicker>

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 17 Apr 2013, 06:46 AM
Hi Fabien,

The reason for that behavior is the way our calendar reads the date. In your case the day abbreviation is "mar" for Tuesday and when the calendar check for the chosen date it will try to parse the day "mar" as March. I could provide you with a workaround which seems to work with the current culture, but I could not guarantee whether this workaround will work in any other case. Check out the following code snippet:
<script type="text/javascript">
 
    with (Telerik.Web.UI.DateParsing)
    {
        Telerik.Web.UI.DateParsing.DateTimeLexer.prototype.CreateTokens = function (inputs)
        {
            var result = [];
            for (var i = 0; i < inputs.length; i++)
            {
                var tokenClasses = [NumberToken, WeekDayNameToken, MonthNameToken, TimeSeparatorToken, AMPMToken];
                for (var j = 0; j < tokenClasses.length; j++)
                {
                    var tokenClass = tokenClasses[j];
                    var token = tokenClass.Create(inputs[i], this.DateTimeFormatInfo);
                    if (token != null)
                    {
                        result.push(token);
                        break;
                    }
                }
            }
            return result;
        }
    }
 
</script>

The differences is that the places of WeekDayNameToken and MonthNameToken in tokenClasses collection are switched .

Greetings,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Calendar
Asked by
Fabien
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or