/** * Make sure that we handle microseconds correctly * * When we Date->__toString() it should preserve the microseconds, * and we should be able to parse it again to yield the exact same * value in another object. */ public function testMicrosecondsToStringAndBack() { $date0 = new Date(); // Format the current date without any microseconds, but use // a "@" char where the micros should be $stringDate = $date0->format('Y-m-d\\TH:i:s@O'); // Explicitly add microseconds to the date format string, so // we _guarantee_ that the date contains microseconds $stringDate = str_replace('@', '.123456', $stringDate); $date1 = new Date($stringDate); $string1 = $date1->__toString(); $date2 = new Date($string1); $this->assertEquals($date1->getTimestamp(), $date2->getTimestamp(), "Parsing __toString result should yield same date as before"); }