WP Date: Add timezone abbreviation to wp-date settings.

Props mkaz.
Fixes #50624.

Built from https://develop.svn.wordpress.org/trunk@49083


git-svn-id: http://core.svn.wordpress.org/trunk@48845 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Helen Hou-Sandí 2020-10-01 17:43:08 +00:00
parent 69b9b23c49
commit e9d572f431
2 changed files with 12 additions and 2 deletions

View File

@ -323,6 +323,15 @@ function wp_default_packages_inline_scripts( $scripts ) {
) )
); );
// Calculate the timezone abbr (EDT, PST) if possible.
$timezone_string = get_option( 'timezone_string', 'UTC' );
$timezone_abbr = '';
if ( ! empty( $timezone_string ) ) {
$timezone_date = new DateTime( null, new DateTimeZone( $timezone_string ) );
$timezone_abbr = $timezone_date->format( 'T' );
}
$scripts->add_inline_script( $scripts->add_inline_script(
'wp-date', 'wp-date',
sprintf( sprintf(
@ -355,7 +364,8 @@ function wp_default_packages_inline_scripts( $scripts ) {
), ),
'timezone' => array( 'timezone' => array(
'offset' => get_option( 'gmt_offset', 0 ), 'offset' => get_option( 'gmt_offset', 0 ),
'string' => get_option( 'timezone_string', 'UTC' ), 'string' => $timezone_string,
'abbr' => $timezone_abbr,
), ),
) )
) )

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.6-alpha-49082'; $wp_version = '5.6-alpha-49083';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.