System.Globalization.GregorianCalendar.GetYear C# (CSharp) Method

GetYear() public method

public GetYear ( System.DateTime time ) : int
time System.DateTime
return int
        public override int GetYear(DateTime time)
        {
            return (GetDatePart(time.Ticks, DatePartYear));
        }

Usage Example

Example #1
0
        public static int EncodeDate(DateTime d)
        {
            int day, month, year;
            int c, ya;

            GregorianCalendar calendar = new GregorianCalendar();

            day = calendar.GetDayOfMonth(d);
            month = calendar.GetMonth(d);
            year = calendar.GetYear(d);

            if (month > 2)
            {
                month -= 3;
            }
            else
            {
                month += 9;
                year -= 1;
            }

            c = year / 100;
            ya = year - 100 * c;

            return ((146097 * c) / 4 + (1461 * ya) / 4 + (153 * month + 2) / 5 + day + 1721119 - 2400001);
        }
All Usage Examples Of System.Globalization.GregorianCalendar::GetYear