Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace time() with Time in BaseModel #6825

Merged
merged 2 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion system/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ protected function doProtectFields(array $data): array
*/
protected function setDate(?int $userData = null)
{
$currentDate = $userData ?? time();
$currentDate = $userData ?? Time::now()->getTimestamp();

return $this->intToDate($currentDate);
}
Expand Down
4 changes: 3 additions & 1 deletion tests/system/I18n/TimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ protected function tearDown(): void
parent::tearDown();

Locale::setDefault($this->currentLocale);

// Reset current time.
Time::setTestNow();
}

public function testNewTimeNow()
Expand Down Expand Up @@ -224,7 +227,6 @@ public function testCreateFromFormat()
$time = Time::createFromFormat('F j, Y', 'January 15, 2017', 'America/Chicago');

$this->assertCloseEnoughString(date('2017-01-15 H:i:s', $now->getTimestamp()), $time->toDateTimeString());
Time::setTestNow();
}

public function testCreateFromFormatWithTimezoneString()
Expand Down