本文整理匯總了C#中System.Globalization.DateTimeFormatInfo.GetAbbreviatedEraName方法的典型用法代碼示例。如果您正苦於以下問題:C# DateTimeFormatInfo.GetAbbreviatedEraName方法的具體用法?C# DateTimeFormatInfo.GetAbbreviatedEraName怎麽用?C# DateTimeFormatInfo.GetAbbreviatedEraName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Globalization.DateTimeFormatInfo
的用法示例。
在下文中一共展示了DateTimeFormatInfo.GetAbbreviatedEraName方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: VerificationHelper
private void VerificationHelper(DateTimeFormatInfo info, int era, string expected)
{
string actual = info.GetAbbreviatedEraName(era);
Assert.Equal(expected, actual);
}
示例2: MatchEraName
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;
}
示例3: MatchEraName
/*=================================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"));
}