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

Week No for Datepicker shows incorrect number (ISO8601)

3 Answers 296 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 22 Jul 2015, 10:07 AM

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>


 

3 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 23 Jul 2015, 08:15 AM
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
0
Jon
Top achievements
Rank 1
answered on 23 Jul 2015, 08:24 AM

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

 

0
Accepted
Vasil
Telerik team
answered on 23 Jul 2015, 10:39 AM
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
Tags
Calendar
Asked by
Jon
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Jon
Top achievements
Rank 1
Share this question
or