Skip to content

Commit

Permalink
Merge pull request #6825 from kenjis/replace-time-in-BaseModel
Browse files Browse the repository at this point in the history
refactor: replace time() with Time in BaseModel
  • Loading branch information
kenjis authored Nov 7, 2022
2 parents 172daf3 + d3a9361 commit bc38d85
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
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

0 comments on commit bc38d85

Please sign in to comment.