lojix/power_model/src/main/com/thesett/aima/attribute/time/TimeUtils.java
public static int ticksToYears(long ticks)
    {
        // The number of years is ticks floor divided by number of milliseconds in 365 1/4 days.
        //return flooredDiv(ticks, MILLIS_PER_REAL_YEAR) + 1970;
        //return flooredDiv(ticks + ((long)DAYS_TO_1970 * MILLIS_PER_DAY), MILLIS_PER_REAL_YEAR);

        long unitMillis = MILLIS_PER_YEAR / 2;
        long i2 = (ticks >> 1) + ((1970L * MILLIS_PER_YEAR) / 2);

        if (i2 < 0)
        {
            i2 = i2 - unitMillis + 1;
        }

        int year = (int) (i2 / unitMillis);

        long yearStart = millisToYearStart(year);
        long diff = ticks - yearStart;

        if (diff < 0)
        {
            year--;
        }
        else if (diff >= (MILLIS_PER_DAY * 365L))
        {
            // One year may need to be added to fix estimate.
            long oneYear;

            if (isLeapYear(year))
            {
                oneYear = MILLIS_PER_DAY * 366L;
            }
            else
            {
                oneYear = MILLIS_PER_DAY * 365L;
            }

            yearStart += oneYear;

            if (yearStart <= ticks)
            {
                year++;
            }
        }

        return year;
    }
public static int ticksToYears(long ticks)
    {
        // The number of years is ticks floor divided by number of milliseconds in 365 1/4 days.
        //return flooredDiv(ticks, MILLIS_PER_REAL_YEAR) + 1970;
        //return flooredDiv(ticks + ((long)DAYS_TO_1970 * MILLIS_PER_DAY), MILLIS_PER_REAL_YEAR);

        long unitMillis = MILLIS_PER_YEAR / 2;
        long i2 = (ticks >> 1) + ((1970L * MILLIS_PER_YEAR) / 2);

        if (i2 < 0)
        {
            i2 = i2 - unitMillis + 1;
        }

        int year = (int) (i2 / unitMillis);

        long yearStart = millisToYearStart(year);
        long diff = ticks - yearStart;

        if (diff < 0)
        {
            year--;
        }
        else if (diff >= (MILLIS_PER_DAY * 365L))
        {
            // One year may need to be added to fix estimate.
            long oneYear;

            if (isLeapYear(year))
            {
                oneYear = MILLIS_PER_DAY * 366L;
            }
            else
            {
                oneYear = MILLIS_PER_DAY * 365L;
            }

            yearStart += oneYear;

            if (yearStart <= ticks)
            {
                year++;
            }
        }

        return year;
    }
Extracts the years component of a time in millisecond ticks.

@param  ticks The time in ticks.

@return The years component of the time.