WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#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)

template-functions-general.php.diff (669 bytes) - added by priv 8 years ago.
fix for Ticket#2189
calendar_double_offset_fix.diff (670 bytes) - added by markjaquith 8 years ago.
Updated patch for 2.1

Download all attachments as: .zip

Change History (13)

comment:1 davidhouse8 years ago

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.

comment:2 macmanx8 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.

comment:3 macmanx8 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.

comment:4 priv8 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.

priv8 years ago

fix for Ticket#2189

comment:5 priv8 years ago

  • Keywords bg|has-patch added
  • Milestone set to 2.1

comment:6 davidhouse8 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.

markjaquith8 years ago

Updated patch for 2.1

comment:7 markjaquith8 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.

comment:8 Nazgul8 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.

comment:9 markjaquith8 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [4350]) avoid double time offset in calendar. props to priv. fixes #2189

comment:10 markjaquith8 years ago

(In [4351]) avoid double time offset in calendar. props to priv. fixes #2189

comment:11 anonymous7 years ago

  • Milestone 2.0.5 deleted

Milestone 2.0.5 deleted

Note: See TracTickets for help on using tickets.