Hateburo: kazeburo hatenablog

Operations Engineer / Site Reliability / 運用系小姑 / Perl Monger

Apache::LogFormat::Compiler v0.22 has been released. Fixed bug around DST

Apache::LogFormat::Compiler v0.22 has been released

cpan: https://metacpan.org/release/Apache-LogFormat-Compiler
github: https://github.com/kazeburo/Apache-LogFormat-Compiler

Fixed bug around Daylight Saving Time(DST).
Older version shows incorrect timezone offset, not incorporating DST.

use Time::Local;
use POSIX;
use HTTP::Message::PSGI;
use Apache::LogFormat::Compiler;
use HTTP::Request::Common;

local $ENV{TZ} = 'America/New_York';
POSIX::tzset;
my $time = timelocal(0, 0, 1, 3, 11 - 1, 2013); 

my $log_handler = Apache::LogFormat::Compiler->new();
my $req = req_to_psgi(GET "/");
my $res = [200,[],[q!OK!]];

print $log_handler->log_line($req,$res,0,2,$time);
print $log_handler->log_line($req,$res,0,2,$time+3599);
print $log_handler->log_line($req,$res,0,2,$time+3600);

__DATA__
127.0.0.1 - - [03/Nov/2013:01:00:00 -0400] "GET / HTTP/1.1" 200 0 "-" "-"
127.0.0.1 - - [03/Nov/2013:01:59:59 -0400] "GET / HTTP/1.1" 200 0 "-" "-"
127.0.0.1 - - [03/Nov/2013:01:00:00 -0500] "GET / HTTP/1.1" 200 0 "-" "-"

Many Thanks dex4er.

Apache::LogFormat::Compilerのいわゆるサマータイムのバグを直しました。サマータイムのないJSTには影響ありません