diff options
author | Tarek Mahmoud Sayed <tarekms@microsoft.com> | 2017-09-13 08:20:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-13 08:20:46 -0700 |
commit | 7d6cc7c6404c119013f6160c755b4347a0883b56 (patch) | |
tree | fad993e2fba21576866694e0342941ceaa5d3ba9 | |
parent | 1d1018ad55b06f13a607d15e2fa41de198fd7137 (diff) | |
download | coreclr-7d6cc7c6404c119013f6160c755b4347a0883b56.tar.gz coreclr-7d6cc7c6404c119013f6160c755b4347a0883b56.tar.bz2 coreclr-7d6cc7c6404c119013f6160c755b4347a0883b56.zip |
Fix Hebrew date parsing (#13929)
This fix when parsing Hevrew dat e string formatted as dd/MM/yy. we didn't encounter the same on Windows before because default short date pattern on Windows is dd MMM yyyy which we can parse it successfully.
-rw-r--r-- | src/mscorlib/shared/System/Globalization/DateTimeParse.cs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mscorlib/shared/System/Globalization/DateTimeParse.cs b/src/mscorlib/shared/System/Globalization/DateTimeParse.cs index 415341aa5e..f821a95412 100644 --- a/src/mscorlib/shared/System/Globalization/DateTimeParse.cs +++ b/src/mscorlib/shared/System/Globalization/DateTimeParse.cs @@ -2295,6 +2295,23 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, return false; } break; + case DS.DX_NNY: + // When formatting, we only format up to the hundred digit of the Hebrew year, although Hebrew year is now over 5000. + // E.g. if the year is 5763, we only format as 763. so we do the reverse when parsing. + if (raw.year < 1000) + { + raw.year += 5000; + } + if (!GetDayOfNNY(ref result, ref raw, dtfi)) + { + return false; + } + if (!dtfi.YearMonthAdjustment(ref result.Year, ref raw.month, true)) + { + result.SetFailure(ParseFailureKind.FormatBadDateTimeCalendar, nameof(SR.Format_BadDateTimeCalendar), null); + return false; + } + break; case DS.DX_NM: case DS.DX_MN: // Deal with Month/Day pattern. |