Thread Floor auch für Minuswerte? (13 answers)
Opened by silbersteine at 2004-08-05 02:03

esskar
 2004-08-06 02:18
#85387 #85387
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
wo er recht hat, hat er recht :)

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
D:\Eigene Dateien\Entwicklung\RFC>perl
sub clock {
my $minutes = shift;
my $sign = ($minutes >= 0);
my $hh = int($minutes/60);
my $rest = abs($minutes - $hh*60);
return sprintf ("%s%d:%02d", ($sign ? '' : '-'), $hh, $rest);
}
$jobsum=0;
$skalars{'stdtime'}=440;
print "Überstunden = ".clock($jobsum-$skalars{'stdtime'});
^Z
Überstunden = --7:20


bugfix:

Code: (dl )
1
2
3
4
5
6
sub clock {
my $minutes = shift;
my $hh = int($minutes/60);
my $rest = abs($minutes - $hh*60);
return sprintf ("%d:%02d", $hh, $rest);
}

View full thread Floor auch für Minuswerte?