System.Globalization.JapaneseCalendar.GetWeekOfYear Method

Returns the week of the year that includes the date in the specified DateTime.

Syntax

[System.Runtime.InteropServices.ComVisible(false)]
public override int GetWeekOfYear (DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek)

Parameters

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.

Returns

A 1-based integer that represents the week of the year that includes the date in the time parameter.

Remarks

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.

Requirements

Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0