The end date of the week

 @param year [Integer] the merch year
 @param month [Integer] an integer specifying the julian month.
 @param week [Integer] an integer specifying the merch week.

 @return [Date] the ending date of the specified week
354705
def end_of_week(year, month, week)
      retail_calendar.end_of_week(year, julian_to_merch(month), week)
    end
765924
def week_date(self, start: int = 2017, end: int = 2018) -> str:
        
        year = self.year(start, end)
        week = self.random.randint(1, 52)
        return '{year}-W{week}'.format(
            year=year,
            week=week,
        )
1322041
function(year, month, date) {

    // change value from to zero-based
    date--;
    year--;

    // combine year and month to get the actual year and month
    // this allows user to set a negative month number
    var months = year2months(year) + month;
    year = months2year(months);
    month = months - year2months(year);
    months -= month;

    var days = getNewYearInDays(months);

    var leap = isLeap(year);
    var nextYear = getNextYearInDays(months, leap);
    var mode = getYearMode(days, nextYear, leap);

    days += Math.ceil(month * 29.5);
    if(month > 1 && mode == 1 || month > 2) days += mode;
    if(month > 5) days += leap;

    days += date;

    return days - DISTANCE;
  }
553555
def yday
      day_of_year = 0

      (1..(@month-1)).to_a.each do |month|
        day_of_year += PDaysInMonth[month-1]
      end

      day_of_year += day

      day_of_year
    end
1310368
def merch_year_from_date(date)
      if end_of_year(date.year) >= date
        return date.year
      else
        return date.year + 1
      end
    end
873990
long getYearMonthMillis(int year, int month) {
        long millis = getYearMillis(year);
        millis += getTotalMillisByYearMonth(year, month);
        return millis;
    }
806500
function monthCalendar(date) {
    var start = date.clone().startOf("month").startOf("week").startOf("day");
    var end = date.clone().endOf("month").endOf("week").startOf("day");
    var result = [];
    var current = start.weekday(0).subtract(1, "d");
    while (true) {
        current = current.clone().add(1, "d");
        result.push(current);
        if (areDatesEqual(current, end)) {
            break;
        }
    }
    return result;
}
435571
public function endOfMonth()
    {
        return $this->setDate($this->year, $this->month, $this->daysInMonth)->endOfDay();
    }
512058
def daysInMonth(self, month, year):
        
        result = None
        debug and log.debug('daysInMonth(%s, %s)', month, year)
        if month > 0 and month <= 12:
            result = self._DaysInMonthList[month - 1]

            if month == 2:
                if year in self._leapYears:
                    result += 1
                else:
                    if calendar.isleap(year):
                        self._leapYears.append(year)
                        result += 1

        return result
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);

    }
20363
def epiweeks_in_year(year: int) -> int:
    

    if date_to_epiweek(epiweek_to_date(Epiweek(year, 53))).year == year:
        return 53
    else:
        return 52
211796
public static Date getDateOfWeeksBack(final int weeksBack, final Date date) {

    return dateBack(Calendar.WEEK_OF_MONTH, weeksBack, date);
  }
1093399
def get_last_weekday_in_month(year, month, weekday):
        
        day = date(year, month, monthrange(year, month)[1])
        while True:
            if day.weekday() == weekday:
                break
            day = day - timedelta(days=1)
        return day
1029786
def merch_month
      # TODO: This is very inefficient, but less complex than strategic guessing
      # maybe switch to a binary search or something
      merch_year = calendar.merch_year_from_date(date)
      @merch_month ||= (1..12).detect do |num|
        calendar.end_of_month(merch_year, num) >= date && date >= calendar.start_of_month(merch_year, num)
      end
    end
1119428
def merch_year_and_month_from_dates(start_date, end_date)
      merch_months = []

      middle_of_start_month = Date.new(start_date.year, start_date.month, 14)
      middle_of_end_month = Date.new(end_date.year, end_date.month, 14)
      date = middle_of_start_month
        
      while date <= middle_of_end_month do
        merch_months.push(date_conversion(date))
        date = date >> 1
      end
      merch_months
    end
629873
long getFirstWeekOfYearMillis(int year) {
        long jan1millis = getYearMillis(year);
        int jan1dayOfWeek = getDayOfWeek(jan1millis);
        
        if (jan1dayOfWeek > (8 - iMinDaysInFirstWeek)) {
            // First week is end of previous year because it doesn't have enough days.
            return jan1millis + (8 - jan1dayOfWeek)
                * (long)DateTimeConstants.MILLIS_PER_DAY;
        } else {
            // First week is start of this year because it has enough days.
            return jan1millis - (jan1dayOfWeek - 1)
                * (long)DateTimeConstants.MILLIS_PER_DAY;
        }
    }
1186226
def end_of_month(self) -> datetime:
        
        # Increase month by 1,
        result = self.value + relativedelta(months=1)
        # take the 1st day of the (next) month,
        result = result.replace(day=1)
        # subtract one day
        result = result - relativedelta(days=1)
        self.value = result
        return self.value