Vtc.Timecode.sub
You're seeing just the function
sub
, go back to Vtc.Timecode module for more information.
Specs
sub( a :: t(), b :: t() | Vtc.Source.Frames.t(), opts :: [{:round, maybe_round()}] ) :: t()
Subtracts two timecodoes together using their real-world seconds representation. When
the rates of a
and b
are not equal, the result will inheret the framerat of a
and be rounded to the seconds representation of the nearest whole-frame at that rate.
b
May be any value that implements the Frames
protocol, such as a timecode string,
and will be assumed to be the same framerate as a
. This is mostly to support quick
scripting. This function will raise if there is an error parsing b
.
Options
- round: How to round the result with respect to whole-frames when mixing
framerates. Default:
:closest
.
Examples
Two timecodes running at the same rate:
iex> a = Timecode.with_frames!("01:30:21:17", Rates.f23_98())
iex> b = Timecode.with_frames!("01:00:00:00", Rates.f23_98())
iex> Timecode.sub(a, b) |> inspect()
"<00:30:21:17 @ <23.98 NTSC NDF>>"
When b
is greater than a
, the result is negative:
iex> a = Timecode.with_frames!("01:00:00:00", Rates.f23_98())
iex> b = Timecode.with_frames!("02:00:00:00", Rates.f23_98())
iex> Timecode.sub(a, b) |> inspect()
"<-01:00:00:00 @ <23.98 NTSC NDF>>"
Two timecodes running at different rates:
iex> a = Timecode.with_frames!("01:00:00:02", Rates.f23_98())
iex> b = Timecode.with_frames!("00:00:00:02", Rates.f47_95())
iex> Timecode.sub(a, b) |> inspect()
"<01:00:00:01 @ <23.98 NTSC NDF>>"
Using a timcode and a bare string:
iex> a = Timecode.with_frames!("01:30:21:17", Rates.f23_98())
iex> Timecode.sub(a, "01:00:00:00") |> inspect()
"<00:30:21:17 @ <23.98 NTSC NDF>>"