diff --git a/VERSION b/VERSION index 2b7c5ae018..17b2ccd9bf 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.2 +0.4.3 diff --git a/src/Adapter/UdpAdapter.php b/src/Adapter/UdpAdapter.php index bc9004ee30..e497b13b76 100644 --- a/src/Adapter/UdpAdapter.php +++ b/src/Adapter/UdpAdapter.php @@ -28,8 +28,7 @@ final class UdpAdapter extends AdapterAbstract $tags = array_replace_recursive($tags, $message["tags"]); } - $now = new DateTime(); - $unixepoch = (int)($now->format("U") * 1e9); + $unixepoch = (int)(microtime(true) * 1e9); if (array_key_exists("time", $message)) { $dt = new DateTime($message["time"]); $unixepoch = (int)($dt->format("U") * 1e9); diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 1bfb33db3d..ad5367b2e9 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -2,6 +2,7 @@ namespace InfluxDB; use DateTime; +use DateTimeZone; use InfluxDB\Adapter\GuzzleAdapter as InfluxHttpAdapter; use InfluxDB\Options; use InfluxDB\Adapter\UdpAdapter; @@ -165,11 +166,8 @@ class ClientTest extends \PHPUnit_Framework_TestCase $object = $this->createClientWithUdpAdapter(); $object->mark("udp.test", ["mark" => "element"]); - sleep(1); $object->mark("udp.test", ["mark" => "element1"]); - sleep(1); $object->mark("udp.test", ["mark" => "element2"]); - sleep(1); $object->mark("udp.test", ["mark" => "element3"]); // Wait UDP/IP message arrives @@ -278,8 +276,8 @@ class ClientTest extends \PHPUnit_Framework_TestCase $this->assertCount(1, $body["results"][0]["series"][0]["values"]); $this->assertEquals("time", $body["results"][0]["series"][0]["columns"][0]); - $saved = new DateTime($body["results"][0]["series"][0]["values"][0][0]); - $this->assertEquals(date("Y-m-d"), $saved->format("Y-m-d")); + $saved = $body["results"][0]["series"][0]["values"][0][0]; + $this->assertRegExp("/".date("Y-m-d")."/i", $saved); } /**