Make WordPress Core

Opened 2 years ago

Closed 14 months ago

#55577 closed defect (bug) (duplicate)

Wrong Date Format on jQuery UI datepicker on the public side of Jetpack forms for Localized sites

Reported by: miguelsansegundo's profile miguelsansegundo Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: I18N Keywords:
Focuses: ui Cc:


There is an issue on the public side showing the wrong date format for escaped literal text such as \d\e in the date format j \d\e F \d\e Y when internationalizing the input value of the jQuery UI datepicker. Which is used by Jetpack forms.

The literal text de is common in the date format of Spain and Portugal. For instance in 15 de Abril de 2022.

Here is a screenshot of the issue showing the wrong format on the datepicker input on the public side.

As you can see, the issue doesn't affect the dates rendered via PHP because the backward slashes are the correct format in that case.

The issue doesn't affect the settings either. Only affects the jQuery UI datepicker on the public side.

The issue happens because we use backward slashes to escape literal text when formatting custom dates in WordPress but the datepicker of jQuery UI only accepts single quotes to scape literal text in the date format. It seems that in the past both syntaxes were supported but nowadays with the latest versions the backward slashes don't work.

The dateFormat together with other localizations for the datepicker of jQuery UI is passed in a script in the HTML document thanks to the WordPress core function wp_localize_jquery_ui_datepicker.

I believe this is not the responsibility of jQuery UI, or Jetpack, but the WordPress core function wp_localize_jquery_ui_datepicker that introduces two bugs:

  1. Replaces d by dd when converting the PHP date format into jQuery UI's format not excluding escaped literal text when it should because \d should not be converted into \dd.
  2. Does not convert the PHP date format for escaped literal text \d with backward slash into the supported jQuery UI's date format, which uses single quotes 'de'.

Change History (1)

#1 @swissspidy
14 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Looks like this can be improved as part of #39756

Note: See TracTickets for help on using tickets.