Browse Source

* Subtitle::SSA::Style : fix to_string()

master
Alex 'AdUser' Z 9 years ago
parent
commit
d64ba2f2b0
  1. 6
      lib/Subtitle/SSA/Record.pm

6
lib/Subtitle/SSA/Record.pm

@ -95,9 +95,9 @@ sub parse {
sub to_string { sub to_string {
my ($self) = @_; my ($self) = @_;
my $string = $self->{_prefix} . ' '; my $string = $self->{_prefix} . ': ';
my @values = (); my @values = ();
foreach my $field (@{ $self->{_fields} }) { foreach my $field (@{ $self->{_format} }) {
my $d = $self->{_fields}->{$field}; my $d = $self->{_fields}->{$field};
my $v = $self->{$field} // $d->{value}; my $v = $self->{$field} // $d->{value};
if ($d->{type} eq 'x' and $self->{_vers} eq 'ass') { if ($d->{type} eq 'x' and $self->{_vers} eq 'ass') {
@ -105,7 +105,7 @@ sub to_string {
} elsif ($d->{type} eq 'f') { } elsif ($d->{type} eq 'f') {
$v = sprintf "%.2f", $v; $v = sprintf "%.2f", $v;
# hack: make decimal from float if fractional part is zero after round up # hack: make decimal from float if fractional part is zero after round up
$v =~ s{\.00$}{}oi; $v =~ s{[\.]?0*$}{}oi;
} elsif ($d->{type} eq 'z') { } elsif ($d->{type} eq 'z') {
$v = sprintf "%04d", $v; $v = sprintf "%04d", $v;
} elsif ($d->{type} eq 't') { } elsif ($d->{type} eq 't') {

Loading…
Cancel
Save