Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHugh Zabriskie <hugh.zabriskie@gmail.com>2018-03-08 01:39:22 +0300
committerJan Kotas <jkotas@microsoft.com>2018-03-08 07:04:05 +0300
commitbc5905fdad203dfdce18119044ccc393088b28fa (patch)
tree161cc5fe3cf92f510aac48eaa959aed88e8c97e3 /src
parent946b43eb13442627b7d736758362bc3807b3e8f6 (diff)
Perf fix for month-day parsing ambiguity (dotnet/coreclr#16782)
* Perf fix for month-day parsing ambiguity * Use DateTime.TryCreate Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Diffstat (limited to 'src')
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs18
1 files changed, 2 insertions, 16 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs
index 16023209e..94963a19c 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs
@@ -520,25 +520,11 @@ namespace System.Globalization
throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue);
}
- internal override Boolean TryToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era, out DateTime result)
+ internal override bool TryToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era, out DateTime result)
{
if (era == CurrentEra || era == ADEra)
{
- try
- {
- result = new DateTime(year, month, day, hour, minute, second, millisecond);
- return true;
- }
- catch (ArgumentOutOfRangeException)
- {
- result = DateTime.Now;
- return false;
- }
- catch (ArgumentException)
- {
- result = DateTime.Now;
- return false;
- }
+ return DateTime.TryCreate(year, month, day, hour, minute, second, millisecond, out result);
}
result = DateTime.MinValue;
return false;