diff --git a/src/transit/Transit.php b/src/transit/Transit.php index f924b7d..8be6167 100644 --- a/src/transit/Transit.php +++ b/src/transit/Transit.php @@ -53,11 +53,11 @@ private function registerDefaultHandlers() { $this->registerHandler(new SymbolHandler()); $this->registerHandler(new SetHandler()); $this->registerHandler(new ListHandler()); + $this->registerHandler(new TimestampHandler()); $this->registerHandler(new DateTimeHandler()); $this->registerHandler(new URIHandler()); $this->registerHandler(new UUIDHandler()); $this->registerHandler(new CharHandler()); - $this->registerHandler(new TimestampHandler()); $this->registerHandler(new ArbitraryPrecisionDecimalHandler()); $this->registerHandler(new ArbitraryPrecisionIntegerHandler()); } diff --git a/src/transit/handlers/DateTimeHandler.php b/src/transit/handlers/DateTimeHandler.php index 57761a3..5ef693e 100644 --- a/src/transit/handlers/DateTimeHandler.php +++ b/src/transit/handlers/DateTimeHandler.php @@ -13,11 +13,11 @@ public function type() { } public function representation($obj) { - return $obj->getTimestamp(); + return $obj->getTimestamp() * 1000; } public function resolve($obj) { - return new \DateTime('@' . $obj); + return new \DateTime('@' . $obj/1000); } -} \ No newline at end of file +} diff --git a/test/test.php b/test/test.php index 0ce593e..5311f1b 100644 --- a/test/test.php +++ b/test/test.php @@ -414,8 +414,8 @@ function r($input) { //------------------------- // extensions -//Assert::equal('["~m482196050"]', w([new DateTime('1985-04-12T23:20:50.52Z')])); -//Assert::equal([new DateTime('1985-04-12T23:20:50.52Z')], r('["~m482196050"]')); +Assert::equal('["~m482196050000"]', w([new DateTime('1985-04-12T23:20:50.52Z')])); +Assert::equal((new DateTime('1985-04-12T23:20:50.52Z'))->getTimestamp(), r('["~m482196050000"]')[0]->getTimestamp()); Assert::equal('["~bYWJj"]', w([new Bytes('abc')])); Assert::equal([new Bytes('abc')], r('["~bYWJj"]'));