Skip to content

Commit

Permalink
Remove bloat that duplicates %z functionality.
Browse files Browse the repository at this point in the history
On 09/12/2009 09:26 PM, Mike Heins wrote:
> Quoting Peter (peter@pajamian.dhs.org):
>> Incidentally why the mess of code in Util.pm to get the same result that
>> %z would give anyways?
>
> Probably because I was stupid when I wrote it, and didn't understand what
> %z did. Or I did it before %z became standard.
>
> It should be changed.
  • Loading branch information
pajamian committed Sep 13, 2009
1 parent b0f731a commit 2ced36a
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions lib/Vend/Util.pm
Expand Up @@ -206,30 +206,9 @@ sub tabbed {
} @_);
}

# Finds common-log-style offset
# Unproven, authoratative code welcome
my $Offset;
FINDOFFSET: {
my $now = time;
my ($gm,$gh,$gd,$gy) = (gmtime($now))[1,2,5,7];
my ($lm,$lh,$ld,$ly) = (localtime($now))[1,2,5,7];
if($gy != $ly) {
$gy < $ly ? $lh += 24 : $gh += 24;
}
elsif($gd != $ld) {
$gd < $ld ? $lh += 24 : $gh += 24;
}
$gh *= 100;
$lh *= 100;
$gh += $gm;
$lh += $lm;
$Offset = sprintf("%05d", $lh - $gh);
$Offset =~ s/0(\d\d\d\d)/+$1/;
}

# Returns time in HTTP common log format
sub logtime {
return POSIX::strftime("[%d/%B/%Y:%H:%M:%S $Offset]", localtime());
return POSIX::strftime("[%d/%B/%Y:%H:%M:%S %z]", localtime());
}

sub format_log_msg {
Expand Down

0 comments on commit 2ced36a

Please sign in to comment.