Freigeben über


CalendarWeekRule Enumeration

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Defines different rules for determining the first week of the year.

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
<ComVisibleAttribute(True)> _
Public Enumeration CalendarWeekRule
[ComVisibleAttribute(true)]
public enum CalendarWeekRule

Members

Member name Description
Supported by Silverlight for Windows PhoneSupported by Xbox 360 FirstDay Indicates that the first week of the year starts on the first day of the year and ends before the following designated first day of the week. The value is 0.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 FirstFullWeek Indicates that the first week of the year begins on the first occurrence of the designated first day of the week on or after the first day of the year. The value is 1.
Supported by Silverlight for Windows PhoneSupported by Xbox 360 FirstFourDayWeek Indicates that the first week of the year is the first week with four or more days before the designated first day of the week. The value is 2.

Remarks

The CalendarWeekRule enumeration provides three different rules to define the first week of the year. This in turn determines which week of the year a particular date occurs in or which week of the year a particular week is. The default calendar week rule for a particular culture is defined by its DateTimeFormatInfo.CalendarWeekRule property, but any CalendarWeekRule value can be specified in the call to the Calendar.GetWeekOfYear method.

Calendar week rules depend on the System.DayOfWeek value that indicates the first day of the week. The DateTimeFormatInfo.FirstDayOfWeek property provides the default value for a culture, but any DayOfWeek value can be specified as the first day of the week in the Calendar.GetWeekOfYear method.

The first week based on the CalendarWeekRule.FirstDay calendar week rule can have one to seven days. The first week based on the CalendarWeekRule.FirstFullWeek calendar week rule always has seven days. The first week based on the CalendarWeekRule.FirstFourDayWeek calendar week rule can have four to seven days.

For example, in the Gregorian calendar, suppose that the first day of the year (January 1) falls on a Tuesday and the designated first day of the week is Sunday. Selecting FirstFullWeek defines the first Sunday (January 6) as the beginning of the first week of the year. The first five days of the year are considered part of the last week of the previous year. In contrast, selecting FirstFourDayWeek defines the first day of the year (January 1) as the beginning of the first week of the year because there are more than four days from January 1 to the day before the following Sunday. Similarly, the FirstDay rule also defines the first day of the year (January 1) as the beginning of the first week of the year. The following table illustrates how each rule affects the date range of the last week of the previous year and the first week of the current year

Date

FirstDay

FirstFullWeek

FirstFourDayWeek

Dec 31 Mon

Last week of the previous year

Last week of the previous year

Last week of the previous year

Jan 1 Tue

Week 1

Last week of the previous year

Week 1

Jan 2 Wed

Week 1

Last week of the previous year

Week 1

Jan 3 Thu

Week 1

Last week of the previous year

Week 1

Jan 4 Fri

Week 1

Last week of the previous year

Week 1

Jan 5 Sat

Week 1

Last week of the previous year

Week 1

Jan 6 Sun

Week 2

Week 1

Week 2

Jan 7 Mon

Week 2

Week 1

Week 2

Jan 8 Tue

Week 2

Week 1

Week 2

Jan 9 Wed

Week 2

Week 1

Week 2

Jan 10 Thu

Week 2

Week 1

Week 2

Jan 11 Fri

Week 2

Week 1

Week 2

Jan 12 Sat

Week 2

Week 1

Week 2

Suppose the first day of the year (January 1) falls on a Friday and the designated first day of the week is Sunday. Selecting FirstFourDayWeek defines the first Sunday (January 3) as the beginning of the first week of the year because there are fewer than four days from January 1 to the day before the following Sunday. The folllowing table shows the date range of the first week of the year for a year that begins on a Friday when the first day of the week is a Sunday.

Date

FirstDay

FirstFullWeek

FirstFourDayWeek

Dec 31 Thu

Last week of the previous year

Last week of the previous year

Last week of the previous year

Jan 1 Fri

Week 1

Last week of the previous year

Last week of the previous year

Jan 2 Sat

Week 1

Last week of the previous year

Last week of the previous year

Jan 3 Sun

Week 2

Week 1

Week 1

Jan 4 Mon

Week 2

Week 1

Week 1

Jan 5 Tue

Week 2

Week 1

Week 1

Jan 6 Wed

Week 2

Week 1

Week 1

Jan 7 Thu

Week 2

Week 1

Week 1

Jan 8 Fri

Week 2

Week 1

Week 1

Jan 9 Sat

Week 2

Week 1

Week 1

Each CultureInfo object supports a set of calendars. The Calendar property returns the default calendar for the culture, and the OptionalCalendars property returns an array containing all the calendars supported by the culture. To change the calendar used by a CultureInfo object, the application should set the Calendar property of CultureInfo.DateTimeFormat to a new Calendar object that is a member of the OptionalCalendars array.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.