// We might want to add more tests here... public void NonMondayFirstDayOfWeek(int minDaysInFirstWeek, IsoDayOfWeek firstDayOfWeek, int weekYear, int week, IsoDayOfWeek dayOfWeek, int expectedYear, int expectedMonth, int expectedDay) { var rule = WeekYearRules.ForMinDaysInFirstWeek(minDaysInFirstWeek, firstDayOfWeek); var actual = rule.GetLocalDate(weekYear, week, dayOfWeek); var expected = new LocalDate(expectedYear, expectedMonth, expectedDay); Assert.AreEqual(expected, actual); Assert.AreEqual(weekYear, rule.GetWeekYear(actual)); Assert.AreEqual(week, rule.GetWeekOfWeekYear(actual)); }
public void RoundtripLastDay_Iso1() { // In the Gregorian calendar with a minimum of 1 day in the first // week, Friday December 31st 9999 is in week year 10000. We should be able to // round-trip. var rule = WeekYearRules.ForMinDaysInFirstWeek(1); var date = new LocalDate(9999, 12, 31); Assert.AreEqual(date, rule.GetLocalDate( rule.GetWeekYear(date), rule.GetWeekOfWeekYear(date), date.IsoDayOfWeek)); }
public void RoundtripFirstDay_Iso7() { // In the Gregorian calendar with a minimum of 7 days in the first // week, Tuesday January 1st -9998 is in week year -9999. We should be able to // round-trip. var rule = WeekYearRules.ForMinDaysInFirstWeek(7); var date = new LocalDate(-9998, 1, 1); Assert.AreEqual(date, rule.GetLocalDate( rule.GetWeekYear(date), rule.GetWeekOfWeekYear(date), date.IsoDayOfWeek)); }
public void Gregorian(int year, IsoDayOfWeek firstDayOfYear, int maxMinDaysInFirstWeekForSameWeekYear) { var startOfCalendarYear = new LocalDate(year, 1, 1); Assert.AreEqual(firstDayOfYear, startOfCalendarYear.IsoDayOfWeek); // Rules which put the first day of the calendar year into the same week year for (int i = 1; i <= maxMinDaysInFirstWeekForSameWeekYear; i++) { var rule = WeekYearRules.ForMinDaysInFirstWeek(i); Assert.AreEqual(year, rule.GetWeekYear(startOfCalendarYear)); Assert.AreEqual(1, rule.GetWeekOfWeekYear(startOfCalendarYear)); } // Rules which put the first day of the calendar year into the previous week year for (int i = maxMinDaysInFirstWeekForSameWeekYear + 1; i <= 7; i++) { var rule = WeekYearRules.ForMinDaysInFirstWeek(i); Assert.AreEqual(year - 1, rule.GetWeekYear(startOfCalendarYear)); Assert.AreEqual(rule.GetWeeksInWeekYear(year - 1), rule.GetWeekOfWeekYear(startOfCalendarYear)); } }