From: Bostjan Skufca Date: Thu, 30 Jul 2015 17:21:54 +0000 (+0000) Subject: LogFormat timezone ISO 8601 support update: make whole timezone part optional, and... X-Git-Tag: AWSTATS_7_5~36^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f6d8cf152a785e7c5d4d50ad1ec46ed8d62007d;p=thirdparty%2FAWStats.git LogFormat timezone ISO 8601 support update: make whole timezone part optional, and support "...mm:ssZ" variation too This change completes support for ISO 8601 format specification by adding support for zero meridian notation ("Z" suffix only). Reason for making time zone optional: AWStats does not parse time zone info, log files are expected to be from single time zone only. Thus making whole TZ information optional makes the most sense if support for wide variety of date+time formats is our objective. --- diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl index c9dcee9a..d715c53a 100755 --- a/wwwroot/cgi-bin/awstats.pl +++ b/wwwroot/cgi-bin/awstats.pl @@ -9154,7 +9154,13 @@ sub DefinePerlParsingFormat { push @fieldlib, 'date'; $PerlParsingFormat .= "(\\d+)"; } - elsif ( $f =~ /%time5$/ ) { # yyyy-mm-ddThh:mm:ss+00:00 (iso format) or yyyy-mm-ddThh:mm:ss.000000Z + elsif ( $f =~ /%time5$/ ) { + # Supports the following formats: + # - yyyy-mm-ddThh:mm:ss (Incomplete ISO 8601) + # - yyyy-mm-ddThh:mm:ssZ (ISO 8601, zero meridian) + # - yyyy-mm-ddThh:mm:ss+00:00 (ISO 8601) + # - yyyy-mm-ddThh:mm:ss+0000 (Apache's best approximation to ISO 8601 using "%{%Y-%m-%dT%H:%M:%S%z}t" in LogFormat) + # - yyyy-mm-ddThh:mm:ss.000000Z (Amazon AWS log files) $pos_date = $i; $i++; push @fieldlib, 'date'; @@ -9162,7 +9168,7 @@ sub DefinePerlParsingFormat { $i++; push @fieldlib, 'tz'; $PerlParsingFormat .= -"([^$LogSeparatorWithoutStar]+T[^$LogSeparatorWithoutStar]+)([-+\.]\\d\\d[:\\.\\dZ]*)"; +"([^$LogSeparatorWithoutStar]+T[^$LogSeparatorWithoutStar]+)(Z|[-+\.]\\d\\d[:\\.\\dZ]*)?"; } # Special for methodurl and methodurlnoprot