Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Validator] Timezone passing to IntlDateFormatter breaks when using ISO8601 zulu times #33901

Copy link
Copy link
Closed
@sjdaws

Description

@sjdaws
Issue body actions

Symfony version(s) affected: 4.3.5

Description
The validator update in 4.3.5 passes the timezone from the DateTime object to IntlDateFormatter which breaks when using zulu timestamps (YYYY-MM-DDTHH:MM:SSZ).

How to reproduce
Extend constraint validator and attempt to validate a zulu timestamp as PRETTY_DATE:

<?php

use \DateTime;
use \Symfony\Component\Validator\Constraint;
use \Symfony\Component\Validator\ConstraintValidator;

class TestValidator extends ConstraintValidator
{
    public function __construct()
    {
        $dateTime = new DateTime('2022-12-12T08:30:42Z');

        // This will throw a fatal error
        $this->formatValue($dateTime, ConstraintValidator::PRETTY_DATE);
    }

    public function validate($value, Constraint $constraint)
    {
    }
}

Possible Solution
Check the validity of the timezone before passing it to IntlDateFormatter.

Additional context
Error returned:

IntlException : datefmt_create: time zone id 'Z' extracted from ext/date DateTimeZone not recognized: U_ILLEGAL_ARGUMENT_ERROR

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.