本文整理匯總了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);
}