title: How to manually configure NodaTime IWeekYearRule correctly?
body: <p>I am wrapping NodaTime for use in our software, and to be future-proof I thought I'd set up IWeekYearRule according to Bcl DateTimeFormat, like this:</p>
  
  <pre><code>var culture = CultureInfo.CurrentCulture;
  var weekRule = WeekYearRules.FromCalendarWeekRule(
      culture.DateTimeFormat.CalendarWeekRule,
      culture.DateTimeFormat.FirstDayOfWeek);
  </code></pre>
  
  <p>Here in Norway we're following the following settings:</p>
  
  <pre><code>CalendarWeekRule.FirstFourDayWeek
  DayOfWeek.Monday
  </code></pre>
  
  <p>However, much to my surprise, when I checked the week number of the following two dates, <a href="https://www.timeanddate.no/kalender/?year=2018&amp;country=18" rel="nofollow noreferrer">kalender.no</a> disagrees:</p>
  
  <pre><code>2018-12-31: week 53 of 2018 (kalender.no says week 1 [implied: of 2019])
  2019-01-01: week 1 of 2019  (kalender.no agrees here)
  </code></pre>
  
  <p>However, if I use WeekYearRules.Iso, they both return "week 1 of 2019", which is the correct one.</p>
  
  <p>I have a bunch of questions but let's focus on the most immediate one:</p>
  
  <p>How can I write the code to "future-proof" this part of the library, so that when we start rolling out the software into more parts of the world, it will calculate week numbers correctly out of the box, according to the local culture?</p>
  
  <p>Or is this just not possible, because the culture information doesn't contain this?</p>
  
  <p>Here's a <a href="http://linqpad" rel="nofollow noreferrer">LINQPad</a> example that demonstrates NodaTime behavior (sorry for not including a [mcve] to begin with):</p>
  
  <pre><code>void Main()
  {
      "-------------- ISO --------------".Dump();
      Test(WeekYearRules.Iso);
  
      "-------------- BCL --------------".Dump();
      Test(WeekYearRules.FromCalendarWeekRule(CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday));
  }
  
  public static void Test(IWeekYearRule rule)
  {
      var date = new LocalDate(2018, 12, 31);
      $"{date}, {rule.GetWeekOfWeekYear(date)} in {rule.GetWeekYear(date)}".Dump();
  
      date = new LocalDate(2019, 1, 1);
      $"{date}, {rule.GetWeekOfWeekYear(date)} in {rule.GetWeekYear(date)}".Dump();
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>-------------- ISO --------------
  mandag 31. desember 2018, 1 in 2019
  tirsdag 1. januar 2019, 1 in 2019
  -------------- BCL --------------
  mandag 31. desember 2018, 53 in 2018
  tirsdag 1. januar 2019, 1 in 2019
  </code></pre>
  
  <p><em>(and just to be clear, the ISO output is the correct one for Norway)</em></p>
  
  <p>This is NodaTime 2.4.4, Windows 10, .NET 4.7.2.</p>
  
  <hr>
  
  <p>And here's a LINQPad example without using NodaTime:</p>
  
  <pre><code>void Main()
  {
      var culture = CultureInfo.GetCultureInfo("nb-NO");
  
      var calendarWeekRule = culture.DateTimeFormat.CalendarWeekRule.Dump();
      var firstDayOfWeek = culture.DateTimeFormat.FirstDayOfWeek.Dump();
  
      var date = new DateTime(2018, 12, 31);
      $"{date.DayOfWeek} {date}, week {culture.Calendar.GetWeekOfYear(date, calendarWeekRule, firstDayOfWeek)}".Dump();
  
      date = new DateTime(2019, 1, 1);
      $"{date.DayOfWeek} {date}, week {culture.Calendar.GetWeekOfYear(date, calendarWeekRule, firstDayOfWeek)}".Dump();
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>FirstFourDayWeek
  Monday
  Monday 31.12.2018 00.00.00, week 53
  Tuesday 01.01.2019 00.00.00, week 1
  </code></pre>
  
  <p>The Monday there is in the same week as week 1 of 2019, and is counted as week 1 in 2019 here in Norway, so the first of the two dates should really have been:</p>
  
  <pre><code>Monday 31.12.2018 00.00.00, week 1
  </code></pre>