Просмотр исходного кода

Correctly fix all problems with timeoffsets, do the time addition/subtraction in Logfile.pm

Morten Brix Pedersen 24 лет назад
Родитель
Сommit
4065a593ab
2 измененных файлов с 24 добавлено и 27 удалено
  1. 1 24
      modules/Pisg/HTMLGenerator.pm
  2. 23 3
      modules/Pisg/Parser/Logfile.pm

+ 1 - 24
modules/Pisg/HTMLGenerator.pm

@@ -315,8 +315,6 @@ sub _activetimes
             $size = 1.0;
         }
 
-        $hour = $self->_adjusttimeoffset($hour);
-
         $image = "pic_v_".(int($hour/6)*6);
         $image = $self->{cfg}->{$image};
 
@@ -341,7 +339,7 @@ sub _activetimes
     $toptime[0] =~ s/0(\d)/$1/;
 
     for ($b = 0; $b < 24; $b++) {
-        if ($self->_adjusttimeoffset($toptime[0]) == $b) {
+        if ($toptime[0] == $b) {
             # Highlight the top time
             $class = 'hirankc10center';
         } else {
@@ -1660,27 +1658,6 @@ sub _mostnicks
     }
 }
 
-sub _adjusttimeoffset
-{
-    my $self = shift;
-    my $hour = shift;
-
-    if ($self->{cfg}->{timeoffset} =~ /\+(\d+)/) {
-        # We must plus some hours to the time
-        $hour += $1;
-        $hour = $hour % 24;
-        if ($hour < 10) { $hour = "0" . $hour; }
-
-    } elsif ($self->{cfg}->{timeoffset} =~ /-(\d+)/) {
-        # We must remove some hours from the time
-        $hour -= $1;
-        $hour = $hour % 24;
-        if ($hour < 10) { $hour = "0" . $hour; }
-    }
-    return $hour;
-}
-
-
 1;
 
 __END__

+ 23 - 3
modules/Pisg/Parser/Logfile.pm

@@ -215,7 +215,7 @@ sub _parse_file
                     #Increment number of lines for repeated lines
                 }
 
-                $hour   = $hashref->{hour};
+                $hour   = $self->_adjusttimeoffset($hashref->{hour});
                 $nick   = find_alias($hashref->{nick});
                 checkname($hashref->{nick}, $nick, $stats) if ($self->{cfg}->{showmostnicks});
                 $saying = $hashref->{saying};
@@ -307,7 +307,7 @@ sub _parse_file
 
             my ($hour, $nick, $saying);
 
-            $hour   = $hashref->{hour};
+            $hour   = $self->_adjusttimeoffset($hashref->{hour});
             $nick   = find_alias($hashref->{nick});
             checkname($hashref->{nick}, $nick, $stats) if ($self->{cfg}->{showmostnicks});
             $saying = $hashref->{saying};
@@ -350,7 +350,7 @@ sub _parse_file
             my ($hour, $min, $nick, $kicker, $newtopic, $newmode, $newjoin);
             my ($newnick);
 
-            $hour     = $hashref->{hour};
+            $hour     = $self->_adjusttimeoffset($hashref->{hour});
             $min      = $hashref->{min};
             $nick     = find_alias($hashref->{nick});
             checkname($hashref->{nick}, $nick, $stats) if ($self->{cfg}->{showmostnicks});
@@ -524,6 +524,26 @@ sub checkname {
     push (@{ $stats->{nicks}{$newnick} }, $nick);
 }
 
+sub _adjusttimeoffset
+{
+    my $self = shift;
+    my $hour = shift;
+
+    if ($self->{cfg}->{timeoffset} =~ /\+(\d+)/) {
+        # We must plus some hours to the time
+        $hour += $1;
+        $hour = $hour % 24;
+        if ($hour < 10) { $hour = "0" . $hour; }
+
+    } elsif ($self->{cfg}->{timeoffset} =~ /-(\d+)/) {
+        # We must remove some hours from the time
+        $hour -= $1;
+        $hour = $hour % 24;
+        if ($hour < 10) { $hour = "0" . $hour; }
+    }
+    return $hour;
+}
+
 1;
 
 __END__