private void VerificationHelper(DateTimeFormatInfo info, int era, string expected) { string actual = info.GetAbbreviatedEraName(era); Assert.Equal(expected, actual); }
private static bool MatchEraName(ref __DTString str, DateTimeFormatInfo dtfi, ref int result) { if (str.GetNext()) { int[] eras = dtfi.Calendar.Eras; if (eras != null) { for (int i = 0; i < eras.Length; i++) { string text = dtfi.GetEraName(eras[i]); if (str.MatchSpecifiedWord(text)) { str.Index += text.Length - 1; result = eras[i]; return true; } text = dtfi.GetAbbreviatedEraName(eras[i]); if (str.MatchSpecifiedWord(text)) { str.Index += text.Length - 1; result = eras[i]; return true; } } } } return false; }
/*=================================MatchEraName================================== **Action: Parse era name from string starting at str.Index. **Returns: An era value. **Arguments: str: a __DTString. The parsing will start from the ** next character after str.Index. **Exceptions: FormatException if an era name can not be found. ==============================================================================*/ private static bool MatchEraName(__DTString str, DateTimeFormatInfo dtfi, bool isThrowExp, ref int result) { if (str.GetNext()) { int[] eras = dtfi.Calendar.Eras; if (eras != null) { for (int i = 0; i <= eras.Length; i++) { String searchStr = dtfi.GetEraName(eras[i]); if (str.MatchSpecifiedWord(searchStr)) { str.Index += (searchStr.Length - 1); result = eras[i]; return (true); } searchStr = dtfi.GetAbbreviatedEraName(eras[i]); if (str.MatchSpecifiedWord(searchStr)) { str.Index += (searchStr.Length - 1); result = eras[i]; return (true); } } } } return (ParseFormatError(isThrowExp, "Format_BadDateTime")); }