Skip to content

Commit

Permalink
fix: Formatting of publishTime date string when none given
Browse files Browse the repository at this point in the history
Use ISO8601 format when the publishTime is not provided in the message.
  • Loading branch information
TonyVlcek committed Sep 29, 2023
1 parent 85aed77 commit 0864918
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/LegacyEventMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private function convertRawPubsubPayload(array $jsonData, string $requestUriPath
if (array_key_exists('publishTime', $jsonData['message'])) {
$timestamp = $jsonData['message']['publishTime'];
} else {
$timestamp = gmdate('%Y-%m-%dT%H:%M:%S.%6NZ');
$timestamp = gmdate('Y-m-d\TH:i:s.v\Z');
}

return [
Expand Down
4 changes: 2 additions & 2 deletions tests/LegacyEventMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function testRawPubsubNoPath(): void
);
$this->assertNull($cloudevent->getSubject());
$this->assertEqualsWithDelta(
strtotime(gmdate('%Y-%m-%dT%H:%M:%S.%6NZ')),
strtotime(gmdate('Y-m-d\TH:i:s.v\Z')),
strtotime($cloudevent->getTime()),
1
);
Expand Down Expand Up @@ -168,7 +168,7 @@ public function testRawPubsubWithPath(): void
);
$this->assertNull($cloudevent->getSubject());
$this->assertEqualsWithDelta(
strtotime(gmdate('%Y-%m-%dT%H:%M:%S.%6NZ')),
strtotime(gmdate('Y-m-d\TH:i:s.v\Z')),
strtotime($cloudevent->getTime()),
1
);
Expand Down

0 comments on commit 0864918

Please sign in to comment.