Further BC issue after #202
joshbmarshall opened this issue · comments
There's an issue with timezones when parsing a time by itself. Introduced by #198 and partially fixed.
For example I add to the TestingAidsTest.php file the following test, it fails:
public function testParseRelativeWithTimezoneAndTestValueSet($class) {
$notNow = $class::parse('2013-07-01 12:00:00', 'America/New_York');
$class::setTestNow($notNow);
$this->assertSame('06:30:00', $class::parse('2013-07-01 06:30:00', 'America/Mexico_City')->toTimeString());
$this->assertSame('06:30:00', $class::parse('6:30', 'America/Mexico_City')->toTimeString());
$this->assertSame('2013-07-01T06:30:00-04:00', $class::parse('2013-07-01 06:30:00')->toIso8601String());
$this->assertSame('2013-07-01T06:30:00-04:00', $class::parse('6:30')->toIso8601String());
$this->assertSame('2013-07-01T06:30:00-05:00', $class::parse('2013-07-01 06:30:00', 'America/Mexico_City')->toIso8601String());
$this->assertSame('2013-07-01T06:30:00-05:00', $class::parse('6:30', 'America/Mexico_City')->toIso8601String());
$this->assertSame('2013-07-01T06:30:00-05:00', $class::parse('6:30:00', 'America/Mexico_City')->toIso8601String());
$this->assertSame('2013-07-01T06:30:00-05:00', $class::parse('06:30:00', 'America/Mexico_City')->toIso8601String());
}
Instead it is returning an offset time based on the timezone. In the above example it is returning 05:30:00 instead of 06:30:00 because of the 1 hour timezone difference.
Pull request up now.
Hi @markstory I have commented on your pull request it causes another issue.
The problem with time parsing has come from #198 and has caused other issues with further tests along the track. It's likely the time detection should be in a separate function. Now I see how you have done it perhaps I can create a pull request?