RadDatePicker issue with Tuesday when set to April 2013

2 posts, 0 answers
  1. Fabien Masson
    Fabien Masson avatar
    11 posts
    Member since:
    Jul 2009

    Posted 11 Apr 2013 Link to this post

    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>

  2. Kostadin
    Admin
    Kostadin avatar
    1711 posts

    Posted 17 Apr 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top