Determine day of week (0 indexed, starts by monday)

@param DateLexerResult $parts

@return integer|null
421628
protected function determineDayOfWeek(DateLexerResult $parts)
    {
        // D   A textual representation of a day, three letters
        // l (lowercase 'L')   A full textual representation of the day of the week
        if (null !== $w = $parts->getFirst('D', 'l')) {
            return (int)$w;
        }

        // N   ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) 1 (for Monday) through 7 (for Sunday)
        if (null !== $w = $parts->get('N')) {
            return (int)$w - 1;
        }

        // w   Numeric representation of the day of the week   0 (for Sunday) through 6 (for Saturday)
        if (null !== $w = $parts->get('w')) {
            return ((int)$w + 6) % 7;
        }
    }
409128
protected function determineOffset(DateLexerResult $parts, TimeOffset $offset)
    {
        // Z   Timezone offset in seconds.
        if (null !== $value = $parts->get('Z')) {
            $value = (int)$value;
        } elseif (null !== $o = $parts->getFirst('O', 'P')) {
            // O   Difference to Greenwich time (GMT) in hours Example: +0200
            // P   Difference to Greenwich time (GMT) with colon between hours and minutes
            $o = str_replace(':', '', $o);
            $sign = substr($o, 0, 1);
            $hours = (int)substr($o, 1, 2);
            $minutes = (int)substr($o, 3, 2);

            $o = $hours * 60 + $minutes;
            $o = $o * 60;

            if ($sign === '-') {
                $o = -$o;
            }

            $value = $o;
        }

        if (null !== $value) {
            $offset = $offset->withValue($value);
        }

        // I (capital i) Whether or not the date is in daylight saving time
        if (null !== $t = $parts->get('I')) {
            $offset = $offset->withDst($t);
        }
        
        // T   Timezone abbreviation   Examples: EST, MDT ...
        if (null !== $t = $parts->get('T')) {
            $offset = $offset->withAbbreviation($t);
        }

        return $offset;
    }
1250399
function getXDay(x, week, date) {
  week = getWeekIndex(week);
  date = date ? this.toDate(date) : new Date();
  if (date && typeof week === 'number') {
    return getXDayFn(date.getFullYear(), date.getMonth()+1, x, week);
  } else {
    return null;
  }
}
247838
protected function getYesterday() {
        if (!$this->_yesterday) {
            $this->_yesterday = new YesterdayList($this->version, $this->solution['accountSid']);
        }

        return $this->_yesterday;
    }
85036
public function ceilWeek($weekStartsAt = null)
    {
        if ($this->isMutable()) {
            $startOfWeek = $this->copy()->startOfWeek($weekStartsAt);

            return $startOfWeek != $this ?
                $this->startOfWeek($weekStartsAt)->addWeek() :
                $this;
        }

        $startOfWeek = $this->startOfWeek($weekStartsAt);

        return $startOfWeek != $this ?
            $startOfWeek->addWeek() :
            $this->copy();
    }
354166
protected function humanDateYesterday($parsedTxt)
    {
        $currentClass    = get_called_class();
        $parsedTxt->date = $currentClass::$humanReadableI18n['yesterday'];
        $parsedTxt->time = $currentClass::$humanReadableI18n['time_part'];
        
        $time = $this->format($currentClass::$humanReadableFormats['time']);
        
        $this->humanParseDateAndTimeText($parsedTxt, '', $time);
    }
841178
public function getRelativeWeekCount($end = null, $locale = null, $query = null, $cacheKey = null)
    {
        if (is_null($end))
        {
            $end = Carbon::today();
        }

        return $this->getCountInBetween($end->copy()->subWeek()->addDay()->startOfDay(), $end->endOfDay(), $locale, $query, $cacheKey);
    }
1295691
public function getOrderPeriodLastDay($day)
    {

        $currentWeekday = $this->formatAsWeekday($day);

        if ($currentWeekday == 7) {
            $currentWeekday = 0;
        }

        if ($currentWeekday == $this->getDeliveryWeekday()) {
            $dateDiff = -1 - Configure::read('appDb.FCS_DEFAULT_SEND_ORDER_LISTS_DAY_DELTA');
        }
        if ($currentWeekday == ($this->getDeliveryWeekday() + 1) % 7) {
            $dateDiff = (Configure::read('appDb.FCS_DEFAULT_SEND_ORDER_LISTS_DAY_DELTA') * -1) + 5;
        }
        if ($currentWeekday == ($this->getDeliveryWeekday() + 2) % 7) {
            $dateDiff = (Configure::read('appDb.FCS_DEFAULT_SEND_ORDER_LISTS_DAY_DELTA') * -1) + 4;
        }
        if ($currentWeekday == ($this->getDeliveryWeekday() + 3) % 7) {
            $dateDiff = (Configure::read('appDb.FCS_DEFAULT_SEND_ORDER_LISTS_DAY_DELTA') * -1) + 3;
        }
        if ($currentWeekday == ($this->getDeliveryWeekday() + 4) % 7) {
            $dateDiff = (Configure::read('appDb.FCS_DEFAULT_SEND_ORDER_LISTS_DAY_DELTA') * -1) + 2;
        }
        if ($currentWeekday == ($this->getDeliveryWeekday() + 5) % 7) {
            $dateDiff = (Configure::read('appDb.FCS_DEFAULT_SEND_ORDER_LISTS_DAY_DELTA') * -1) + 1;
        }
        if ($currentWeekday == ($this->getDeliveryWeekday() + 6) % 7) {
            $dateDiff = Configure::read('appDb.FCS_DEFAULT_SEND_ORDER_LISTS_DAY_DELTA') * -1;
        }

        $date = date($this->getI18Format('DateShortAlt'), strtotime($dateDiff . ' day ', $day));

        return $date;
    }
1174423
private int getDaysToNextMatch(WeekDay weekDay) {

        for (WeekDay wd : m_weekDays) {
            if (wd.compareTo(weekDay) > 0) {
                return wd.toInt() - weekDay.toInt();
            }
        }
        return (m_weekDays.iterator().next().toInt() + (m_interval * I_CmsSerialDateValue.NUM_OF_WEEKDAYS))
            - weekDay.toInt();
    }
941522
def working_yesterday(self, date_from=None, date_format=None):
		
		# date d'hier que sur les jours de week-end
		return self.delta(days=-1, date_from=date_from, date_format=date_format, days_range=[1, 2, 3, 4, 5, 6])
968924
public function startOfWeek()
    {
        $dt = $this;
        if ($dt->dayOfWeek !== static::$weekStartsAt) {
            $dt = $dt->previous(static::$weekStartsAt);
        }

        return $dt->startOfDay();
    }
1160825
public function getPart($part)
    {
        return isset($this->parts[$part]) ? $this->parts[$part] : null;
    }
566943
public static function getWeekdayFullname($day = null)
    {
        if ($day === null) {
            $day = new AnDate();
        }
        if ($day instanceof AnDate) {
            $weekday = self::getDayOfWeek($day);
        } elseif (is_int($day)) {
            $weekday = $day;
        }
        $names = self::getWeekDays();
        return $names[$weekday];
    }
968435
public function getWeek($timestamp = false)
    {
        if (!$timestamp) {
            $timestamp = $this->dateTime->getTimestamp();
        }

        return (int) date('W', $timestamp);
    }
364329
public function byDays(int $days): Date
    {
        return $this->dayTo($this->originalDate->day() + $days);
    }
232084
protected function convertDayOrdinalToPositive($dayNumber, $weekday, $timestamp)
    {
        $dayNumber = empty($dayNumber) ? 1 : $dayNumber; // Returns 0 when no number defined in BYDAY

        $dayOrdinals = $this->dayOrdinals;

        // We only care about negative BYDAY values
        if ($dayNumber >= 1) {
            return $dayOrdinals[$dayNumber];
        }

        $timestamp = (is_object($timestamp)) ? $timestamp : \DateTime::createFromFormat(self::UNIX_FORMAT, $timestamp);
        $start     = strtotime('first day of ' . $timestamp->format(self::DATE_TIME_FORMAT_PRETTY));
        $end       = strtotime('last day of ' . $timestamp->format(self::DATE_TIME_FORMAT_PRETTY));

        // Used with pow(2, X) so pow(2, 4) is THURSDAY
        $weekdays = array_flip(array_keys($this->weekdays));

        $numberOfDays = $this->numberOfDays(pow(2, $weekdays[$weekday]), $start, $end);

        // Create subset
        $dayOrdinals = array_slice($dayOrdinals, 0, $numberOfDays, true);

        // Reverse only the values
        $dayOrdinals = array_combine(array_keys($dayOrdinals), array_reverse(array_values($dayOrdinals)));

        return $dayOrdinals[$dayNumber * -1];
    }
706311
public static function getWeek($week = null)
    {
        $week = $week ? $week : date('w');
        $weekArr = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
        return Yii::t('system', $weekArr [$week]);
    }