Thread Timestamp Dateien abfragen (13 answers)
Opened by leissi at 2005-12-14 15:11

esskar
 2005-12-15 01:19
#60903 #60903
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
ich hätte die ja so geschrieben

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
sub mtime {
  my ($file, $option) = @_;

  return undef unless -e $file;
 
  my $mtime = time - (stat $file)[9];
  my $retval = undef;

  $option = lc($option || '');
  if($option eq "time") {
     my $fmt = 'sek';
     my $tmstr = $mtime % 60;
     if($mtime / 60 >= 1) {
        $fmt = 'min';
        $tmstr = ($mtime / 60 % 60) . ':' . $tmstr;
        if($mtime / 3600 >= 1) {
           $fmt = 'hour';
           $tmstr = ($mtime / 3600 % 60) . ':' . $tmstr;
        }
     }
     $retval = "$timestr $fmt";
  } elsif($option eq "date") {
     $retval = scalar localtime $mtime;
  } else { # es gibt immer einen else fall
     warn "Unknown option '$option'.";
  }

  return $retval;
}
\n\n

<!--EDIT|esskar|1134602412-->

View full thread Timestamp Dateien abfragen