From a97a2194067800bb552c8b4cc0d1770588db00ad Mon Sep 17 00:00:00 2001 From: Davey Shafik Date: Sat, 17 Dec 2016 00:36:26 -0800 Subject: [PATCH] Ignore microseconds per the spec --- src/Authentication/Timestamp.php | 4 +++- tests/Authentication/TimestampTest.php | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Authentication/Timestamp.php b/src/Authentication/Timestamp.php index bbc87f4..923ce3d 100644 --- a/src/Authentication/Timestamp.php +++ b/src/Authentication/Timestamp.php @@ -18,6 +18,8 @@ */ class Timestamp { + const FORMAT = 'Ymd\TH:i:sO'; + /** * @var \DateTime Signing Timestamp */ @@ -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); } } diff --git a/tests/Authentication/TimestampTest.php b/tests/Authentication/TimestampTest.php index 853b96f..93f8a7c 100644 --- a/tests/Authentication/TimestampTest.php +++ b/tests/Authentication/TimestampTest.php @@ -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); }