Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetYearOffset()

int System.Globalization.GregorianCalendarHelper.GetYearOffset ( int year,
int era,
bool throwOnError )
inlineprivate

Definition at line 53 of file GregorianCalendarHelper.cs.

54 {
55 if (year < 0)
56 {
57 if (throwOnError)
58 {
59 throw new ArgumentOutOfRangeException("year", SR.ArgumentOutOfRange_NeedNonNegNum);
60 }
61 return -1;
62 }
63 if (era == 0)
64 {
66 }
67 for (int i = 0; i < m_EraInfo.Length; i++)
68 {
69 if (era != m_EraInfo[i].era)
70 {
71 continue;
72 }
73 if (year >= m_EraInfo[i].minEraYear)
74 {
75 if (year <= m_EraInfo[i].maxEraYear)
76 {
77 return m_EraInfo[i].yearOffset;
78 }
79 if (!LocalAppContextSwitches.EnforceJapaneseEraYearRanges)
80 {
81 int num = year - m_EraInfo[i].maxEraYear;
82 for (int num2 = i - 1; num2 >= 0; num2--)
83 {
84 if (num <= m_EraInfo[num2].maxEraYear)
85 {
86 return m_EraInfo[i].yearOffset;
87 }
88 num -= m_EraInfo[num2].maxEraYear;
89 }
90 }
91 }
92 if (!throwOnError)
93 {
94 break;
95 }
96 throw new ArgumentOutOfRangeException("year", SR.Format(SR.ArgumentOutOfRange_Range, m_EraInfo[i].minEraYear, m_EraInfo[i].maxEraYear));
97 }
98 if (throwOnError)
99 {
100 throw new ArgumentOutOfRangeException("era", SR.ArgumentOutOfRange_InvalidEraValue);
101 }
102 return -1;
103 }

References System.SR.ArgumentOutOfRange_InvalidEraValue, System.SR.ArgumentOutOfRange_NeedNonNegNum, System.SR.ArgumentOutOfRange_Range, System.Globalization.Calendar.CurrentEraValue, System.LocalAppContextSwitches.EnforceJapaneseEraYearRanges, System.SR.Format(), System.Globalization.GregorianCalendarHelper.m_Cal, System.Globalization.GregorianCalendarHelper.m_EraInfo, System.Globalization.EraInfo.maxEraYear, System.Globalization.EraInfo.minEraYear, System.year, and System.Globalization.EraInfo.yearOffset.

Referenced by System.Globalization.GregorianCalendarHelper.GetGregorianYear(), System.Globalization.GregorianCalendarHelper.IsValidYear(), and System.Globalization.GregorianCalendarHelper.ValidateYearInEra().