Skip to content

Commit

Permalink
Fix Hebrew date parsing (#13929)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tarekgh authored Sep 13, 2017
1 parent 1d1018a commit 7d6cc7c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/mscorlib/shared/System/Globalization/DateTimeParse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2295,6 +2295,23 @@ internal static Boolean ProcessHebrewTerminalState(DS dps, ref DateTimeResult re
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.
Expand Down

0 comments on commit 7d6cc7c

Please sign in to comment.