First, just let me say that I don't have a clue what I'm talking about.
With that out of the way ...
Bugzilla has just started moving over to using TT for it's UI, and some
I went to install TT.
Everyone else had no problem installing it, but it wouldn't work for
me. The installation from CPAN kept falling over on the t/date tests.
The test that failed for me was:
-- test --
[% USE date %]
[% date.format('4:20:00 6-13-2000', '%H') %]
-- expect --
04
On my system, this came back with "05".
Now I couldn't find anything about this going wrong, and I know a bit of
Perl, so I went ferretting around files for about 2 hours and eventually
convinced myself that something was going on here in the Date plugin:
unless ($time =~ /^\d+$/) {
# if $time is numeric, then we assume it's seconds since the epoch
# otherwise, we try to parse it as a 'H:M:S D:M:Y' string
@date = (split(/(?:\/| |:|-)/, $time))[2,1,0,3..5];
return (undef, Template::Exception->new('date',
"bad time/date string: expects 'h:m:s d:m:y' got: '$time'"))
unless @date >= 6 && defined $date[5];
$date[4] -= 1; # correct month number 1-12 to range 0-11
$date[5] -= 1900; # convert absolute year to years since 1900
print join( ",", @date) . "\n";
$time = &POSIX::mktime(@date);
}
Because @date originally only has 6 members, the extra 3 get filled in
with 0. So having read the mktime man page, I added another statement
right after the @date assignment:
@date = (@date, 0, 0, -1);
This made it work.
For some reason, if my DST if specified as 0 (which I believe is off),
it doesn't work, even though I'm not in DST. Yet if I specify 1 it
works.
Northern hemisphere developers in DST seem to get "03" when they have 1,
and the correct answer for 0.
Why you have to specify the incorrect DST to get the correct time is
beyond me at this point, but leaving it unspecified with -1 seems to
work.
So basically, this seems to either fall over for people not in DST (in
which case if I'm right you'd better fix it fast =) ). Still, I find it
hard to believe that everyone using TT is currently in DST.
--
Matthew Tuck: Software Developer & All-Round Nice Guy
My Short Autobiography: 1985 Grade Bin Monitor 1990 Class Clown Award
1992 Awarded Most Likely To Spontaneously Combust 1996 Crowned Galactic
Emperor 1998 Released From Smith Psychiatric Hospital