Week No for Datepicker shows incorrect number (ISO8601)

4 posts, 1 answers
  1. Jon
    Jon avatar
    53 posts
    Member since:
    Oct 2013

    Posted 22 Jul 2015 Link to this post

    I am using rad date picker and the dropdown calendar displays week numbers but they do not match ISO8601 standard. Eg. 2009 has 53 weeks according to the standard. How do I correct this.

    My markup is....

    <telerik:RadDatePicker ID="dp_ReportStartDate" runat="server" MinDate="2006-01-01" Width="100%" AutoPostBack="true">

    </telerik:RadDatePicker>


     
  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 23 Jul 2015 Link to this post

    Hello Jon,

    The calendar does not calculate the week number, it uses the DateTime object and get the week number from it. Based on System.Globalization.CalendarWeekRule.

    Seems that the Culture that you are currently using have different CalendarWeekRule. But you can override it. Check this forum thread about he very same subject.
    http://www.telerik.com/forums/week-numbers-is-wrong#1293405

    Regards,
    Vasil
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jon
    Jon avatar
    53 posts
    Member since:
    Oct 2013

    Posted 23 Jul 2015 in reply to Vasil Link to this post

    Vasil,

     Thanks... The link refers to a Rad Calendar control. I'm using a date-picker which I understand uses a calendar but what will be the script in this case.

    Regards

     

  5. Answer
    Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 23 Jul 2015 Link to this post

    Hi,

    You can access the calendar of your picker directly from the .Calendar property of the picker, and apply any settings to it.

    If you you multiple calendars in your page, I would suggest you to follow the Microsoft documentation and to override the InitializeCulture, providing your custom calendar.

    protected override void InitializeCulture()
    {
        System.Globalization.CultureInfo c = new System.Globalization.CultureInfo(Thread.CurrentThread.CurrentCulture.ToString());
        c.DateTimeFormat.CalendarWeekRule = System.Globalization.CalendarWeekRule.FirstFourDayWeek;
        Thread.CurrentThread.CurrentCulture = c;
     
        base.InitializeCulture();
    }

    This way it will automatically apply to all Calendars in your page, including the dynamically added (in places like Filter item of the grid), as well as the calendars you add using the code-behind and these in the RadPicker.

    Regards,
    Vasil
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top