Get week number with year.

        :param start: From start.
        :param end: To end.
        :return: Week number.
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,
        )
1022132
def iso_year_start(iso_year):
    ""
    fourth_jan = datetime.date(iso_year, 1, 4)
    delta = datetime.timedelta(fourth_jan.isoweekday() - 1)
    return fourth_jan - delta
295018
def _start_of_decade(self):
        
        year = self.year - self.year % YEARS_PER_DECADE

        return self.set(year, 1, 1)
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);
    }
115062
def _get_start_end(parts, index=7):
    
    start = parts[1]
    end = [x.split("=")[-1] for x in parts[index].split(";") if x.startswith("END=")]
    if end:
        end = end[0]
        return start, end
    return None, None
199751
def get(self, start, end):
        
        return [self.read_byte(addr) for addr in xrange(start, end)]
163793
def _ssweek_num_weeks(ssweek_year):
    ""
    year_start = _ssweek_year_start(ssweek_year)
    next_year_start = _ssweek_year_start(ssweek_year+1)
    year_num_weeks = ((next_year_start - year_start).days) // 7
    return year_num_weeks
1272312
def date_to_epiweek(date=datetime.date.today()) -> Epiweek:
    

    year = date.year
    start_dates = list(map(_start_date_of_year, [year - 1, year, year + 1]))

    start_date = start_dates[1]
    if start_dates[1] > date:
        start_date = start_dates[0]
    elif date >= start_dates[2]:
        start_date = start_dates[2]

    return Epiweek(
        year=(start_date + datetime.timedelta(days=7)).year,
        week=((date - start_date).days // 7) + 1,
        day=(date.isoweekday() % 7) + 1
    )
809798
def from_bucket(self, bucket, native=False):
    '''
    
    '''
    # NOTE: this is due to a bug somewhere in strptime that does not process
    # the week number of '%Y%U' correctly. That bug could be very specific to
    # the combination of python and ubuntu that I was testing.
    bucket = str(bucket)
    if self._step == 'weekly':
      year, week = bucket[:4], bucket[4:]
      normal = datetime(year=int(year), month=1, day=1) + timedelta(weeks=int(week))
    else:
      normal = datetime.strptime(bucket, self.FORMATS[self._step])
    if native:
      return normal
    return long(time.mktime( normal.timetuple() ))
943115
def _duration(start, end):
    
    if start and end:
        if start > end:
            return None
        else:
            return end - start
    elif start:
        return time.time() - start
    else:
        return None
618428
private int diff360EIsda(final LocalDate start, final LocalDate end) {
        if (start.equals(end)) {
            return 0;
        }
        int dayStart = start.getDayOfMonth();
        int dayEnd = end.getDayOfMonth();
        if (start.getMonth().length(start.isLeapYear()) == dayStart) {
            dayStart = CalculatorConstants.MONTH_30_DAYS;
        }
        if (end.getMonth() != Month.FEBRUARY && end.getMonth().length(end.isLeapYear()) == dayEnd) {
            dayEnd = CalculatorConstants.MONTH_30_DAYS;
        }
        return (end.getYear() - start.getYear()) * CalculatorConstants.YEAR_360 + (end.getMonthValue() - start.getMonthValue()) * CalculatorConstants.MONTH_30_DAYS + dayEnd - dayStart;
    }
261774
def get_week_start_end_day():
    
    t = date.today()
    wd = t.weekday()
    return (t - timedelta(wd), t + timedelta(6 - wd))
824919
def snap_to_beginning_of_week(day, weekday_start="Sunday"):
    
    delta_days = ((day.weekday() + 1) % 7) if weekday_start is "Sunday" else day.weekday()
    return day - timedelta(days=delta_days)
1166310
@SuppressWarnings("deprecation")
	private Date getWeekOne(int year) {
		GregorianCalendar weekOne = new GregorianCalendar();
		weekOne.setFirstDayOfWeek(getFirstDayOfWeek());
		weekOne.setMinimalDaysInFirstWeek(getMinimalDaysInFirstWeek());
		weekOne.setTime(new Date(year, 0, 1));
		// can we use the week of 1/1/year as week one?
		int dow = weekOne.get(DAY_OF_WEEK);
		if (dow < weekOne.getFirstDayOfWeek()) dow += 7;
		int eow = weekOne.getFirstDayOfWeek() + 7;
		if ((eow - dow) < weekOne.getMinimalDaysInFirstWeek()) {
			// nope, week one is the following week
			weekOne.add(DATE, 7);
		}
		weekOne.set(DAY_OF_WEEK, weekOne.getFirstDayOfWeek());
		return weekOne.getTime();
	}
1357288
private static int getWeekOfYear(PlainDate date) {

        int dayOfYear = date.getDayOfYear();
        int wCurrent = getFirstCalendarWeekAsDayOfYear(date, 0);

        if (wCurrent <= dayOfYear) {
            int result = ((dayOfYear - wCurrent) / 7) + 1;

            if (result >= 53) { // Optimierung
                int wNext =
                    getFirstCalendarWeekAsDayOfYear(date, 1)
                    + getLengthOfYear(date, 0);
                if (wNext <= dayOfYear) {
                    result = 1;
                }
            }

            return result;
        } else {
            int wPrevious = getFirstCalendarWeekAsDayOfYear(date, -1);
            int dayCurrent = dayOfYear + getLengthOfYear(date, -1);
            return ((dayCurrent - wPrevious) / 7) + 1;
        }

    }
916123
function getWeekNumber(date) {
  date = this.toDate(date);
  var week = this._startWeek;
  return date ? getWeekNumberFn(date, week, this.startMonth): null;
}
20058
def get_week_dates(year, week, as_timestamp=False):
    
    year = int(year)
    week = int(week)
    start_date = date(year, 1, 1)
    if start_date.weekday() > 3:
        start_date = start_date + timedelta(7 - start_date.weekday())
    else:
        start_date = start_date - timedelta(start_date.weekday())
    dlt = timedelta(days=(week-1)*7)
    start = start_date + dlt
    end = start_date + dlt + timedelta(days=6)
    if as_timestamp:
        # Add the complete day
        one_day = timedelta(days=1).total_seconds() - 0.000001
        end_timestamp = time.mktime(end.timetuple()) + one_day
        return time.mktime(start.timetuple()), end_timestamp
    return start, end