Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class NodaTime.​Calendars.​WeekYearRules
Assembly: NodaTime
Inheritance: object → WeekYearRules
Factory methods to construct week-year rules supported by Noda Time.
Properties
public static
IWeekYearRule
Iso
Returns an <see cref="T:NodaTime.Calendars.IWeekYearRule" /> consistent with ISO-8601.
Remarks <para>
In the standard ISO-8601 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 ISO-8601,
weeks always begin on a Monday, so this rule is equivalent to the first Thursday
being in the first Monday-to-Sunday week of the year.
</para> <para>
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 week-year 2010. Conversely, December 31st 2012 is a Monday,
so is part of week 1 of week-year 2013.
</para>
Methods
public static
IWeekYearRule
ForMinDaysInFirstWeek​(int minDaysInFirstWeek)
Creates a week year rule where the boundary between one week-year 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.
Returns A <see cref="T:NodaTime.Calendars.SimpleWeekYearRule" /> with the specified minimum number of days in the first
week.
minDaysInFirstWeek
The minimum number of days in the first Monday-to-Sunday week
which have to be in the new calendar year for that week to count as being in that week-year.
Must be in the range 1 to 7 inclusive.
Remarks
<paramref name="minDaysInFirstWeek" /> determines when the first week of the week-year starts.
For any given calendar year X, consider the Monday-to-Sunday 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
X-1. If <paramref name="minDaysInFirstWeek" /> or more of the days are in year X, then the week is
deemed to be the first week of week-year X. Otherwise, the week is deemed to be the last week of
week-year X-1, and the first week of week-year X starts on the following Monday.
public static
IWeekYearRule
ForMinDaysInFirstWeek​(int minDaysInFirstWeek,
IsoDayOfWeek firstDayOfWeek)
Creates a week year rule where the boundary between one week-year 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.
Returns A <see cref="T:NodaTime.Calendars.SimpleWeekYearRule" /> with the specified minimum number of days in the first
week and first day of the week.
minDaysInFirstWeek
The minimum number of days in the first week (starting on
<paramref name="firstDayOfWeek" /> ) which have to be in the new calendar year for that week
to count as being in that week-year. Must be in the range 1 to 7 inclusive.
firstDayOfWeek
The first day of the week.
Remarks
<paramref name="minDaysInFirstWeek" /> determines when the first week of the week-year 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
X-1. If <paramref name="minDaysInFirstWeek" /> or more of the days are in year X, then the week is
deemed to be the first week of week-year X. Otherwise, the week is deemed to be the last week of
week-year X-1, and the first week of week-year X starts on the following <paramref name="firstDayOfWeek" /> .
public static
IWeekYearRule
FromCalendarWeekRule​(System.​Globalization.​CalendarWeekRule calendarWeekRule,
System.​DayOfWeek firstDayOfWeek)
Creates a rule which behaves the same way as the BCL
<see cref="M:System.Globalization.Calendar.GetWeekOfYear(System.DateTime,System.Globalization.CalendarWeekRule,System.DayOfWeek)" />
method.
Returns A rule which behaves the same way as the BCL
<see cref="M:System.Globalization.Calendar.GetWeekOfYear(System.DateTime,System.Globalization.CalendarWeekRule,System.DayOfWeek)" />
method.
calendarWeekRule
The BCL rule to emulate.
firstDayOfWeek
The first day of the week to use in the rule.
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
week-year in the BCL rules, whereas in the ISO rules they can fall into the next
week-year. (The first few days of the calendar year can be part of the previous
week-year 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.
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object