本文整理汇总了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"));
}