Skip to content

Commit

Permalink
Ignore microseconds per the spec
Browse files Browse the repository at this point in the history
  • Loading branch information
dshafik committed Dec 17, 2016
1 parent ab3be7d commit a97a219
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Authentication/Timestamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
class Timestamp
{
const FORMAT = 'Ymd\TH:i:sO';

/**
* @var \DateTime Signing Timestamp
*/
Expand Down Expand Up @@ -69,6 +71,6 @@ public function setValidFor($interval)
*/
public function __toString()
{
return $this->timestamp->format('Ymd\TH:i:s.uO');
return $this->timestamp->format(static::FORMAT);
}
}
4 changes: 2 additions & 2 deletions tests/Authentication/TimestampTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public function testTimestampFormat()
{
$timestamp = new \Akamai\Open\EdgeGrid\Authentication\Timestamp();

$check = \DateTime::createFromFormat('Ymd\TH:i:s.uO', (string) $timestamp, new \DateTimeZone('UTC'));
$this->assertEquals($check, \PHPUnit_Framework_Assert::readAttribute($timestamp, 'timestamp'));
$check = \DateTime::createFromFormat('Ymd\TH:i:sO', (string) $timestamp, new \DateTimeZone('UTC'));
$this->assertEquals($check->format(\Akamai\Open\EdgeGrid\Authentication\Timestamp::FORMAT), (string) $timestamp);
}


Expand Down

0 comments on commit a97a219

Please sign in to comment.