Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DST correction
#1
I notice my time was off an hour on the forums and I checked my options as well as the default DST setting for the board. These were set correctly. If the DST option is checked in the user CP, it will add an hour regardless. If you open inc/functions.php and go to line 280, you find the var $offset++ is set when the user has DST enabled. This should only increment in the Spring. Adding a conditional to test for DST fixes this.

Code:
date( 'I' ) tests false until April 2008.

replace:

$offset++;

with:

if ( date( 'I' ) )
{
    $offset++;
}
Reply
#2
while using date('I') will work for the server (eg default time zone), you cannot use it for users. Different places have different rules regarding daylight savings (when to start, when to stop, or whether to observe at all).

The best way to accomplish what you propose is to store the name of the timezone (eg America/Denver) and use PEAR packages to deal with it.
Reply
#3
The "Enable Daylight Savings Time correction" option essentially treats the user time as observing DST if enabled. If left enabled, it supplies the offset regardless of DST ending. date('I') simply tells me that we are not in DST and if the option is enabled, it shouldn't "spring forward" until March 08. Users in areas that don't observe DST shouldn't enable the correction.
Reply
#4
date('I') says whether the timezone the server itself is currently observing daylight savings time. What you really want to do is check to see if the user's timezone is currently observing DST, which should be true for most of the southern hemisphere and false for most of the northern hemisphere.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)