Skip to content

Commit

Permalink
fix: keep TimeLegacy::setTimestamp() behavior
Browse files Browse the repository at this point in the history
We do not fix the bug in TimeLegacy.
  • Loading branch information
kenjis committed Aug 6, 2024
1 parent 2030114 commit f4c5ad9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions system/I18n/TimeLegacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
namespace CodeIgniter\I18n;

use DateTime;
use Exception;
use ReturnTypeWillChange;

/**
* Legacy Time class.
Expand Down Expand Up @@ -45,4 +47,21 @@
class TimeLegacy extends DateTime
{
use TimeTrait;

/**
* Returns a new instance with the date set to the new timestamp.
*
* @param int $timestamp
*
* @return self
*
* @throws Exception
*/
#[ReturnTypeWillChange]
public function setTimestamp($timestamp)
{
$time = date('Y-m-d H:i:s', $timestamp);

return self::parse($time, $this->timezone, $this->locale);
}
}

0 comments on commit f4c5ad9

Please sign in to comment.