Skip to content

[Form] Add DateType IntlCalendar option. #53894

Closed
@jan-pintr

Description

@jan-pintr

Description

Recently I required to render DateType in format with week of year [1] (week 13 of year 2024: 2023-03-31 2024w13) with independent IntlCalendar specification than provided from currently set Locale.

For example when project (default) locale is en_US (en). But you need to output in "European's format" it is not possible with current implementation. You would get 2023-03-31 2024w14, because first day of week configuration is taken from currently set locale.

It would be nice to have for example calendar option in DateType with something like this:

$calendar = \IntlCalendar::createInstance();
$calendar->setFirstDayOfWeek(\IntlCalendar::DOW_MONDAY);
$calendar->setMinimalDaysInFirstWeek(4);

$form->add('with_week', DateType::class, [
    'format' => "y-MM-dd y'w'w",
    'calendar' => $calendar,          
]);

[1] https://unicode.org/reports/tr35/tr35-dates.html#Date_Patterns_Week_Of_Year

Example

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions