本文整理汇总了C#中System.Globalization.DateTimeFormatInfo.GetEra方法的典型用法代码示例。如果您正苦于以下问题:C# DateTimeFormatInfo.GetEra方法的具体用法?C# DateTimeFormatInfo.GetEra怎么用?C# DateTimeFormatInfo.GetEra使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Globalization.DateTimeFormatInfo
的用法示例。
在下文中一共展示了DateTimeFormatInfo.GetEra方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetEra
public void GetEra(DateTimeFormatInfo format, string eraName, int expected)
{
Assert.Equal(expected, format.GetEra(eraName));
}
示例2: VerificationHelper
private void VerificationHelper(DateTimeFormatInfo info, string eraName, int expected)
{
int actual = info.GetEra(eraName);
Assert.Equal(expected, actual);
}
示例3: GetEra
private static int GetEra(__DTString str, DateTimeResult result, ref DateTimeFormatInfo dtfi) {
int[] eras = dtfi.Calendar.Eras;
if (eras != null) {
String word = str.PeekCurrentWord();
int era;
if ((era = dtfi.GetEra(word)) > 0) {
str.Index += word.Length;
return (era);
}
switch (dtfi.CultureID) {
case 0x0411:
// 0x0411 is the culture ID for Japanese.
if (dtfi.Calendar.ID != Calendar.CAL_JAPAN) {
// If the calendar for dtfi is Japanese, we have already
// done the check above. No need to re-check again.
GetJapaneseCalendarDTFI();
if ((era = m_jajpDTFI.GetEra(word)) > 0) {
str.Index += word.Length;
result.calendar = JapaneseCalendar.GetDefaultInstance();
dtfi = m_jajpDTFI;
return (era);
}
}
break;
case 0x0404:
// 0x0404 is the culture ID for Taiwan.
if (dtfi.Calendar.ID != Calendar.CAL_TAIWAN) {
GetTaiwanCalendarDTFI();
if ((era = m_zhtwDTFI.GetEra(word)) > 0) {
str.Index += word.Length;
result.calendar = TaiwanCalendar.GetDefaultInstance();
dtfi = m_zhtwDTFI;
return (era);
}
}
break;
}
}
return (-1);
}