To whom it may concern,we are having some issues with the year end/year beginning and the calendar weeks during those weeks. In the 1st calendar week of the year 2015 (Days 29, 30, 31 of December 2014) the calendar week is numbered 53.However in the 53st week of the year 2015 (days 1, 2, 3 of January 2016) the calendar week is numbered 53, whereas the logic would dictate this week to be numbered 1.GetWeekNumberForDate is the function that seems to differ and vary, depending on the calendar year. Whereas the calendar control UltraDayView has the same logic display consistently. Could you please explain your ideas behind this? We are having rather large issues with each year end/ year beginning using your software and we are open to solutions, that will be consistent for the future.Best wishes,
A. Kasar
Hi Kasar,
I have reproduced this behavior in certain circumstances, and I believe it is correct. The result given by GetWeekNumberForDate depends on the CalendarInfo's FirstDayOfWeek and WeekRule properties. I have provided a sample that evaluates each combination, then prints the results if the week number is different. I have attached the sample to this post.
1/1/15 is week 1 and 1/1/16 is week 53 in two cases:
1) FirstDayOfWeek is Monday and WeekRule is FirstFourDayWeek. This is accurate because January 1st falls in the first four day week of 2015, but the first four day week of 2016 starts with January 4th.
2) FirstDayOfWeek is Thursday and WeekRule is FirstFullWeek. This is accurate because January 1st is a Thursday in 2015 and a Friday in 2016.
What are your settings for FirstDayOfWeek and WeekRule? WeekRule defaults to FirstDay, but FirstDayOfWeek's has a Default value that allows the control to defer to your system settings to determine the first day of the week. Are you able to modify these properties to get the behavior you need? Please refer to my sample to see the results of different rule combinations.
I am using the .NET Framework 4.0 and the Infragistics-versions Infragistics Windows Forms 2014.2.2010 & Infragistics WPF 2014.2.2024
I have used your example and the incorrect result keeps showing up.
Infragistics.Win.UltraWinSchedule.UltraCalendarInfo ultraCalendarInfo1 = new Infragistics.Win.UltraWinSchedule.UltraCalendarInfo();int wk1 = ultraCalendarInfo1.GetWeekNumberForDate(new DateTime(2015, 1, 1)); ==> 1int wk2 = ultraCalendarInfo1.GetWeekNumberForDate(new DateTime(2016, 1, 1)); ==> 53
I used the following code, and both weeks came out to be numbered week 1:
int wk1 = ultraCalendarInfo1.GetWeekNumberForDate(new DateTime(2015, 1, 1));int wk2 = ultraCalendarInfo1.GetWeekNumberForDate(new DateTime(2016, 1, 1));
I am using Infragistics 14.2, with the October service release.
Does your code look similar to mine? Are you nonetheless seeing different results?Are you using the same version and service release as me?
Please let me know which version and SR you are using and, if possible, provide some code that I can test. My testing seems to indicate that this method is behaving consistently, so I would like to be able to take a closer look at your application.