From 2840c2eb912229c43fe6d2aac303804e0b631261 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Tue, 17 Mar 2015 14:58:03 +1000 Subject: [PATCH] * Subtitle::BASE->build_timing : customizable timing format --- lib/Subtitle/BASE.pm | 2 +- lib/Subtitle/SRT.pm | 1 + lib/Subtitle/SSA.pm | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Subtitle/BASE.pm b/lib/Subtitle/BASE.pm index 838137c..b7f4734 100644 --- a/lib/Subtitle/BASE.pm +++ b/lib/Subtitle/BASE.pm @@ -72,7 +72,7 @@ sub build_timing { $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); + return sprintf($self->{timing_fmt}, $hrs, $min, $sec, $msec); } sub trim { diff --git a/lib/Subtitle/SRT.pm b/lib/Subtitle/SRT.pm index 78a67ef..ca84972 100644 --- a/lib/Subtitle/SRT.pm +++ b/lib/Subtitle/SRT.pm @@ -15,6 +15,7 @@ sub new { %args, events => [], log => [], + timing_fmt => "%02d:%02d:%02d,%s", }; return bless($self, $class); diff --git a/lib/Subtitle/SSA.pm b/lib/Subtitle/SSA.pm index bbbe018..020e56d 100644 --- a/lib/Subtitle/SSA.pm +++ b/lib/Subtitle/SSA.pm @@ -29,6 +29,7 @@ sub new { styles => [], events => [], log => [], + timing_fmt => "%d:%02d:%02d.%s", }; return bless($self, $class);