[Locale] Fixed error resetting in StubIntlDateFormatter::parse()
This commit is contained in:
parent
50109ebcc2
commit
b7aae48a74
@ -151,6 +151,9 @@ class FullTransformer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reset error code and message
|
||||||
|
StubIntl::setError(StubIntl::U_ZERO_ERROR);
|
||||||
|
|
||||||
return $this->calculateUnixTimestamp($dateTime, $options);
|
return $this->calculateUnixTimestamp($dateTime, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,10 +378,8 @@ class StubIntlDateFormatter
|
|||||||
$timestamp = $transformer->parse($dateTime, $value);
|
$timestamp = $transformer->parse($dateTime, $value);
|
||||||
|
|
||||||
// behave like the intl extension. FullTransformer::parse() set the proper error
|
// behave like the intl extension. FullTransformer::parse() set the proper error
|
||||||
if (false === $timestamp) {
|
$this->errorCode = StubIntl::getErrorCode();
|
||||||
$this->errorCode = StubIntl::getErrorCode();
|
$this->errorMessage = StubIntl::getErrorMessage();
|
||||||
$this->errorMessage = StubIntl::getErrorMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $timestamp;
|
return $timestamp;
|
||||||
}
|
}
|
||||||
|
@ -859,6 +859,24 @@ class StubIntlDateFormatterTest extends LocaleTestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* https://github.com/symfony/symfony/issues/4242
|
||||||
|
*/
|
||||||
|
public function testParseAfterErrorIntl()
|
||||||
|
{
|
||||||
|
$this->testParseErrorIntl('y-MMMMM-d', '1970-J-1');
|
||||||
|
$this->testParseIntl('y-M-d', '1970-1-1', 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* https://github.com/symfony/symfony/issues/4242
|
||||||
|
*/
|
||||||
|
public function testParseAfterErrorStub()
|
||||||
|
{
|
||||||
|
$this->testParseErrorStub('y-MMMMM-d', '1970-J-1');
|
||||||
|
$this->testParseStub('y-M-d', '1970-1-1', 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Just to document the differences between the stub and the intl implementations. The intl can parse
|
* Just to document the differences between the stub and the intl implementations. The intl can parse
|
||||||
* any of the tested formats alone. The stub does not implement them as it would be needed to add more
|
* any of the tested formats alone. The stub does not implement them as it would be needed to add more
|
||||||
|
Reference in New Issue
Block a user