Ticket #2189 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

Calendar Stuck on December 2005

Reported by: macmanx Assigned to: markjaquith
Priority: normal Milestone:
Component: Template Version: 2.0
Severity: normal Keywords: calendar has-patch commit
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

template-functions-general.php.diff (0.7 kB) - added by priv on 01/03/06 05:24:42.
fix for Ticket#2189
calendar_double_offset_fix.diff (0.7 kB) - added by markjaquith on 08/07/06 06:15:29.
Updated patch for 2.1

Change History

01/01/06 13:54:50 changed by davidhouse

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.

01/01/06 19:30:54 changed by macmanx

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.

01/01/06 19:36:22 changed by macmanx

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.

01/03/06 02:25:50 changed by priv

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.

01/03/06 05:24:42 changed by priv

  • attachment template-functions-general.php.diff added.

fix for Ticket#2189

01/03/06 05:34:17 changed by priv

  • keywords changed from calendar to calendar bg|has-patch.
  • milestone set to 2.1.

01/05/06 21:27:43 changed by davidhouse

  • keywords changed from calendar bg|has-patch to calendar bg|has-patch bg|commit.

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.

08/07/06 06:15:29 changed by markjaquith

  • attachment calendar_double_offset_fix.diff added.

Updated patch for 2.1

08/07/06 06:17:32 changed by markjaquith

  • 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.

10/06/06 11:04:30 changed by Nazgul

  • keywords changed from calendar bg|has-patch bg|commit to calendar has-patch commit.
  • milestone changed from 2.1 to 2.0.5.

According to markjaquith this is a candidate for 2.0.5.

10/06/06 11:22:45 changed by markjaquith

  • status changed from assigned to closed.
  • resolution set to fixed.

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

10/06/06 11:24:28 changed by markjaquith

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

11/30/06 19:41:51 changed by

  • milestone deleted.

Milestone 2.0.5 deleted