You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
827 B
37 lines
827 B
package Subtitle::TimePoint; |
|
|
|
use strict; |
|
use warnings; |
|
|
|
use Subtitle::Utils ':timing'; |
|
|
|
sub new { |
|
my ($class, %args) = @_; |
|
my $self = { |
|
shift => $args{shift} || 0.0, |
|
time => $args{time} || 0.0, |
|
}; |
|
return bless($self, $class); |
|
} |
|
|
|
sub parse { |
|
my ($self, $timespec) = @_; |
|
|
|
return 'empty timespec, nothing to do' |
|
unless $timespec; |
|
return 'wrong timespec, expected <time>/[+-]<time>, abort' |
|
unless $timespec =~ m<^([0-9:.]+)/([+-]?[0-9:.]+)$>o; |
|
my ($t1, $t2) = ($1, $2); |
|
$self->{time} = parse_timeshift($t1); |
|
$self->{shift} = parse_timeshift($t2); |
|
return "can't parse time: $t1" |
|
unless defined $self->{time}; |
|
return "can't parse time: $t2" |
|
unless defined $self->{shift}; |
|
return; |
|
} |
|
|
|
sub shift { return CORE::shift->{'shift'}; } |
|
sub time { return CORE::shift->{'time'}; } |
|
|
|
1;
|
|
|