Set TimeZone configuration directive to +00 by default to force

SquidAnalyzer to use localtime. If this directive is commented
then SquidAnalyzer will autodetect the timezone and apply it to
all timestamp found. If the directive is set to an other timezone
value, this is this value that will be applied.
This commit is contained in:
Gilles Darold 2019-07-12 21:54:13 +02:00
parent 6b9ae0571c
commit 1cdee5fed1
2 changed files with 8 additions and 4 deletions

View File

@ -1649,10 +1649,13 @@ sub _init
# Set default timezone # Set default timezone
$self->{TimeZone} = (0-($options{TimeZone} || $timezone || 0))*3600; $self->{TimeZone} = (0-($options{TimeZone} || $timezone || 0))*3600;
if (!$self->{TimeZone}) { if (!$self->{TimeZone} && $options{TimeZone} eq '') {
my @lt = localtime(); my @lt = localtime();
# count TimeZone and Daylight Saving Time # count TimeZone and Daylight Saving Time
$self->{TimeZone} = timelocal(@lt) - timegm(@lt); $self->{TimeZone} = timelocal(@lt) - timegm(@lt);
print STDERR "DEBUG: using autodetected timezone $self->{TimeZone}\n" if ($debug);
} else {
print STDERR "DEBUG: using timezone $self->{TimeZone}\n" if ($debug);
} }
# Cleanup old temporary files # Cleanup old temporary files
@ -6248,7 +6251,7 @@ sub parse_config
$self->localdie("ERROR: unknown image format. See option: ImgFormat\n"); $self->localdie("ERROR: unknown image format. See option: ImgFormat\n");
} }
if ($opt{TimeZone} && $opt{TimeZone} !~ /^[+\-]\d{1,2}$/) { if (defined $opt{TimeZone} && $opt{TimeZone} !~ /^[+\-]\d{1,2}$/) {
$self->localdie("ERROR: timezone format: +/-HH, ex: +01. See option: TimeZone\n"); $self->localdie("ERROR: timezone format: +/-HH, ex: +01. See option: TimeZone\n");
} }

View File

@ -179,8 +179,9 @@ TopUrlUser 10
# Adjust timezone to use when SquidAnalyzer reports different time than graphs # Adjust timezone to use when SquidAnalyzer reports different time than graphs
# in your browser. The value must follow format: +/-HH. Default is to use local # in your browser. The value must follow format: +/-HH. Default is to use local
# time. This must be considered as real timezone but the number of hours to add # time. This must be considered as real timezone but the number of hours to add
# remove from log timestamp to adjust graphs times. # remove from log timestamp to adjust graphs times. Set to +00 to use localtime
#TimeZone +01 # otherwise if commented SquidAnalyzer will autodetect the timezone and apply it.
TimeZone +00
# Enable this directive if you want to include port number into Url statistics. # Enable this directive if you want to include port number into Url statistics.
# Default is to remove the port information from the Url. # Default is to remove the port information from the Url.