Skip to content

Commit

Permalink
Always add hours to SRT encoding
Browse files Browse the repository at this point in the history
It [appears][1] that the SRT format always requires hours.

1: https://en.wikipedia.org/wiki/SubRip#SubRip_file_format
  • Loading branch information
bismark committed Jul 20, 2023
1 parent 40e9cde commit a3e8222
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/vttyl/encode.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule Vttyl.Encode do

# Lop off hours if there aren't any
hr_and_min =
if hours <= 0 do
if hours <= 0 and type == :vtt do
prefix_fmt(minutes)
else
[hours, minutes]
Expand Down
6 changes: 3 additions & 3 deletions test/vttyl_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ defmodule VttylTest do
end

test "basic", %{parts: parts} do
assert make_srt(1, "00:01,000", "00:10,000", "Hello world") == Vttyl.encode_srt(parts)
assert make_srt(1, "00:00:01,000", "00:00:10,000", "Hello world") == Vttyl.encode_srt(parts)
end

test "multi line" do
Expand All @@ -157,8 +157,8 @@ defmodule VttylTest do
]

expect =
make_srt(1, "00:01,000", "00:10,000", "Hello") <>
"\n" <> make_srt(2, "00:02,000", "00:20,000", "world")
make_srt(1, "00:00:01,000", "00:00:10,000", "Hello") <>
"\n" <> make_srt(2, "00:00:02,000", "00:00:20,000", "world")

assert expect == Vttyl.encode_srt(parts)
end
Expand Down

0 comments on commit a3e8222

Please sign in to comment.