Browse files

fix mins

  • Loading branch information...
1 parent 6f87948 commit 33fd655fb464e2ca51a82d782e96962221902e27 Monopatis Dimitris committed Mar 20, 2012
Showing with 20 additions and 14 deletions.
  1. +20 −14 p-space.event
View
34 p-space.event
@@ -8,30 +8,36 @@ my $string = 'Remote';
my $oldevent = 'foo';
my $message = 'foo';
my $time = '00:00';
-my $url = 'http://p-space.gr/report/index.php?limit=1&nostyle';
+my $url = 'http://pspace.dyndns.org/report/index.php?limit=1&nostyle';
#add # if you want to see the last event on start
$oldevent = get("$url");
my @values = split(' ', $oldevent);
+#always
while (1==1)
{
$event = get("$url");
if ($oldevent ne $event){
$oldevent = $event ;
@values = split(' ', $oldevent);
- my $sec= time()-$values[0];
- print "$sec \n";
- $sec = $sec+(8*60*60);
- print $sec;
- if ($sec>60){
- my $min = $sec;
- $sec = $sec % 60;
- $min = ($min-$sec);
- my $secs = sprintf("%02d", $sec);
- print $secs;
- $time = "$min:$secs mins";
+ my $diftime= time()-$values[0];
+ my ($sec, $min, $hour, $day,$month,$year) = (gmtime($diftime))[0,1,2,3,4,5];
+ $hour=$hour+($day-1)*24;
+# print "Unix time ".$diftime." means ".$day." day, ";
+# print " ".$hour.":".$min.":".$sec."\n";
+ my $secs = sprintf("%02d", $sec);
+ my $mins = sprintf("%02d", $min);
+ my $hours = sprintf("%02d", $hour);
+ if ($hour>0){
+
+ $time = "$hour:$mins:$secs hours";
}
- else {
- $time = "$sec secs";
+ else{
+ if ($min>0) {
+ $time = "$min:$secs mins";
+ }
+ else {
+ $time = "$sec secs";
+ }
}
if ($string eq $values[1]){
$message = "remote button pressed";

0 comments on commit 33fd655

Please sign in to comment.