Skip to content

Commit

Permalink
fix timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
honzabrecka committed Nov 20, 2023
1 parent e40bb42 commit 19e1418
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 53 deletions.
24 changes: 0 additions & 24 deletions src/transit/Timestamp.php

This file was deleted.

2 changes: 0 additions & 2 deletions src/transit/Transit.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use transit\handlers\URIHandler;
use transit\handlers\UUIDHandler;
use transit\handlers\CharHandler;
use transit\handlers\TimestampHandler;
use transit\handlers\ArbitraryPrecisionDecimalHandler;
use transit\handlers\ArbitraryPrecisionIntegerHandler;

Expand Down Expand Up @@ -53,7 +52,6 @@ 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());
Expand Down
4 changes: 2 additions & 2 deletions src/transit/handlers/DateTimeHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ public function type() {
}

public function representation($obj) {
return $obj->getTimestamp() * 1000;
return $obj->getTimestamp();
}

public function resolve($obj) {
return new \DateTime('@' . $obj/1000);
return new \DateTime('@' . $obj);
}

}
25 changes: 0 additions & 25 deletions src/transit/handlers/TimestampHandler.php

This file was deleted.

3 changes: 3 additions & 0 deletions test/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,9 @@ function r($input) {
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());

$timestamp = "[\"~#'\",\"~m1776669847291\"]";
Assert::equal($timestamp, w(r($timestamp)));

Assert::equal('["~bYWJj"]', w([new Bytes('abc')]));
Assert::equal([new Bytes('abc')], r('["~bYWJj"]'));

Expand Down

0 comments on commit 19e1418

Please sign in to comment.