#2189 closed defect (bug) (fixed)
Calendar Stuck on December 2005
Reported by: | macmanx | Owned by: | markjaquith |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.0 |
Component: | Template | Keywords: | calendar has-patch commit |
Focuses: | Cc: |
Description
On two WP v2.0 blogs, I am using the "get_calendar()" template tag to display a monthly calendar on an archives list page (based off of the Default Theme's Archives page template). Typically, this calendar would always move on to the next month as soon as I created a post for the new month. I just made a post this morning at 1:01AM. So, typically, the calendar should have moved on to January 2006. Unfortunately, it is apparently stuck on December 2005.
In this forum thread, "Artemis" reported that the calendars on all of his blogs, three WP v1.5.2 blogs and one WP v2.0 blog, are stuck on December 2005. Artemis is also hearing similar reports of stuck calendars from a WordPress-related email group.
Attachments (2)
Change History (14)
#2
@
19 years ago
Yes, it looks like my calendar finally switched over to January 2006 sometime between now and 1AM. I'll leave this open in case you still think that this is a problem.
#3
@
19 years ago
Oops, I forgot to add that my server is on Eastern Standard Time (UTC/GMT -5 hours), and I'm on Pacific Standard Time (UTC/GMT -8 hours), so the server was in January 2006 long before I made that post at 1:01AM.
#4
@
19 years ago
In template-functions-general.php, the get_calendar() function, we see these two lines:
$thisyear = gmdate('Y', current_time('timestamp') + get_settings('gmt_offset') * 3600);
$thismonth = gmdate('m', current_time('timestamp') + get_settings('gmt_offset') * 3600);
We can see it is applying the gmt_offset correction, however meanwhile it use "current_time()" instead of "time()". In current_time the gmt_offset() is already applied, cause double offset.
That will make calendar jump too early to next month/year in the UTC+X timezone, and stuck in UTC-X timezone for a while.
The bug is in both 1.5.2 and 2.0.
The solution should be changing the two lines to
$thisyear = gmdate('Y', current_time('timestamp'));
$thismonth = gmdate('m', current_time('timestamp'));
Piece of a cake, but I'm new here so I'll have to learn how to submit changes first.
#6
@
19 years ago
- Keywords bg|commit added
If you're wanting to know about how the bug process goes on around here, you should read http://asymptomatic.net/2005/12/03/2142/how-to-patch-wordpress/. Pick out the bits that are relevant to you, it's mostly aimed at people with no server set up.
#7
@
18 years ago
- Owner changed from anonymous to markjaquith
- Status changed from new to assigned
Just updating this for the renamed 2.1 file, and giving it my +1. The description is accurate, current_time() already does the offset.
If there is another 2.0.x release (likely not, but IF), we can put this in /branches/2.0/ at that point.
#8
@
18 years ago
- Keywords has-patch commit added; bg|has-patch bg|commit removed
- Milestone changed from 2.1 to 2.0.5
According to markjaquith this is a candidate for 2.0.5.
Argh, it's like Y2K all over again :) This might be a problem with timezones, can you see if changes after a few hours? Like, tomorrow? In the mean time I'll have a look at the code.