-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why sonata admin datepicker is not getting dates with september in spanish #362
Comments
### Update |
Hi, I've encountered this issue and I have some steps to replicate the issue in pure PHP and I kind of know why it happens, but not how to solve it. So, basically, Sonata relies on In Spanish, the ICU standard expects the month of September in Here is a single script where you can see how it works with <?php
$dateFormat = \IntlDateFormatter::MEDIUM;
$timeFormat = \IntlDateFormatter::NONE;
$timezone = "Europe/Berlin";
if (class_exists('IntlTimeZone', false)) {
$timezone = \IntlTimeZone::createTimeZone($timezone);
}
$calendar = \IntlDateFormatter::GREGORIAN;
$pattern = null;
$locale = 'es';
$intlDateFormatter = new \IntlDateFormatter($locale, $dateFormat, $timeFormat, $timezone, $calendar, $pattern);
$intlDateFormatter->setLenient(false);
$dates = ["12 sept. 2019", "12 sep. 2019",];
foreach ($dates as $date) {
$data = $intlDateFormatter->parse($date);
print_r($data);
print "\n";
if (!$data) {
print_r($intlDateFormatter->getErrorMessage());
print "\n";
}
}
print $intlDateFormatter->format(1568332800);
print "\n"; This is the why it is happening. But I am not sure from where it comes. It could be PHP, as It could be in the javascript date picker, as javascript usually generates var event = new Date(2019, 8, 12, 14, 39, 7);
console.log(event.toDateString()); |
By default, the date format used is |
…mit dates without extra configuration. See: https://github.com/sonata-project/SonataAdminBundle/issues/5235
maybe @ro0NL our Intl-Expert can help us out here 🤔 |
…mit dates without extra configuration. See: https://github.com/sonata-project/SonataAdminBundle/issues/5235
The This I do not know where is the I do not know if it is a backwards compatibility issue of Symfony, as I have inherited this project and we have not changed the version of Symfony or Sonata. On the other hand, the original report of the issue was from a year ago, so it does not seem to be due to a recent change. |
I do not know how Sonata sets up the form type at all, but having some Intl date formatter involved when talking about a date picker looks at least a bit suspicious to me. Is there a special reason not to use the HTML datetime format for the data exchange (which as an added bonus would also allow to fall back to an HTML5 datepicker when JavaScript is disabled)? |
The default DatePicker form type of Sonata includes this javascript date picker. You can see the documentation here: https://sonata-project.org/bundles/core/master/doc/reference/form_types.html#datepickertype-datetimepickertype
Here is the library: https://github.com/Eonasdan/bootstrap-datetimepicker |
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Still relevant and not solved |
With format Long it also doesnt work (even other months stop working) |
Wanna work on this @bochkarev-artem ? |
If this is a problem, I think the issue is in the way the comparison is implemented. @DavidHernandez, could you please elaborate this affirmation regarding the ICU standard?
|
You could check if the right "locale" option is passed to $view->vars['dp_options'] = $dpOptions; since this option is intended to provide the "locale" option in the template: $('#{{ datepicker_use_button ? 'dp_' : '' }}{{ id }}').datetimepicker({{ dp_options|json_encode|raw }}); |
Looking at bootstrap datepicker, its clear that Hardcoding language doesnt take any effect. Here i print content of |
Maybe this fixes the issue: #427 Since we are jumping 3 majors and its not even using same library (moment was dropped on the date picker) this issue will be closed. If the problem persist, we should update a bit the issue to reflect how it is seen with the new version. |
Environment
Sonata packages
Symfony packages
PHP version
Subject
When I send any day of any year with september as a month it's not getting the date.
Steps to reproduce
First I make a composer update.
I'm using sonata admin and setted up the config file with:
and
Expected results
Actual results
The text was updated successfully, but these errors were encountered: