Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,19 @@ public static void JapaneseTest()
DateTime dTest = jCal.ToDateTime(1, 1, 8, 0, 0, 0, 0, 4);
Assert.Equal(dTest, new DateTime(1989, 1, 8));
}

[Theory]
[InlineData(@"Thg 1", 1)]
[InlineData(@"Thg 2", 2)]
[InlineData(@"Thg 10", 10)]
[InlineData(@"Thg 11", 11)]
[InlineData(@"Thg 12", 12)]
//[InlineData(@"Thg 13", 13)] Needs supported calendar with 13 months
public static void VietnameseTest_MatchAbbreviatedMonthName_ContinuesSearchAfterMatch(string monthAbberavition, int expectedMonthNum)
{
var dtfi = new System.Globalization.CultureInfo("vi-VN").DateTimeFormat;
dtfi.AbbreviatedMonthNames = new string[] { "Thg 1", "Thg 2", "Thg 3", "Thg 4", "Thg 5", "Thg 6", "Thg 7", "Thg 8", "Thg 9", "Thg 10", "Thg 11", "Thg 12", "Thg 13" }; // 13 months
Assert.Equal(expectedMonthNum, DateTime.ParseExact(monthAbberavition, "MMM", dtfi).Month);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3352,9 +3352,9 @@ private static bool MatchAbbreviatedMonthName(ref __DTString str, DateTimeFormat
{
// Scan the month names (note that some calendars has 13 months) and find
// the matching month name which has the max string length.
// We need to do this because some cultures (e.g. "cs-CZ") which have
// abbreviated month names with the same prefix.
int monthsInYear = (dtfi.GetMonthName(13).Length == 0 ? 12 : 13);
// We need to do this because some cultures which have abbreviated
// month names with the same prefix (e.g. "vi-VN" culture has those conflicts "Thg1", "Thg10", "Thg11")
int monthsInYear = (dtfi.GetAbbreviatedMonthName(13).Length == 0 ? 12 : 13);
for (int i = 1; i <= monthsInYear; i++)
{
string searchStr = dtfi.GetAbbreviatedMonthName(i);
Expand Down