File tree Expand file tree Collapse file tree 3 files changed +9
-3
lines changed
src/CloudEvents/Serializers
tests/CloudEvents/Serializers Expand file tree Collapse file tree 3 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 6
6
use CloudEvents \Serializers \Exceptions \UnsupportedEventSpecVersionException ;
7
7
use CloudEvents \V1 \CloudEventInterface as V1CloudEventInterface ;
8
8
use DateTimeInterface ;
9
+ use DateTimeZone ;
9
10
10
11
use function array_merge ;
11
12
12
13
class ArraySerializer
13
14
{
15
+ private const DATETIME_FORMAT = 'Y-m-d\TH:i:s\Z ' ;
16
+ private const DATETIME_ZONE = 'UTC ' ;
17
+
14
18
/**
15
19
* @throws UnsupportedEventSpecVersionException
16
20
* @throws \JsonException
@@ -46,7 +50,9 @@ protected function createPayload(CloudEventInterface $cloudEvent): array
46
50
47
51
private function formatTime (?DateTimeInterface $ time ): ?string
48
52
{
49
- return $ time === null ? null : $ time ->format (DATE_RFC3339 );
53
+ return $ time === null
54
+ ? null
55
+ : $ time ->setTimezone (new DateTimeZone (self ::DATETIME_ZONE ))->format (self ::DATETIME_FORMAT );
50
56
}
51
57
52
58
/**
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ public function testSerialize(): void
39
39
'datacontenttype ' => 'application/json ' ,
40
40
'dataschema ' => 'com.example/schema ' ,
41
41
'subject ' => 'larger-context ' ,
42
- 'time ' => '2018-04-05T17:31:00+00:00 ' ,
42
+ 'time ' => '2018-04-05T17:31:00Z ' ,
43
43
'data ' => [
44
44
'key ' => 'value ' ,
45
45
]
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public function testSerialize(): void
40
40
'datacontenttype ' => 'application/json ' ,
41
41
'dataschema ' => 'com.example/schema ' ,
42
42
'subject ' => 'larger-context ' ,
43
- 'time ' => '2018-04-05T17:31:00+00:00 ' ,
43
+ 'time ' => '2018-04-05T17:31:00Z ' ,
44
44
'data ' => [
45
45
'key ' => 'value ' ,
46
46
]
You can’t perform that action at this time.
0 commit comments