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

Use sprintf to prefix with a zero, more readable

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

+ 1 - 1
modules/Pisg/HTMLGenerator.pm

@@ -324,7 +324,7 @@ sub _activetimes
     _html("<table border=\"0\" width=\"$self->{cfg}->{tablewidth}\"><tr>\n");
 
     for ($b = 0; $b < 24; $b++) {
-        if ($b < 10) { $a = "0" . $b; } else { $a = $b; }
+        $a = sprintf("%02d", $b);
 
         if (!defined($output{$a}) || $output{$a} eq "") {
             _html("<td align=\"center\" valign=\"bottom\" class=\"asmall\">0%</td>");

+ 2 - 2
modules/Pisg/Parser/Logfile.pm

@@ -535,13 +535,13 @@ sub _adjusttimeoffset
         # We must plus some hours to the time
         $hour += $1;
         $hour = $hour % 24;
-        if ($hour < 10) { $hour = "0" . $hour; }
+        $hour = sprintf("%02d", $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 = sprintf("%02d", $hour);
     }
     return $hour;
 }