Create ``daterange`` based on a year and an ISO week

        :param year: Year as an integer
        :param iso_week: ISO week number
        :return: A new ``daterange`` for the given week

        .. versionadded:: 0.4.0
514822
def from_week(cls, year, iso_week):
        

        first_day = date_from_iso_week(year, iso_week)
        return cls.from_date(first_day, period="week")
240599
def get_year_week(timestamp):
    """"""
    time_ = datetime.fromtimestamp(timestamp)
    year = time_.isocalendar()[0]
    week = time_.isocalendar()[1]
    return year, week
912730
def _years_in_date_range_within_decade(self, decade, begin_date, end_date):
        """"""
        begin_year = begin_date.year
        end_year = end_date.year
        if begin_year < decade:
            begin_year = decade
        if end_year > decade + 9:
            end_year = decade + 9
        return list(range(begin_year, end_year + 1))
1256030
func (dt DateTime) ISOWeek() (year, week int) {
	year, week = dt.t.ISOWeek()
	return
}
957373
def _iso_year_start(iso_year):
    ""
    fourth_jan = dt.date(iso_year, 1, 4)
    delta = dt.timedelta(fourth_jan.isoweekday()-1)
    return fourth_jan - delta
529086
def _start_date_of_year(year: int) -> datetime.date:
    

    jan_one = datetime.date(year, 1, 1)
    diff = 7 * (jan_one.isoweekday() > 3) - jan_one.isoweekday()

    return jan_one + datetime.timedelta(days=diff)
705851
def add_years(datetime_like_object, n, return_date=False):
    
    a_datetime = parser.parse_datetime(datetime_like_object)

    # try assign year, month, day
    try:
        a_datetime = datetime(
            a_datetime.year + n, a_datetime.month, a_datetime.day,
            a_datetime.hour, a_datetime.minute, a_datetime.second,
            a_datetime.microsecond, tzinfo=a_datetime.tzinfo,
        )
    except ValueError:  # Must be xxxx-02-29
        a_datetime = datetime(
            a_datetime.year + n, 2, 28,
            a_datetime.hour, a_datetime.minute,
            a_datetime.second, a_datetime.microsecond)

    if return_date:  # pragma: no cover
        return a_datetime.date()
    else:
        return a_datetime
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();
	}
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
    )
587555
def get(self, prefix, year, week):
        """"""
        filename = self._format_filename(prefix, year, week)
        return RawEvents(filename, prefix, year, 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
641258
void formatISOWeekOfYear(StringBuilder b, ZonedDateTime d, int width) {
    int w = d.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR);
    switch (width) {
      case 2:
        zeroPad2(b, w, 2);
        break;
        
      case 1:
        b.append(w);
        break;
    }
  }
452767
def to_iso_date(date, default=None):
    

    # not a date
    if not is_date(date):
        return default

    # handle Zope DateTime objects
    if isinstance(date, (DateTime)):
        return date.ISO8601()

    # handle python datetime objects
    return date.isoformat()
377723
def pickNthWeekday(year, month, dayofweek, hour, minute, whichweek):
    """"""
    first = datetime.datetime(year=year, month=month, hour=hour, minute=minute,
                              day=1)
    weekdayone = first.replace(day=((dayofweek - first.isoweekday()) % 7 + 1))
    for n in xrange(whichweek - 1, -1, -1):
        dt = weekdayone + n * WEEKS
        if dt.month == month:
            return dt
1190845
def picknthweekday(year, month, dayofweek, hour, minute, whichweek):
    """"""
    first = datetime.datetime(year, month, 1, hour, minute)
    weekdayone = first.replace(day=((dayofweek-first.isoweekday())%7+1))
    for n in range(whichweek):
        dt = weekdayone+(whichweek-n)*ONEWEEK
        if dt.month == month:
            return dt
1246794
public static function dateRangeInWeek($week = 0, $year = 0)
    {
        /*
          Fungsi ini untuk mendapatkan nilai tanggal berapa saja dalam minggu tertentu
          Tanggal dimulai pada hari senin pada minggu tersebut.
          returned type: array
         */
        $year = (int)$year;
        $week = (int)$week;
        if ($year < 1970) { // minimal unix time year 1970
            $year = date("Y");
            $week = date("W");
        }
        if ($week <= 0 || $week > 54) {
            $week = date("W");
            $year = date("Y");
        }
        //cek apakah tanggal 1 masuk minggu pertama atau minggu terakhir tahun sebelumnya
        $mingguTanggalAwalTahun   = date("W", mktime(1, 0, 0, 1, 1, $year));
        $jumlahDetikDalamSehari   = 24 * 60 * 60;
        $jumlahDetikDalamSeminggu = $jumlahDetikDalamSehari * 7;
        $hariAwalTahun            = date("w", mktime(1, 0, 0, 1, 1, $year));
        // Hari ke 0/7->minggu 1->Senin 2->Selasa 3->Rabu 4->Kamis 5->Jumat 6->Sabtu
        $detikAwalTahun = date("U", mktime(1, 0, 0, 1, 1, $year));
        if ($hariAwalTahun == 0) {
            $hariAwalTahun = 7; // ISO-8601 numeric representation
        }
        $jumlahHariPadaMingguPertama = (7 - $hariAwalTahun) + 1; //Long variable name but easily understood :P
        $detikTambahan               = (($week - 1) * $jumlahDetikDalamSeminggu) + ($jumlahHariPadaMingguPertama * $jumlahDetikDalamSehari);
        if ($mingguTanggalAwalTahun == 1) {
            $tanggalUnixSenin = $detikAwalTahun + $detikTambahan;
        } else {
            $tanggalUnixSenin = $detikAwalTahun + $detikTambahan + $jumlahDetikDalamSeminggu;
        }
        $dateRange = array();
        for ($i = 1; $i <= 7; $i++) {
            $dateRange[$i] = date("Y-m-d", ($tanggalUnixSenin + (($i - 1) * $jumlahDetikDalamSehari) - $jumlahDetikDalamSeminggu));
        }

        return $dateRange;
    }
978257
def get_week_URL(date, day=0):
    
    if day < 1:
        day = 1
    date = datetime(year=date.year, month=date.month, day=day, tzinfo=utc)
    return reverse('calendar_week', kwargs={'year': date.isocalendar()[0],
                                            'week': date.isocalendar()[1]})