File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 56
56
* Requires the intl PHP extension.
57
57
*
58
58
* @package CodeIgniter\I18n
59
+ *
60
+ * @property string $date
59
61
*/
60
62
class Time extends DateTime
61
63
{
62
-
63
64
/**
64
65
* @var \DateTimeZone
65
66
*/
@@ -1371,4 +1372,21 @@ public function __isset($name): bool
1371
1372
return method_exists ($ this , $ method );
1372
1373
}
1373
1374
1375
+ //--------------------------------------------------------------------
1376
+
1377
+ /**
1378
+ * This is called when we unserialize the Time object.
1379
+ */
1380
+ public function __wakeup ()
1381
+ {
1382
+ /**
1383
+ * Prior to unserialization, this is a string.
1384
+ *
1385
+ * @var string $timezone
1386
+ */
1387
+ $ timezone = $ this ->timezone ;
1388
+
1389
+ $ this ->timezone = new DateTimeZone ($ timezone );
1390
+ parent ::__construct ($ this ->date , $ this ->timezone );
1391
+ }
1374
1392
}
Original file line number Diff line number Diff line change @@ -1008,4 +1008,14 @@ public function testGetter()
1008
1008
$ this ->assertNull ($ time ->weekOfWeek );
1009
1009
}
1010
1010
1011
+ public function testUnserializeTimeObject ()
1012
+ {
1013
+ $ time1 = new Time ('August 28, 2020 10:04:00pm ' , 'Asia/Manila ' , 'en ' );
1014
+ $ timeCache = serialize ($ time1 );
1015
+ $ time2 = unserialize ($ timeCache );
1016
+
1017
+ $ this ->assertInstanceOf (Time::class, $ time2 );
1018
+ $ this ->assertTrue ($ time2 ->equals ($ time1 ));
1019
+ $ this ->assertEquals ($ time1 , $ time2 );
1020
+ }
1011
1021
}
You can’t perform that action at this time.
0 commit comments