package plugin::jikokuhyou::Jikokuhyou; use strict; sub new { my $class = shift; my $self = {}; return bless $self,$class; } sub paragraph { my $self = shift; my $wiki = shift; my $source = shift; my ($sec, $now_min, $now_hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time()); my $buf = ''; my $page = $wiki->get_page($source); if ($page eq ''){ return &Util::paragraph_error("Page($source) not found."); } my @lines = split("\n", $page); my $line = ''; do { $line = shift @lines; } while (!($line =~ /^,/)); $buf .= "\n"; do { if ($line =~ /^,(.+),(.+)/) { my $hour = $1; my $minutes = $2; $buf .= ""; my $color; if ($hour == $now_hour) { $color = "class=diff0"; } elsif ($hour == $now_hour+1) { $color = "class=diff1"; } else { if ($hour%2 == 0) { $color = "class=diff_"; } else { $color = "class=diff-"; } } $buf .= " "; $buf .= ""; $buf .= "\n"; } } while (($line = shift @lines) =~ /^,/); $buf .= "
$hour"; foreach my $m (split(' ', $minutes)) { my $bold = 0; my $us = 0; if ($m =~/\*(.+)/) { $m = $1; $bold = 1; } my $now = $now_hour*60 + $now_min; my $t = $hour*60 + $m; if ( ($now <= $t) && ($t < $now + 30 )) { $us = 1; } $buf .= '' if ($us == 1); $buf .= '' if ($bold == 1); $buf .= $m; $buf .= '' if ($bold == 1); $buf .= '' if ($us == 1); $buf .= ' '; } $buf .= "
\n"; return $buf; } 1;