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. git-svn-id: https://develop.svn.wordpress.org/trunk@47098 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
1bf8b94129
commit
af39b30e28
@ -373,11 +373,11 @@ function wp_maybe_decline_date( $date, $format = '' ) {
|
||||
|
||||
if ( $decline ) {
|
||||
foreach ( $months as $key => $month ) {
|
||||
$months[ $key ] = '#\b' . preg_quote( $month, '#' ) . ' (\d{1,2})(st|nd|rd|th)?\b#u';
|
||||
$months[ $key ] = '#\b' . preg_quote( $month, '#' ) . ' (\d{1,2})(st|nd|rd|th)?([-–]\d{1,2})?(st|nd|rd|th)?\b#u';
|
||||
}
|
||||
|
||||
foreach ( $months_genitive as $key => $month ) {
|
||||
$months_genitive[ $key ] = '$1 ' . $month;
|
||||
$months_genitive[ $key ] = '$1$3 ' . $month;
|
||||
}
|
||||
|
||||
$date = preg_replace( $months, $months_genitive, $date );
|
||||
|
@ -39,6 +39,7 @@ class Tests_Functions_MaybeDeclineDate extends WP_UnitTestCase {
|
||||
* @ticket 36790
|
||||
* @ticket 37411
|
||||
* @ticket 48606
|
||||
* @ticket 48934
|
||||
* @dataProvider data_wp_maybe_decline_date
|
||||
*/
|
||||
public function test_wp_maybe_decline_date( $test_locale, $format, $input, $output ) {
|
||||
@ -73,6 +74,7 @@ class Tests_Functions_MaybeDeclineDate extends WP_UnitTestCase {
|
||||
array( 'ru_RU', 'j F Y', '1 Январь 2016', '1 января 2016' ),
|
||||
array( 'ru_RU', 'F jS Y', 'Январь 1st 2016', '1 января 2016' ),
|
||||
array( 'ru_RU', 'F j Y', 'Январь 1 2016', '1 января 2016' ),
|
||||
array( 'ru_RU', 'F j–j Y', 'Январь 1–2 2016', '1–2 января 2016' ),
|
||||
array( 'ru_RU', 'F j y', 'Январь 1 16', '1 января 16' ),
|
||||
array( 'ru_RU', 'F y', 'Январь 16', 'Январь 16' ),
|
||||
array( 'ru_RU', 'l, d F Y H:i', 'Суббота, 19 Январь 2019 10:50', 'Суббота, 19 января 2019 10:50' ),
|
||||
|
Loading…
Reference in New Issue
Block a user