bug #28704 [Form] fix multi-digit seconds fraction handling (xabbuh)

This PR was merged into the 2.8 branch.

Discussion
----------

[Form] fix multi-digit seconds fraction handling

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Commits
-------

7b920c1ec5 fix multi-digit seconds fraction handling
This commit is contained in:
Fabien Potencier 2018-10-10 02:33:33 -07:00
commit 270f496c0c
2 changed files with 2 additions and 1 deletions

View File

@ -69,7 +69,7 @@ class DateTimeToRfc3339Transformer extends BaseDateTimeTransformer
return;
}
if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})T\d{2}:\d{2}(?::\d{2})?(?:\.\d)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))$/', $rfc3339, $matches)) {
if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})T\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))$/', $rfc3339, $matches)) {
throw new TransformationFailedException(sprintf('The date "%s" is not a valid date.', $rfc3339));
}

View File

@ -67,6 +67,7 @@ class DateTimeToRfc3339TransformerTest extends TestCase
array('UTC', 'UTC', '2010-02-03 04:05:00 UTC', '2010-02-03T04:05Z'),
array('America/New_York', 'Asia/Hong_Kong', '2010-02-03 04:05:00 America/New_York', '2010-02-03T17:05+08:00'),
array('Europe/Amsterdam', 'Europe/Amsterdam', '2013-08-21 10:30:00 Europe/Amsterdam', '2013-08-21T08:30:00Z'),
array('UTC', 'UTC', '2018-10-03T10:00:00.000Z', '2018-10-03T10:00:00.000Z'),
));
}