Returns the week of the year that includes the date in the specified DateTime.
- time
- The DateTime to read.
- rule
- One of the System.Globalization.CalendarWeekRule values that defines a calendar week.
- firstDayOfWeek
- One of the DayOfWeek values that represents the first day of the week.
A positive integer that represents the week of the year that includes the date in the time parameter.
This method can be used to determine the number of weeks in the year by setting the time parameter to the last day of the year.
The CultureInfo.DateTimeFormat property contains culture-specific values that can be used for the rule and firstDayOfWeek parameters.
The DateTimeFormatInfo.FirstDayOfWeek property of CultureInfo.DateTimeFormat contains the default DayOfWeek value that represents the first day of the week for a specific culture, using the calendar specified in the DateTimeFormatInfo.Calendar property of CultureInfo.DateTimeFormat.
The DateTimeFormatInfo.CalendarWeekRule property of CultureInfo.DateTimeFormat contains the default System.Globalization.CalendarWeekRule value that defines a calendar week for a specific culture, using the calendar specified in the DateTimeFormatInfo.Calendar property of CultureInfo.DateTimeFormat.
For example, in System.Globalization.GregorianCalendar, the Calendar.GetWeekOfYear(DateTime, CalendarWeekRule, DayOfWeek) method for January 1 returns 1.