[wp-trac] [WordPress Trac] #44985: timezone_string should be valid when offset time zone mode is used
WordPress Trac
noreply at wordpress.org
Mon Sep 24 12:45:34 UTC 2018
#44985: timezone_string should be valid when offset time zone mode is used
-------------------------+------------------------------------------
Reporter: Rarst | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Date/Time | Version: trunk
Severity: normal | Keywords: needs-patch needs-unit-tests
Focuses: |
-------------------------+------------------------------------------
`timezone_string` time zone settings mode is backwards compatible,
overriding `gmt_offset` mode with correct offset:
{{{#!php
// Kiev
var_dump( get_option( 'gmt_offset' ), get_option( 'timezone_string' ) );
// float(3) string(11) "Europe/Kiev"
}}}
However the reverse isn't true, if settings are in offset mode the time
zone string is empty and invalid:
{{{#!php
// UTC+3
var_dump( get_option( 'gmt_offset' ), get_option( 'timezone_string' ) );
// string(1) "3" string(0) ""
}}}
In part this is because on older PHP versions there is no valid string
that would correspond to an hours offset. But from PHP 5.5.10 it would
work with timezone strings in `+03:00` format just fine.
I think generating valid time zone strings in offset mode for new PHP
versions is low hanging and makes things much more robust for downstream
developers, making it harder for them to unknowingly screw up by relying
on `timezone_string` alone.
We still need unified timezone retrieval in #24730, but that doesn't
displace making `timezone_string` by itself more reliable.
Will work on a patch.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44985>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list