Opened 3 years ago
Closed 3 years ago
#13173 closed defect (bug) (duplicate)
get_date_from_gmt does not properly convert non-DST dates when DST is in effect and vice versa.
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Date/Time | Version: | 3.0 |
| Severity: | normal | Keywords: | reporter-feedback |
| Cc: |
Description
If it is May 1 where I am and daylight-savings time is in effect, and I schedule a post for December 1 at noon (when DST is not in effect) via XML-RPC using the date_created_gmt parameter, my post will actually be scheduled for December 1 at 1pm. This is due to the fact that get_date_from_gmt uses the current timezone offset to convert the date from GMT to local time rather than the timezone offset specific to the date it is converting.
The root issue I suppose is that get_option('gmt_offset') doesn't know when it's getting the gmt_offset for. Fixing that would probably fix a number of other daylight-savings time related issues in Wordpress.
Tested in Wordpress 2.9.2 and the current Wordpress.com.
Attachments (1)
Change History (6)
comment:1
solarissmoke
— 3 years ago
- Milestone changed from Unassigned to 3.1
- Version set to 3.0
solarissmoke
— 3 years ago
Idea for new function that allows getting gmt offset for a past/future timestamp, which is then called from get_date_from_gmt()
comment:3
in reply to:
↑ 2
solarissmoke
— 3 years ago
Replying to nacin:
Isn't this a duplicate of #9285?
Possibly, though they are related to different functions. The issue here is that get_date_from_gmt() assumes that the current timezone offset equals the timezone offset for whatever time-string it is given. The issue with #9825 is that get_gmt_from_date() is doing the same thing in reverse.
I think having a get_gmt_offset() function would help fix both of these, rather than having separate timezone-handling code in both of get_date_from_gmt() and get_gmt_from_date(). The main problem is that currently any use of get_option('gmt_offset') assumes that we're dealing with the present.
There is already a pre_option filter on gmt_offset that automatically adjusts the offset for daylight savings - only thing is it assumes you want to know the offset at the time of execution.
I don't think it would be too difficult to add an argument to wp_timezone_override_offset() that allows you to specify a future time for which to calculate an offset. Let me see if I can cobble something together.