Make WordPress Core

Changeset 47098


Ignore:
Timestamp:
01/21/2020 11:46:36 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Date/Time: In wp_maybe_decline_date(), add support for a range of days, e.g. February 21–23.

A potential use case is displaying multi-day events in the WordPress Events and News dashboard widget.

See #47798, #48934.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r47088 r47098  
    374374                if ( $decline ) {
    375375                        foreach ( $months as $key => $month ) {
    376                                 $months[ $key ] = '#\b' . preg_quote( $month, '#' ) . ' (\d{1,2})(st|nd|rd|th)?\b#u';
     376                                $months[ $key ] = '#\b' . preg_quote( $month, '#' ) . ' (\d{1,2})(st|nd|rd|th)?([-–]\d{1,2})?(st|nd|rd|th)?\b#u';
    377377                        }
    378378
    379379                        foreach ( $months_genitive as $key => $month ) {
    380                                 $months_genitive[ $key ] = '$1 ' . $month;
     380                                $months_genitive[ $key ] = '$1$3 ' . $month;
    381381                        }
    382382
  • trunk/tests/phpunit/tests/date/maybeDeclineDate.php

    r47079 r47098  
    4040         * @ticket 37411
    4141         * @ticket 48606
     42         * @ticket 48934
    4243         * @dataProvider data_wp_maybe_decline_date
    4344         */
    … …  
    7475                        array( 'ru_RU', 'F jS Y', 'Январь 1st 2016', '1 января 2016' ),
    7576                        array( 'ru_RU', 'F j Y', 'Январь 1 2016', '1 января 2016' ),
     77                        array( 'ru_RU', 'F j–j Y', 'Январь 1–2 2016', '1–2 января 2016' ),
    7678                        array( 'ru_RU', 'F j y', 'Январь 1 16', '1 января 16' ),
    7779                        array( 'ru_RU', 'F y', 'Январь 16', 'Январь 16' ),
Note: See TracChangeset for help on using the changeset viewer.