Class WeekYearRules
Factory methods to construct weekyear rules supported by Noda Time.
Since 1.4.x
Availability net45, netstandard1.3
Inheritance
System.Object
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace:System.Dynamic.ExpandoObject
Assembly:NodaTime.dll
Syntax
public static class WeekYearRules
Properties
Iso
Returns an IWeekYearRule consistent with ISO8601.
Since 1.4.x
Availability net45, netstandard1.3
Declaration
public static IWeekYearRule Iso { get; }
Property Value
Type  Description 

IWeekYearRule  A IWeekYearRule consistent with ISO8601. (The value returned is never null.) 
Remarks
In the standard ISO8601 week algorithm, the first week of the year is that in which at least 4 days are in the year. As a result of this definition, day 1 of the first week may be in the previous year. In ISO8601, weeks always begin on a Monday, so this rule is equivalent to the first Thursday being in the first MondaytoSunday week of the year.
For example, January 1st 2011 was a Saturday, so only two days of that week (Saturday and Sunday) were in 2011. Therefore January 1st is part of week 52 of weekyear 2010. Conversely, December 31st 2012 is a Monday, so is part of week 1 of weekyear 2013.
Methods
ForMinDaysInFirstWeek(Int32)
Creates a week year rule where the boundary between one weekyear and the next
is parameterized in terms of how many days of the first week of the week
year have to be in the new calendar year. In rules created by this method,
weeks are always deemed to begin on an Monday.
Since 1.4.x
Availability net45, netstandard1.3
Declaration
public static IWeekYearRule ForMinDaysInFirstWeek(int minDaysInFirstWeek)
Parameters
Type  Name  Description 

System.Int32  minDaysInFirstWeek  The minimum number of days in the first MondaytoSunday week which have to be in the new calendar year for that week to count as being in that weekyear. Must be in the range 1 to 7 inclusive. 
Returns
Type  Description 

IWeekYearRule  A NodaTime.Calendars.SimpleWeekYearRule with the specified minimum number of days in the first week. (The value returned is never null.) 
Remarks
minDaysInFirstWeek
determines when the first week of the weekyear starts.
For any given calendar year X, consider the MondaytoSunday week that includes the first day of the
calendar year. Usually, some days of that week are in calendar year X, and some are in calendar year
X1. If minDaysInFirstWeek
or more of the days are in year X, then the week is
deemed to be the first week of weekyear X. Otherwise, the week is deemed to be the last week of
weekyear X1, and the first week of weekyear X starts on the following Monday.
ForMinDaysInFirstWeek(Int32, IsoDayOfWeek)
Creates a week year rule where the boundary between one weekyear and the next
is parameterized in terms of how many days of the first week of the week
year have to be in the new calendar year, and also by which day is deemed
to be the first day of the week.
Since 1.4.x
Availability net45, netstandard1.3
Declaration
public static IWeekYearRule ForMinDaysInFirstWeek(int minDaysInFirstWeek, IsoDayOfWeek firstDayOfWeek)
Parameters
Type  Name  Description 

System.Int32  minDaysInFirstWeek  The minimum number of days in the first week (starting on
firstDayOfWeek ) which have to be in the new calendar year for that week
to count as being in that weekyear. Must be in the range 1 to 7 inclusive.

IsoDayOfWeek  firstDayOfWeek  The first day of the week. 
Returns
Type  Description 

IWeekYearRule  A NodaTime.Calendars.SimpleWeekYearRule with the specified minimum number of days in the first week and first day of the week. (The value returned is never null.) 
Remarks
minDaysInFirstWeek
determines when the first week of the weekyear starts.
For any given calendar year X, consider the week that includes the first day of the
calendar year. Usually, some days of that week are in calendar year X, and some are in calendar year
X1. If minDaysInFirstWeek
or more of the days are in year X, then the week is
deemed to be the first week of weekyear X. Otherwise, the week is deemed to be the last week of
weekyear X1, and the first week of weekyear X starts on the following firstDayOfWeek
.
FromCalendarWeekRule(CalendarWeekRule, DayOfWeek)
Creates a rule which behaves the same way as the BCL
System.Globalization.Calendar.GetWeekOfYear(System.DateTime,System.Globalization.CalendarWeekRule,System.DayOfWeek)
method.
Since 1.4.x
Availability net45, netstandard1.3
Declaration
public static IWeekYearRule FromCalendarWeekRule(CalendarWeekRule calendarWeekRule, DayOfWeek firstDayOfWeek)
Parameters
Type  Name  Description 

System.Globalization.CalendarWeekRule  calendarWeekRule  The BCL rule to emulate. 
System.DayOfWeek  firstDayOfWeek  The first day of the week to use in the rule. 
Returns
Type  Description 

IWeekYearRule  A rule which behaves the same way as the BCL System.Globalization.Calendar.GetWeekOfYear(System.DateTime,System.Globalization.CalendarWeekRule,System.DayOfWeek) method. (The value returned is never null.) 
Remarks
The BCL week year rules are subtly different to the ISO rules.
In particular, the last few days of the calendar year are always part of the same
weekyear in the BCL rules, whereas in the ISO rules they can fall into the next
weekyear. (The first few days of the calendar year can be part of the previous
weekyear in both kinds of rule.) This means that in the BCL rules, some weeks
are incomplete, whereas ISO weeks are always exactly 7 days long.