System.Globalization.GregorianCalendarHelper.InitEraInfo C# (CSharp) Method

InitEraInfo() static private method

static private InitEraInfo ( int calID ) : System.Globalization.EraInfo[]
calID int
return System.Globalization.EraInfo[]
        internal static EraInfo[] InitEraInfo(int calID) {
            //
            // Initialize era information.
            //

            /*
            Japaense era info example:
            eraInfo[0] = new EraInfo(4, new DateTime(1989, 1, 8).Ticks, 1988, 1, GregorianCalendar.MaxYear - 1988);    // Heisei. Most recent
            eraInfo[1] = new EraInfo(3, new DateTime(1926, 12, 25).Ticks, 1925, 1, 1989 - 1925);  // Showa
            eraInfo[2] = new EraInfo(2, new DateTime(1912, 7, 30).Ticks, 1911, 1, 1926 - 1911);   // Taisho
            eraInfo[3] = new EraInfo(1, new DateTime(1868, 9, 8).Ticks, 1867, 1, 1912 - 1867);    // Meiji            
            */
            BCLDebug.Assert(calID > 0, "[GregorianCalendarHelper.InitEraInfo] Expected calID > 0");
            int[][] eraRanges = CalendarTable.Default.SERARANGES(calID);
            EraInfo [] eraInfo = new EraInfo[eraRanges.Length];
            int maxEraYear = GregorianCalendar.MaxYear;
            for (int i = 0; i < eraRanges.Length; i++)
            {
                //
                // The eraRange arrays are each the form of "4 1989 1 8 1988 1".
                // eraRanges[i][0] is the era value.
                // eraRanges[i][1] is the year when the era starts.
                // eraRanges[i][2] is the month when the era starts.
                // eraRanges[i][3] is the day when the era starts.
                // eraRanges[i][4] is the offset to Gregorian year (1988).
                // eraRanges[i][5] is the minimum era year for this era.
                //
                BCLDebug.Assert(eraRanges[i].Length == 6, "[GregorianCalendarHelper.InitEraInfo] Expected 6 SERARANGE elements (0-5), not " + eraRanges[i].Length);
                eraInfo[i] = new EraInfo(eraRanges[i][0], new DateTime(eraRanges[i][1], eraRanges[i][2], eraRanges[i][3]).Ticks, eraRanges[i][4], eraRanges[i][5], maxEraYear - eraRanges[i][4]);
                maxEraYear= eraRanges[i][1];
            }
            return (eraInfo);
        }
        

Usage Example

Example #1
0
 static TaiwanCalendar()
 {
     // Since
     //    Gregorian Year = Era Year + yearOffset
     // When Gregorian Year 1912 is year 1, so that
     //    1912 = 1 + yearOffset
     //  So yearOffset = 1911
     //m_EraInfo[0] = new EraInfo(1, new DateTime(1912, 1, 1).Ticks, 1911, 1, GregorianCalendar.MaxYear - 1911);
     m_EraInfo = GregorianCalendarHelper.InitEraInfo(Calendar.CAL_TAIWAN);
 }
All Usage Examples Of System.Globalization.GregorianCalendarHelper::InitEraInfo