From 5f8db583df1c4596d758bbb6607f11fe99ad3da8 Mon Sep 17 00:00:00 2001 From: Benjamin Morel Date: Tue, 6 Feb 2018 18:36:28 +0100 Subject: [PATCH] Add YearWeek::getFirstDay() and getLastDay() --- src/YearWeek.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/YearWeek.php b/src/YearWeek.php index 3b15760..9c3e0c5 100644 --- a/src/YearWeek.php +++ b/src/YearWeek.php @@ -236,6 +236,26 @@ public function atDay(int $dayOfWeek) : LocalDate return LocalDate::ofYearDay($this->year - 1, $daysOfPreviousYear + $dayOfYear); } + /** + * Returns the first day of this week. + * + * @return LocalDate + */ + public function getFirstDay() : LocalDate + { + return $this->atDay(DayOfWeek::MONDAY); + } + + /** + * Returns the last day of this week. + * + * @return LocalDate + */ + public function getLastDay() : LocalDate + { + return $this->atDay(DayOfWeek::SUNDAY); + } + /** * Returns a copy of this YearWeek with the specified period in years added. *