if (month < 1 || month > 13) throw new ArgumentOutOfRangeException();
return monthNames[month-1];
}
+
+ internal string GetMonthGenitiveName (int month)
+ {
+ return genitiveMonthNames [month - 1];
+ }
public string[] AbbreviatedDayNames
{
}
}
- public string[] DayNames
- {
- get { return (string[]) RawDayNames.Clone (); }
- set { RawDayNames = value; }
- }
-
- internal string[] RawDayNames
- {
- get
- {
- return dayNames;
+ public string[] DayNames {
+ get {
+ return (string[]) dayNames.Clone ();
}
set {
CheckDaysValue (value);
}
}
- public string[] MonthNames
- {
- get { return (string[]) RawMonthNames.Clone (); }
- set { RawMonthNames = value; }
+ internal string[] RawDayNames {
+ get {
+ return dayNames;
+ }
}
- internal string[] RawMonthNames
- {
- get
- {
- return monthNames;
+ public string[] MonthNames {
+ get {
+ return (string[]) monthNames.Clone ();
}
set {
CheckMonthsValue (value);
monthNames = (string[]) value.Clone();
}
}
+
+ internal string[] RawMonthNames {
+ get {
+ return monthNames;
+ }
+ }
[ComVisible (false)]
public string[] AbbreviatedMonthGenitiveNames {
genitiveMonthNames = value;
}
}
-
- [MonoLimitation ("Oly default calendar is supported")]
+
+ [MonoLimitation ("Only default calendar is supported")]
[ComVisible (false)]
public string NativeCalendarName {
get {
dfi = inv;
int i = 0;
+ bool saw_day_specifier = false;
while (i < format.Length) {
int tokLen;
else
result.Append (dfi.GetDayName (dfi.Calendar.GetDayOfWeek (dt)));
+ saw_day_specifier = true;
break;
case 'M':
// Month.m(m?) = month # (with leading 0 if two mm)
DateTimeUtils.ZeroPad (result, month, tokLen);
else if (tokLen == 3)
result.Append (dfi.GetAbbreviatedMonthName (month));
- else
- result.Append (dfi.GetMonthName (month));
+ else {
+ // NOTE: .NET ignores quoted 'd' and reads it as day specifier but I think
+ // that's wrong
+ result.Append (saw_day_specifier ? dfi.GetMonthGenitiveName (month) : dfi.GetMonthName (month));
+ }
break;
case 'y':
Assert.AreEqual ("0999", t3.ToString ("yyyy"), "#B33");
}
+ [Test]
+ public void TestToStringGenitive ()
+ {
+ DateTime dt = new DateTime (2010, 1, 2, 3, 4, 5);
+ var dtf = new CultureInfo ("cs-cz").DateTimeFormat;
+
+ Assert.AreEqual ("2 ledna", dt.ToString ("d MMMM", dtf), "#A1");
+ Assert.AreEqual ("2. ledna", dt.ToString ("d. MMMM", dtf), "#A2");
+ Assert.AreEqual ("leden", dt.ToString ("MMMM", dtf), "#A4");
+ Assert.AreEqual ("leden", dt.ToString ("MMMMMMM", dtf), "#A5");
+ }
+
[Test]
public void ParseExact_Format_Empty ()
{