public static int getDayOfYear(Calendar c) {
        Calendar c2 = Calendar.getInstance(c.getTimeZone());
        c2.setTime(c.getTime());
        c2.set(Calendar.MONTH, Calendar.JANUARY);
        c2.set(Calendar.DAY_OF_MONTH, 1);
        long diff = c.getTime().getTime() - c2.getTime().getTime();

        return (int)Math.ceil((double)diff / MILLIS_PER_DAY);
    }
converts the relevant fields in the given luatable to a Date object.
@param time LuaTable with entries for year month and day, and optionally hour/min/sec
@return a date object representing the date frim the luatable.
main/src/main/java/cgeo/geocaching/wherigo/kahlua/stdlib/OsLib.java