Hi,

I encountered a problem with the calender of Drupal. Bear in mind I am a newbie with some programming background (25 years). I have to say that PHP is new for me. I am studying it for several months now.

The problem
I saw that the current day on the calender was 1 day ahead. It was after 10 o'clock local time so I expected it to be a timezone problem. I checked it and the timezone was OK. I must be +0200 hour to match my local time. So no solution there.

So I searched for the code. I found the code in the Archieve Module. This is the code:

// Extract today's date:
  $offset = time() + $user->timezone;
  $start_of_today = mktime(0, 0, 0, date('n', $offset), date('d', $offset), date('Y', $offset)) + $user->timezone;
  $end_of_today = mktime(23, 59, 59, date('n', $offset), date('d', $offset), date('Y', $offset)) + $user->timezone;

I noticed that the variable $offset contains the timezone difference added to the time. Right? If we take a closer look you can see that $start_of_today contains ruffly the $offset (time + timezone remember?) and the timezone is added again. That is 2 times the timezone. Right? The same counts for the variable $end_of_today.

If I am correct that means with a timezone of 0200 hours in this case the time will be +0400 hours. Correct? I corrected it by removing the first $user->timezone.

This row has become:

$offset = time();
$start_of_today = mktime(0, 0, 0, date('n', $offset), date('d', $offset), date('Y', $offset)) + $user->timezone;
  $end_of_today = mktime(23, 59, 59, date('n', $offset), date('d', $offset), date('Y', $offset)) + $user->timezone;

It seems to work OK now. Anyone of development can comment on this? Is this a bug? I found the same code also in Drupal 4.5.

Grtz. Henk [pd5dp]
http://pd5dp.ham-radio.ch
pd5dp@amsat.org

Comments

dries’s picture

Please file a bug report and attach a patch. Makes it easier to test.

Stefan Nagtegaal’s picture

Filed a bug report and made a patch.. Tested the approach and it seems to work fine..

pss0ft’s picture

Hi,

Ok, Dries. Someone else did it. See above this posting. He beat me to it. :-(

He submitted also a patch. It works the same as the one I had in mind. My adjustment was easier I think. Maybe his uses less code.

Grtz. Henk

WebSite powered by Drupal: http://pd5dp.ham-radio.ch
Other WebSite : http://www.qsl.net/pd5dp

Email:
pd5dp@amsat.org

dries’s picture

Committed the patch. Thanks.