Skip to content

Commit f4c5ad9

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

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.
@@ -45,4 +47,21 @@
4547
class TimeLegacy extends DateTime
4648
{
4749
use TimeTrait;
50+
51+
/**
52+
* Returns a new instance with the date set to the new timestamp.
53+
*
54+
* @param int $timestamp
55+
*
56+
* @return self
57+
*
58+
* @throws Exception
59+
*/
60+
#[ReturnTypeWillChange]
61+
public function setTimestamp($timestamp)
62+
{
63+
$time = date('Y-m-d H:i:s', $timestamp);
64+
65+
return self::parse($time, $this->timezone, $this->locale);
66+
}
4867
}

0 commit comments

Comments
 (0)