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 = RegularWeekYearRule.ForMinDaysInFirstWeek(7); var date = new LocalDate(-9998, 1, 1); Assert.AreEqual(date, rule.GetLocalDate( rule.GetWeekYear(date), rule.GetWeekOfWeekYear(date), date.IsoDayOfWeek)); }
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 = RegularWeekYearRule.ForMinDaysInFirstWeek(1); var date = new LocalDate(9999, 12, 31); 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 = RegularWeekYearRule.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 = RegularWeekYearRule.ForMinDaysInFirstWeek(i); Assert.AreEqual(year - 1, rule.GetWeekYear(startOfCalendarYear)); Assert.AreEqual(rule.GetWeeksInWeekYear(year - 1), rule.GetWeekOfWeekYear(startOfCalendarYear)); } }