I noticed that when searching for tickets that have a due date on a given
date, the searched date is wrong by one day.
The problem lies in the timezone handling and how the range for the day
In Tickets_Overlay.pm there is the following code:
if we’re specifying =, that means we want everything on a
particular single day. in the database, we need to check for >
and < the edges of that day.
my $daystart = strftime( “%Y-%m-%d %H:%M”,
gmtime( $time - ( $time % 86400 ) ) );
my $dayend = strftime( “%Y-%m-%d %H:%M”,
gmtime( $time + ( 86399 - $time % 86400 ) ) );
Note that when you enter a date, it is parsed in the local time zone (which is
a good thing to do) and, unless you specify it, the time is set to 00:00:00.
So, if you search for 2006-04-14 in my timezone (+0200), it will be parsed as
2006-04-14 00:00:00 +0200. The Unix time is however stored in UTC, so
internally it is 2006-04-13 22:00:00 +0000. Using the above formulas, it gives:
daystart = 2006-04-13 00:00:00 +0000
dayend = 2006-04-13 23:59:59 +0000
… which is not what I expect when searching.
The attached patch fixes this problem.
PS: Even better would be not to use the Unix time directly but instead
use a module like Date::Calc.
David Schweikert | phone: +41 44 632 7019
System manager ISG.EE | walk: ETH Zentrum, ETL F24.1
ETH Zurich, Switzerland | web: http://people.ee.ethz.ch/dws
Tickets_Overlay.pm.patch (931 Bytes)