Imported Upstream version 6.0.0.172

Former-commit-id: f3cc9b82f3e5bd8f0fd3ebc098f789556b44e9cd
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-04-12 14:10:50 +00:00
parent 8016999e4d
commit 64ac736ec5
32155 changed files with 3981439 additions and 75368 deletions

View File

@@ -825,6 +825,17 @@ public class CalendarTest {
}
}
[Test]
public void TestJapaneseCalendarDateParsing ()
{
CultureInfo ciJapanese = new CultureInfo ("ja-JP") { DateTimeFormat = { Calendar = new JapaneseCalendar () } };
DateTime dt = new DateTime (1970, 1, 1);
string eraName = dt.ToString ("gg", ciJapanese);
Assert.AreEqual (new DateTime (1995, 1, 1), DateTime.Parse (eraName + " 70/1/1 0:00:00", ciJapanese));
}
// TODO: more tests :-)
} // class CalendarTest

View File

@@ -283,6 +283,7 @@ namespace MonoTests.System.Globalization
}
[Test] // bug #81930
[Category ("NotWasm")]
public void IsReadOnly ()
{
CultureInfo ci;
@@ -504,6 +505,7 @@ namespace MonoTests.System.Globalization
}
[Test]
[Category ("NotWasm")]
public void UseUserOverride_CurrentCulture ()
{
CultureInfo ci = CultureInfo.CurrentCulture;
@@ -515,6 +517,7 @@ namespace MonoTests.System.Globalization
}
[Test]
[Category ("NotWasm")]
public void UseUserOverride_CurrentUICulture ()
{
CultureInfo ci = CultureInfo.CurrentCulture;
@@ -757,6 +760,7 @@ namespace MonoTests.System.Globalization
}
[Test]
[Category ("MultiThreaded")]
public void FlowCultureInfoFromParentThreadSinceNet46 ()
{
if (SynchronizationContext.Current != null) {

View File

@@ -142,6 +142,28 @@ namespace MonoTests.System.Globalization
DateTime dt2 = DateTime.Parse (s, ci);
Assert.AreEqual (dt.Month, dt2.Month);
}
[Test]
public void TestFirstYearOfJapaneseEra ()
{
DateTimeFormatInfo jpnFormat = new CultureInfo ("ja-JP").DateTimeFormat;
jpnFormat.Calendar = new JapaneseCalendar ();
string pattern = "gg yyyy'\u5E74' MM'\u6708' dd'\u65E5'"; // "gg yyyy'年' MM'月' dd'日'"
DateTime dt = new DateTime (1989, 01, 08); // Start of Heisei Era
string formattedDateWithGannen = "\u5E73\u6210 \u5143\u5E74 01\u6708 08\u65E5"; // 平成 元年 01月 08日
string formattedDate = dt.ToString (pattern, jpnFormat);
Assert.IsTrue (DateTime.TryParseExact (formattedDate, pattern, jpnFormat, DateTimeStyles.None, out DateTime parsedDate));
Assert.AreEqual (dt, parsedDate);
// If the formatting with Gan-nen is supported, then parsing should succeed. otherwise parsing should fail.
Assert.IsTrue (formattedDate.IndexOf ("\u5143" /* 元 */, StringComparison.Ordinal) >= 0 ==
DateTime.TryParseExact (formattedDateWithGannen, pattern, jpnFormat, DateTimeStyles.None, out parsedDate),
$"Parsing '{formattedDateWithGannen}' result should match if '{formattedDate}' has Gan-nen symbol"
);
}
}
}