Browse Source

* Subtitle::BASE->build_timing

master
Alex 'AdUser' Z 10 years ago
parent
commit
7b5373315b
  1. 14
      lib/Subtitle/BASE.pm

14
lib/Subtitle/BASE.pm

@ -61,6 +61,20 @@ sub parse_timing {
return $time;
}
sub build_timing {
my ($self, $time, $prec) = @_;
$prec //= 2;
my ($hrs, $min, $sec, $msec, $rest);
$hrs = int($time / 3600);
$rest = $time - ($hrs * 3600);
$min = int($rest / 60);
$rest = $rest - ($min * 60);
$sec = int($rest / 1);
$msec = sprintf "%.${prec}f", ($rest - ($sec * 1));
$msec =~ s/^0\.//o;
return sprintf("%d:%02d:%02d.%s", $hrs, $min, $sec, $msec);
}
sub trim {
my ($self, $line) = @_;
return unless defined $line;

Loading…
Cancel
Save