From: Carl Hetherington Date: Sun, 13 Nov 2022 18:46:18 +0000 (+0100) Subject: Make SubripReader::convert_time usable by other classes. X-Git-Tag: v1.6.38~1 X-Git-Url: https://git.carlh.net/gitweb/?p=libsub.git;a=commitdiff_plain;h=e3c66895937d334ceb6d9c310941e2fbeae0e6dc Make SubripReader::convert_time usable by other classes. --- diff --git a/src/subrip_reader.cc b/src/subrip_reader.cc index f0fe07f..926511a 100644 --- a/src/subrip_reader.cc +++ b/src/subrip_reader.cc @@ -124,8 +124,18 @@ SubripReader::read (function ()> get_line) throw SubripError (*line, "a time/position line", _context); } - rs.from = convert_time (p[0]); - rs.to = convert_time (p[2]); + string expected; + auto from = convert_time(p[0], &expected); + if (!from) { + throw SubripError(p[0], expected, _context); + } + rs.from = *from; + + auto to = convert_time(p[2], &expected); + if (!to) { + throw SubripError(p[2], expected, _context); + } + rs.to = *to; /* XXX: should not ignore coordinate specifications */ @@ -152,19 +162,27 @@ SubripReader::read (function ()> get_line) } } -Time -SubripReader::convert_time (string t) +optional