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

Add a function to adjust the timeoffset properly, more readable code. Also use this function to fix a bug which highlighted the wrong hour in most active times

Morten Brix Pedersen 24 лет назад
Родитель
Сommit
338a2e3aa7
1 измененных файлов с 23 добавлено и 13 удалено
  1. 23 13
      modules/Pisg/HTMLGenerator.pm

+ 23 - 13
modules/Pisg/HTMLGenerator.pm

@@ -315,18 +315,8 @@ sub _activetimes
             $size = 1.0;
             $size = 1.0;
         }
         }
 
 
-        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; }
-        }
+        $hour = $self->_adjusttimeoffset($hour);
+
         $image = "pic_v_".(int($hour/6)*6);
         $image = "pic_v_".(int($hour/6)*6);
         $image = $self->{cfg}->{$image};
         $image = $self->{cfg}->{$image};
 
 
@@ -351,7 +341,7 @@ sub _activetimes
     $toptime[0] =~ s/0(\d)/$1/;
     $toptime[0] =~ s/0(\d)/$1/;
 
 
     for ($b = 0; $b < 24; $b++) {
     for ($b = 0; $b < 24; $b++) {
-        if ($toptime[0] == $b) {
+        if ($self->_adjusttimeoffset($toptime[0]) == $b) {
             # Highlight the top time
             # Highlight the top time
             $class = 'hirankc10center';
             $class = 'hirankc10center';
         } else {
         } else {
@@ -1670,6 +1660,26 @@ 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;
 1;