System.Globalization.CCGregorianCalendar.year_from_fixed C# (CSharp) Method

year_from_fixed() public static method

The method computes the Gregorian year from a fixed day number.
public static year_from_fixed ( int date ) : int
date int The fixed day number. ///
return int
	public static int year_from_fixed(int date) {
		int d		= date - epoch;
		int n_400	= CCMath.div_mod(out d, d, 146097);
		int n_100	= CCMath.div_mod(out d, d, 36524);
		int n_4		= CCMath.div_mod(out d, d, 1461);
		int n_1		= CCMath.div(d, 365);

		int year = 400*n_400 + 100*n_100 + 4*n_4 + n_1;
		return (n_100 == 4 || n_1 == 4) ? year : year + 1;
	}

Usage Example

Beispiel #1
0
        public static int GetDayOfYear(DateTime time)
        {
            int num  = CCFixed.FromDateTime(time);
            int year = CCGregorianCalendar.year_from_fixed(num);
            int num2 = CCGregorianCalendar.fixed_from_dmy(1, 1, year);

            return(num - num2 + 1);
        }
All Usage Examples Of System.Globalization.CCGregorianCalendar::year_from_fixed