Get the number of weeks in the year.

@param year  the year to use
@return number of weeks in the year
335615
int getWeeksInYear(int year) {
        long firstWeekMillis1 = getFirstWeekOfYearMillis(year);
        long firstWeekMillis2 = getFirstWeekOfYearMillis(year + 1);
        return (int) ((firstWeekMillis2 - firstWeekMillis1) / DateTimeConstants.MILLIS_PER_WEEK);
    }
363126
public XMLGregorianCalendar newGYear(int year) {
        XMLGregorianCalendar cal=dataFactory.newXMLGregorianCalendar();
        cal.setYear(year);
        return cal;
    }
1176967
def get_months_of_year(year):
    
    current_year = now().year
    if year == current_year:
        return now().month
    if year > current_year:
        return 1
    if year < current_year:
        return 12
543022
function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) {
        var end = firstDayOfWeekOfYear - firstDayOfWeek,
            daysToDayOfWeek = firstDayOfWeekOfYear - mom.day();


        if (daysToDayOfWeek > end) {
            daysToDayOfWeek -= 7;
        }

        if (daysToDayOfWeek < end - 7) {
            daysToDayOfWeek += 7;
        }

        return Math.ceil(moment(mom).add('d', daysToDayOfWeek).dayOfYear() / 7);
    }
177219
public static Date plusYears(Date date, int years) {
		return plus(date, years, DateTimeField.YEAR);
	}
861877
private static int lYearDays(int year) {
        int i, sum = 348;
        for (i = 0x8000; i > 0x8; i >>= 1) {
            if ((lunarInfo[year - 1900] & i) != 0)
                sum += 1;
        }
        return (sum + leapDays(year));
    }
101299
public static function check(int $weekOfYear, int $year = null) : void
    {
        if ($weekOfYear < 1 || $weekOfYear > 53) {
            throw DateTimeException::fieldNotInRange(self::NAME, $weekOfYear, 1, 53);
        }

        if ($weekOfYear === 53 && $year !== null && ! self::is53WeekYear($year)) {
            throw new DateTimeException("Year $year does not have 53 weeks");
        }
    }
1369342
private static int getDayOfYear(int cycleNumber, int dayOfCycle, int yearInCycle) {
        Integer[] cycles = getAdjustedCycle(cycleNumber);

        if (dayOfCycle > 0) {
            return dayOfCycle - cycles[yearInCycle].intValue();
        } else {
            return cycles[yearInCycle].intValue() + dayOfCycle;
        }
    }
351534
public CalendarWeek plus(Years<Weekcycle> years) {

        if (years.isEmpty()) {
            return this;
        }

        int y = MathUtils.safeAdd(this.year, years.getAmount());
        int effectiveWeek = this.week;

        if ((this.week == 53) && (maximumOfWeek(y) < 53)) {
            effectiveWeek = 52;
        }

        return CalendarWeek.of(y, effectiveWeek);

    }
891162
public String getWeekdayOfMonth(int number, int weekday, int month, int year) {
		return getWeekdayRelativeTo(String.format("%04d-%02d-01", year, month), weekday, number, true);
	}
759553
def from_jd(jd):
    ''''''
    year = gregorian.from_jd(jd)[0]
    day = jwday(jd) + 1

    dayofyear = ordinal.from_jd(jd)[1]
    week = trunc((dayofyear - day + 10) / 7)

    # Reset year
    if week < 1:
        week = weeks_per_year(year - 1)
        year = year - 1

    # Check that year actually has 53 weeks
    elif week == 53 and weeks_per_year(year) != 53:
        week = 1
        year = year + 1

    return year, week, day
1169259
@Override
    protected PlainDate getDate0(int year) {

        int month = this.getMonthValue();
        int lastDay = GregorianMath.getLengthOfMonth(year, month);
        int lastW = GregorianMath.getDayOfWeek(year, month, lastDay);
        int delta = (lastW - this.dayOfWeek);

        if (delta < 0) {
            delta += 7;
        }

        return PlainDate.of(year, month, lastDay - delta);

    }
991198
public static int getDayOfYear(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        return c.get(Calendar.DAY_OF_YEAR);
    }
1345904
def _ssweek_info(ssweek_year, ssweek_week):
    ""
    prev_year_start = _ssweek_year_start(ssweek_year-1)
    year_start = _ssweek_year_start(ssweek_year)
    next_year_start = _ssweek_year_start(ssweek_year+1)
    first_day = year_start + dt.timedelta(weeks=ssweek_week-1)
    last_day = first_day + dt.timedelta(days=6)
    prev_year_num_weeks = ((year_start - prev_year_start).days) // 7
    year_num_weeks = ((next_year_start - year_start).days) // 7
    return (first_day, last_day, prev_year_num_weeks, year_num_weeks)
1303639
public static Years<Weekcycle> between(CalendarWeek w1, CalendarWeek w2) {

        int delta = w2.getYear() - w1.getYear();

        if (delta > 0) {
            if (w2.getWeek() < w1.getWeek()) {
                delta--;
            }
        } else if (delta < 0) {
            if (w2.getWeek() > w1.getWeek()) {
                delta++;
            }
        }

        return Years.ofWeekBased(delta);

    }
574065
public function withYear(int $year) : YearWeek
    {
        if ($year === $this->year) {
            return $this;
        }

        Field\Year::check($year);

        $week = $this->week;

        if ($week === 53 && ! Field\WeekOfYear::is53WeekYear($year)) {
            $week = 52;
        }

        return new YearWeek($year, $week);
    }
179091
public int getYear() {
    if (Date_Type.featOkTst && ((Date_Type)jcasType).casFeat_year == null)
      jcasType.jcas.throwFeatMissing("year", "de.julielab.jules.types.Date");
    return jcasType.ll_cas.ll_getIntValue(addr, ((Date_Type)jcasType).casFeatCode_year);}