Skip to content

Commit b20df7c

Browse files
committed
fix: keep TimeLegacy::setTimestamp() behavior
We do not fix the bug in TimeLegacy.
1 parent f3a9ebb commit b20df7c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

system/I18n/TimeLegacy.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
namespace CodeIgniter\I18n;
1515

1616
use DateTime;
17+
use Exception;
18+
use ReturnTypeWillChange;
1719

1820
/**
1921
* Legacy Time class.
@@ -47,4 +49,21 @@
4749
class TimeLegacy extends DateTime
4850
{
4951
use TimeTrait;
52+
53+
/**
54+
* Returns a new instance with the date set to the new timestamp.
55+
*
56+
* @param int $timestamp
57+
*
58+
* @return static
59+
*
60+
* @throws Exception
61+
*/
62+
#[ReturnTypeWillChange]
63+
public function setTimestamp($timestamp)
64+
{
65+
$time = date('Y-m-d H:i:s', $timestamp);
66+
67+
return static::parse($time, $this->timezone, $this->locale);
68+
}
5069
}

0 commit comments

Comments
 (0)