Returns the seven days of the week in an array.

@param DayOfWeek|null $first The day to return first. Optional, defaults to Monday.

@return DayOfWeek[]
194985
public static function all(DayOfWeek $first = null) : array
    {
        $days = [];
        $first = $first ?: DayOfWeek::get(DayOfWeek::MONDAY);
        $current = $first;

        do {
            $days[] = $current;
            $current = $current->plus(1);
        }
        while (! $current->isEqualTo($first));

        return $days;
    }
696355
public static function getWeekBeginningForDate($date = null, $dateFormat = 'd/m/Y') {
        if (!$date)
            $date = date($dateFormat);

        $dateObj = date_create_from_format($dateFormat, $date);

        $initialDay = $dateObj->format("w");
        $startDayOfWeek = $initialDay == 0 ? 6 : $initialDay - 1;

        // If we need to back track to monday, do that now.
        if ($startDayOfWeek > 0) {
            $dateObj->sub(new \DateInterval ("P" . $startDayOfWeek . "D"));
        }

        return $dateObj->format($dateFormat);
    }
375269
@Override
    public int getFirstDayOfWeek(Locale country) {

        String fw = country.getUnicodeLocaleType("fw");

        if (fw != null) {
            Weekday wd = toEnum(fw);
            if (wd != null) { // else ignore fw-extension
                return wd.getValue();
            }
        }

        if (this.firstDayOfWeek.isEmpty()) {
            // fallback
            GregorianCalendar gc = new GregorianCalendar(country);
            int fd = gc.getFirstDayOfWeek();
            return ((fd == 1) ? 7 : (fd - 1));
        }

        String key = FormatUtils.getRegion(country);
        Weekday first = Weekday.MONDAY;

        if (this.firstDayOfWeek.containsKey(key)) {
            first = this.firstDayOfWeek.get(key);
        }

        return first.getValue();

    }
479644
public function getDayOfWeek(AnDate $date = null)
    {
        $year = isset($date) ? $date->year  : $this->year;
        $month = isset($date) ? $date->month : $this->month;
        $day = isset($date) ? $date->day   : $this->day;

        if ($month > 2) {
            $month -= 2;
        } else {
            $month += 10;
            $year--;
        }

        $day = (floor((13 * $month - 1) / 5) +
                $day + ($year % 100) +
                floor(($year % 100) / 4) +
                floor(($year / 100) / 4) - 2 *
                floor($year / 100) + 77);

        $weekday_number = $day - 7 * floor($day / 7);
        return $weekday_number;
    }
713187
public static function lastWeekRange()
    {
        $timestamp = time();
        return [
            strtotime(date('Y-m-d', strtotime("last week Monday", $timestamp))),
            strtotime(date('Y-m-d', strtotime("last week Sunday", $timestamp))) + 24 * 3600 - 1
        ];
    }
218565
public static int dayOfWeek(long day) {
        long[] remainder = new long[1];
        floorDivide(day + 5 /* Calendar.THURSDAY */, 7, remainder);
        int dayOfWeek = (int)remainder[0];
        dayOfWeek = (dayOfWeek == 0) ? 7 : dayOfWeek;
        return dayOfWeek;
    }
18636
private function getDayBefore($dayNumber)
    {
        $tmpDayNumber = $dayNumber;

        for ($i = 0; $i < 6; $i++) {
            $tmpDayNumber = (Days::MONDAY === $tmpDayNumber) ? Days::SUNDAY : --$tmpDayNumber;

            if (null !== $day = $this->getDay($tmpDayNumber)) {
                return $day;
            }
        }

        return $this->getDay($dayNumber);
    }
754422
public com.google.type.DayOfWeek getDayOfWeek() {
    @SuppressWarnings("deprecation")
    com.google.type.DayOfWeek result = com.google.type.DayOfWeek.valueOf(dayOfWeek_);
    return result == null ? com.google.type.DayOfWeek.UNRECOGNIZED : result;
  }
1209365
@Nonnegative
  public static DayOfWeek getWeekday (@Nonnull final Weekday eWeekday)
  {
    switch (eWeekday)
    {
      case MONDAY:
        return DayOfWeek.MONDAY;
      case TUESDAY:
        return DayOfWeek.TUESDAY;
      case WEDNESDAY:
        return DayOfWeek.WEDNESDAY;
      case THURSDAY:
        return DayOfWeek.THURSDAY;
      case FRIDAY:
        return DayOfWeek.FRIDAY;
      case SATURDAY:
        return DayOfWeek.SATURDAY;
      case SUNDAY:
        return DayOfWeek.SUNDAY;
      default:
        throw new IllegalArgumentException ("Unknown weekday " + eWeekday);
    }
  }
752742
public static Date getFirstDayOfWeek(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return getADayOfWeek(calendar, Calendar.MONDAY).getTime();
    }
778133
public static function weekdays() : array
    {
        $days     = self::getAll();
        $weekDays = [];

        foreach ($days as $key => $day) {
            if ($day->isWeekDay()) {
                $weekDays[] = $day;
            }
        }

        return $weekDays;
    }
223368
public static function lastWeek($timeZone = null, $startOfWeek = 0)
    {
        $now = null;
        $before = null;
        if ( is_null($timeZone) ) {
            $now = new \DateTime();
            $before = new \DateTime();
        } else {
            $now = new \DateTime( "now", new \DateTimeZone( $timeZone ) );
            $before = new \DateTime( "now", new \DateTimeZone( $timeZone ) );
        }
        $dayOfWeek = (int) $now->format( "w" );
        $offset = (($dayOfWeek - $startOfWeek ) + 7 ) % 7;
        $beginOffset = $offset + 7;
        $endOffset = $offset + 1;
        $before->modify( "-$beginOffset day" );
        $now->modify( "-$endOffset day" );
        $range = new Range( $before, $now );

        return $range;
    }
989389
public function weekday($value = null)
    {
        $dayOfWeek = ($this->dayOfWeek + 7 - intval($this->getTranslationMessage('first_day_of_week') ?? 0)) % 7;

        return is_null($value) ? $dayOfWeek : $this->addDays($value - $dayOfWeek);
    }
514933
def workdays(first_day=None):
    
    if first_day is None:
        first_day = 'Monday'
    ix = _lower_weekdays().index(first_day.lower())
    return _double_weekdays()[ix:ix+5]
390405
public static function finalDayOfWeek($ts = null)
	{
		return sfTime::subtractDay(sfTime::firstDayOfWeek(sfTime::addWeek($ts)));
	}
1371568
public static function weekends() : array
    {
        $days        = self::getAll();
        $weekEndDays = [];

        foreach ($days as $key => $day) {
            if ($day->isWeekEnd()) {
                $weekEndDays[] = $day;
            }
        }

        return $weekEndDays;
    }
1012292
public static function getWeek($week = null): string
    {
        $week = $week ? $week : date('w');
        switch ($week) {
            case 'Sunday':
                return Yii::t('yuncms', 'Sunday');
                break;
            case 'Monday':
                return Yii::t('yuncms', 'Monday');
                break;
            case 'Tuesday':
                return Yii::t('yuncms', 'Tuesday');
                break;
            case 'Wednesday':
                return Yii::t('yuncms', 'Wednesday');
                break;
            case 'Thursday':
                return Yii::t('yuncms', 'Thursday');
                break;
            case 'Friday':
                return Yii::t('yuncms', 'Friday');
                break;
            case 'Saturday':
                return Yii::t('yuncms', 'Saturday');
                break;
        }
        return 'N/A';
    }