[wp-trac] [WordPress Trac] #39991: jQuery UI Datepicker Localization Error with PHP date 'S'

WordPress Trac noreply at wordpress.org
Tue Feb 28 20:03:38 UTC 2017


#39991: jQuery UI Datepicker Localization Error with PHP date 'S'
---------------------------+-----------------------------
 Reporter:  devonto        |      Owner:
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Script Loader  |    Version:  4.7.2
 Severity:  normal         |   Keywords:
  Focuses:  javascript     |
---------------------------+-----------------------------
 When localising the datepicker, the UK default WordPress date format is
 not converted correctly to jQuery UI's format.

 The default PHP format for the UK is `jS F Y`

 The script-loader.php function `wp_localize_jquery_ui_datepicker()`
 converts this to `dS MM YY`, however the `S` is invalid and an ordinal
 suffix cannot be created with the datepicker.

 There is no easy solution to add in the ordinal suffix, but a better
 solution than printing the stray `S` is to strip this out by modifying the
 `str_replace()` function call to do so.


 {{{
         // Convert the PHP date format into jQuery UI's format.
         $datepicker_date_format = str_replace(
                 array(
                         'd', 'j', 'l', 'z', // Day.
                         'F', 'M', 'n', 'm', // Month.
                         'Y', 'y',           // Year.
                         'S'                 // Invalid
                 ),
                 array(
                         'dd', 'd', 'DD', 'o',
                         'MM', 'M', 'm', 'mm',
                         'yy', 'y',
                         ''
                 ),
                 get_option( 'date_format' )
         );
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39991>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list