What's a genitive month name anyway?

I’m not a linguistic expert, so I’ll probably get this a bit wrong, but basically a genitive month name is used when there’s a number next to the month name. This doesn’t happen in English, but I think of it sort of like instead of saying “1 April 2008”, using “1 of April 2008”, where the “of April” is the “genitive month name”.

For most cultures the “genitive month names” and the “month names” are identical, and in .Net 2.0 DateTimeFormatInfo the “genitive” forms are internally delay created from the month name. Unfortunately what this means is that you cannot reliably set the DateTimeFormatInfo.MonthNames property unless you also set the DateTimeFormatInfo.MonthGenitiveNames property.

The example code demonstrates this by changing the month names and not the genitive names, then changing those as well.

 MMMM dd format: April 01   
System.String[]   
w/o Genitive:   April 01   
with Genitive:  prilAy 01   

using System;   
using System.Globalization;   
public class Test   

{
     static void Main()
     {
         // Pick a date and show what it looks like normally
         DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
         DateTime dt = new DateTime(2008,4,1,12,30,15);
         Console.WriteLine("MMMM dd format: " + dt.ToString("M", dtfi));

         // Force the delay create to happen in some versions of .Net
         Console.WriteLine(dtfi.MonthGenitiveNames);

         // Try to make the month names pig-latn (hey, its an example)
         dtfi.MonthNames = new string[]
             { "anuaryJay", "ebruaryJay", "archMay", "prilAy", "aMay", "uneJay",
               "ulyJay", "ugustJay", "eptemberSay", "ctoberOay", "ovemberNay", "ecemberDay", "" };
         // It doesn't work quite as expected
         Console.WriteLine("w/o Genitive:   " + dt.ToString("M", dtfi));

         // We also have to set the genitive names
         dtfi.MonthGenitiveNames = dtfi.MonthNames;
         Console.WriteLine("with Genitive:  " + dt.ToString("M", dtfi));
     }
}