]> git.ipfire.org Git - thirdparty/AWStats.git/commitdiff
LogFormat timezone ISO 8601 support update: make whole timezone part optional, and...
authorBostjan Skufca <bostjan@a2o.si>
Thu, 30 Jul 2015 17:21:54 +0000 (17:21 +0000)
committerBostjan Skufca <bostjan@a2o.si>
Thu, 30 Jul 2015 17:21:54 +0000 (17:21 +0000)
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.

wwwroot/cgi-bin/awstats.pl

index c9dcee9ad9173ffa2fcb981909fa85e3e4558455..d715c53a8eecfa14d3939b5faa8704b3fd8f5a71 100755 (executable)
@@ -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