Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Baspa committed Oct 5, 2023
1 parent f8a5b20 commit 74c0804
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Period.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,45 @@ final public function __construct(Carbon $startDate, Carbon $endDate)
throw InvalidPeriod::startDateCannotBeGreaterThanEndDate($startDate, $endDate);
}

$this->startDate = $startDate;
$this->endDate = $endDate;
$this->startDate = Carbon::instance($startDate);
$this->endDate = Carbon::instance($endDate);
}

public static function make(Carbon $startDate, Carbon $endDate): self
{
return new self($startDate, $endDate);
return new self(Carbon::instance($startDate), Carbon::instance($endDate));
}

public static function days(int $days): self
{
$endDate = Carbon::today();
$startDate = Carbon::today()->subDays($days);

return new self($startDate, $endDate);
return new self(Carbon::instance($startDate), Carbon::instance($endDate));
}

public static function weeks(int $weeks): self
{
$endDate = Carbon::today();
$startDate = Carbon::today()->subWeeks($weeks)->startOfDay();

return new self($startDate, $endDate);
return new self(Carbon::instance($startDate), Carbon::instance($endDate));
}

public static function months(int $months): self
{
$endDate = Carbon::today();
$startDate = Carbon::today()->subMonths($months)->startOfDay();

return new self($startDate, $endDate);
return new self(Carbon::instance($startDate), Carbon::instance($endDate));
}

public static function years(int $years): self
{
$endDate = Carbon::today();
$startDate = Carbon::today()->subYears($years)->startOfDay();

return new self($startDate, $endDate);
return new self(Carbon::instance($startDate), Carbon::instance($endDate));
}

public static function since(Carbon $startDate): self
Expand All @@ -68,14 +68,14 @@ public static function hours(int $hours): self
$endDate = Carbon::now();
$startDate = Carbon::now()->subHours($hours);

return new self($startDate, $endDate);
return new self(Carbon::instance($startDate), Carbon::instance($endDate));
}

public static function minutes(int $minutes): self
{
$endDate = Carbon::now();
$startDate = Carbon::now()->subMinutes($minutes);

return new self($startDate, $endDate);
return new self(Carbon::instance($startDate), Carbon::instance($endDate));
}
}

0 comments on commit 74c0804

Please sign in to comment.