Problem Description
%SEARCH{date=<interval>}%
does not handle the DST setting correctly when the timezone is GMT. Instead the topic's date matching is out by an hour.
Here is a demo of the relevant Perl code from the command line,
# ( cd twiki/lib && perl -I$PWD -M"TWiki::Time" -e '@a = TWiki::Time::parseInterval("2012-11-14T01:42:28/2012-11-21T02:43:00"); print "$a[0] to $a[1]\n"' )
1352853748 to 1353462180
# find twiki/data/Sandbox/LogBookNovemberEntry0001.txt -printf "%T@ %t %TZ %f\n"
1352857348 Wed Nov 14 01:42:28 2012 GMT LogBookNovemberEntry0001.txt
The find command illustrates the correct epoch value for Wed Nov 14 01:42:28 2012 GMT which is also used in the first field of the interval passed to TWiki::Time::parseInterval(). The epoch returned by TWiki::Time::parseInterval() is 3600 seconds behind the correct value from the find comand.
Problem Analysis
The problem arises because the method used to calculate the timezone offset (from GMT) fails when the timezone is GMT. The problem is in lib/TWiki/Time.pm. Here is a demo which should return 0 but returns -3600
# perl -M"Time::Local" -e 'print &Time::Local::timelocal(0, 0, 0, 1, 0, 70),"\n"'
-3600
Problem bugfix
The attached patch fixes the problem. Here is a demo after applying this patch
TWiki_Time_tzadj_patch.txt. The epoch returned is now the same as the correct value from the find command above.
( cd twiki/lib && perl -I$PWD -M"TWiki::Time" -e '@a = TWiki::Time::parseInterval("2012-11-14T01:42:28/2012-11-21T02:43:00"); print "$a[0] to $a[1]\n"' )
1352857348 to 1353465780
Tom Crane (Email: T dot Crane at rhul dot ac dot uk)
--
TWiki:Main/TomCrane - 2012-11-30
Thank you Tom for reporting a bug
with patch to fix it!
This is now in SVN trunk and 5.1 branch.
--
TWiki:Main.PeterThoeny - 2012-11-30