@@ -23,13 +23,15 @@ final class JsonCodec implements CodecInterface
2323 private int $ maxDepth ;
2424 private Decoder $ parser ;
2525 private Encoder $ serializer ;
26+ private \DateTimeZone $ hostTimeZone ;
2627
2728 public function __construct (DataConverterInterface $ dataConverter , int $ maxDepth = 64 )
2829 {
2930 $ this ->maxDepth = $ maxDepth ;
3031
3132 $ this ->parser = new Decoder ($ dataConverter );
3233 $ this ->serializer = new Encoder ($ dataConverter );
34+ $ this ->hostTimeZone = new \DateTimeZone (\date_default_timezone_get ());
3335 }
3436
3537 public function encode (iterable $ commands ): string
@@ -50,15 +52,13 @@ public function encode(iterable $commands): string
5052
5153 public function decode (string $ batch , array $ headers = []): iterable
5254 {
53- static $ tz = new \DateTimeZone ('UTC ' );
54-
5555 try {
5656 $ commands = \json_decode ($ batch , true , $ this ->maxDepth , \JSON_THROW_ON_ERROR );
5757
5858 foreach ($ commands as $ command ) {
5959 /** @psalm-suppress ArgumentTypeCoercion */
6060 $ info = new TickInfo (
61- time: new \DateTimeImmutable ($ headers ['tickTime ' ] ?? 'now ' , $ tz ),
61+ time: ( new \DateTimeImmutable ($ headers ['tickTime ' ] ?? 'now ' ))-> setTimezone ( $ this -> hostTimeZone ),
6262 historyLength: (int ) ($ headers ['history_length ' ] ?? 0 ),
6363 historySize: (int ) ($ headers ['history_size ' ] ?? 0 ),
6464 continueAsNewSuggested: (bool ) ($ headers ['continue_as_new_suggested ' ] ?? false ),
0 commit comments