Skip to content

Commit

Permalink
WP Date: Add timezone abbreviation to wp-date settings.
Browse files Browse the repository at this point in the history
Props mkaz.
Fixes #50624.


git-svn-id: https://develop.svn.wordpress.org/trunk@49083 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
helen committed Oct 1, 2020
1 parent f60aa51 commit 7cca745
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/wp-includes/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
'wp-date',
sprintf(
Expand Down Expand Up @@ -355,7 +364,8 @@ function wp_default_packages_inline_scripts( $scripts ) {
),
'timezone' => array(
'offset' => get_option( 'gmt_offset', 0 ),
'string' => get_option( 'timezone_string', 'UTC' ),
'string' => $timezone_string,
'abbr' => $timezone_abbr,
),
)
)
Expand Down

0 comments on commit 7cca745

Please sign in to comment.