/** * Test reading with different timezones * * WARNING: This test restores to UTC, otherwise other tests will fail */ public function testReadingDifferentTimezones() { // GMT+2 time Data_Reader::$default_timezone = 'Etc/GMT+2'; // Get the data reader for the given data source $reader = Data_Reader::factory(realpath(__DIR__ . '/logs/rfactor2/race.xml')); // Get session $session = $reader->getSession(); // Get session date $date = $session->getDate(); // Validate timestamp of date $this->assertSame(1364153781, $date->getTimestamp()); // Test timezone $this->assertSame('2013-03-24 17:36:21', $date->format('Y-m-d H:i:s')); $this->assertSame('Etc/GMT+2', $date->getTimezone()->getName()); // UTC time (also restore default) Data_Reader::$default_timezone = 'UTC'; // Get the data reader for the given data source $reader = Data_Reader::factory(realpath(__DIR__ . '/logs/rfactor2/race.xml')); // Get session $session = $reader->getSession(); // Get session date $date = $session->getDate(); // Validate timestamp of date $this->assertSame(1364153781, $date->getTimestamp()); // Test timezone $this->assertSame('2013-03-24 19:36:21', $date->format('Y-m-d H:i:s')); $this->assertSame('UTC', $date->getTimezone()->getName()); }