Returns the last day of last week of month
First day of week is configurable via {@link Factory::setOption()}.

@return \DateTime
173449
public function getLastDayOfLastWeek()
    {
        $lastDay = clone $this->end;
        $lastDay->sub(new \DateInterval('P1D'));

        return $this->getFactory()->findFirstDayOfWeek($lastDay)->add(new \DateInterval('P6D'));
    }
103826
public function get_starting_weekday() {
        global $CFG;

        if (isset($CFG->calendar_startwday)) {
            $firstday = $CFG->calendar_startwday;
        } else {
            $firstday = get_string('firstdayofweek', 'langconfig');
        }

        if (!is_numeric($firstday)) {
            $startingweekday = CALENDAR_DEFAULT_STARTING_WEEKDAY;
        } else {
            $startingweekday = intval($firstday) % 7;
        }

        return get_user_preferences('calendar_startwday', $startingweekday);
    }
699978
public function getDays()
	{
		return @isset( $this->Value->daysOnly ) && $this->Value->daysOnly && $this->Value->days ? $this->Value->days : $this->Value->d;
		return $this->Value->d;
	}
187849
public function weekly()
    {
        $this->setScheduleMonth(self::ANY);
        $this->setScheduleWeek(self::ANY);
        $this->setScheduleDayOfMonth(self::ANY);
        $this->setScheduleDayOfWeek(Day::SUNDAY);
        $this->setScheduleHour(0);
        $this->setScheduleMinute(0);

        return $this;
    }
289102
public static function weekRange()
    {
        $timestamp = time();
        return [
            strtotime(date('Y-m-d', strtotime("+0 week Monday", $timestamp))),
            strtotime(date('Y-m-d', strtotime("+0 week Sunday", $timestamp))) + 24 * 3600 - 1
        ];
    }
28888
public function getLastModified(): \DateTime
    {
        if ($this->caching == false) {
            return \DateTime::createFromFormat("F d Y H:i:s.", date("F d Y H:i:s.", filemtime($this->getAbsoluteFilePath())));
        }

        if ($this->lastModified == null) {
            $this->lastModified = \DateTime::createFromFormat("F d Y H:i:s.", date("F d Y H:i:s.", filemtime($this->getAbsoluteFilePath())));
        }

        return $this->lastModified;
    }
915934
public function dayOfWeek()
    {
        $dateString = sprintf(
            '%04d-%02d-%02d',
            $this->month->getYear()->value(),
            $this->month->value(),
            $this->day
        );

        $datetime = new \DateTime($dateString);

        return (int) $datetime->format('N');
    }
746913
public function getValue()
	{
		$value = parent::getValue();
		if ($value instanceof \DateTime) {
			$value->setTime(0, 0, 0);
			return $value;
		}
		return $value;
	}
683242
public static Date getFirstDayOfLastWeek(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTimeInMillis(date.getTime() - 604800000L);
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        Date lastWeekDate = c.getTime();

        c = new GregorianCalendar();
        c.setFirstDayOfWeek(Calendar.MONDAY);
        c.setTime(new Date(lastWeekDate.getTime()));
        c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek()); // Monday
        return c.getTime();
    }
76614
public static Date getLastDayOfMonth(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        int firstDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
        return org.apache.commons.lang.time.DateUtils.setDays(date, firstDay);
    }
25466
public function getLastRead(): \DateTime
    {
        if ($this->caching == false) {
            return \DateTime::createFromFormat("F d Y H:i:s.", date("F d Y H:i:s.", fileatime($this->getAbsoluteFilePath())));
        }

        if ($this->lastRead == null) {
            $this->lastRead = \DateTime::createFromFormat("F d Y H:i:s.", date("F d Y H:i:s.", fileatime($this->getAbsoluteFilePath())));
        }

        return $this->lastRead;
    }
898135
public function getStartDate() {
        $now = $this->getNow();
        $endOfDay = $this->getToday()->modify('+18 hours');

        $currentDay = $this->getToday();

        if($now > $endOfDay) {
            $currentDay->modify('+1 day');
        }

        return $currentDay;
    }
875942
def get_last_day_of_month(t: datetime) -> int:
    
    tn = t + timedelta(days=32)
    tn = datetime(year=tn.year, month=tn.month, day=1)
    tt = tn - timedelta(hours=1)
    return tt.day
575457
public function loadLastRunTime()
	{
		$date = NULL;
		$filepath = $this->buildFilePath();
		if (file_exists($filepath)) {
			$date = file_get_contents($filepath);
			$date = DateTime::createFromFormat(self::DATETIME_FORMAT, $date);
		}

		return $date ? $date : NULL;
	}
724878
public function getPasswordLastSetDate()
    {
        if ($timestamp = $this->getPasswordLastSetTimestamp()) {
            return (new DateTime())->setTimestamp($timestamp)->format($this->dateFormat);
        }
    }
1126487
public static Date getLastDayFromCurrentWeek(Date d) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(d);        
        // depends on Locale (if a week starts on Monday or on Sunday)
        if (cal.getFirstDayOfWeek() == Calendar.SUNDAY) {
        	cal.add(Calendar.WEEK_OF_YEAR, 1);  
        }	
        cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
        cal.set(Calendar.HOUR_OF_DAY, 23);
        cal.set(Calendar.MINUTE, 59);
        cal.set(Calendar.SECOND, 59);
        cal.set(Calendar.MILLISECOND, 999);
        return cal.getTime();
    }
54825
public function endOfWeek()
        {
            if ($this->dayOfWeek != self::SUNDAY) $this->next(self::SUNDAY);

            return $this->endOfDay();
        }