Time.diff

You're seeing just the function diff, go back to Time module for more information.
Link to this function

diff(time1, time2, unit \\ :second)

View Source (since 1.5.0)

Specs

Returns the difference between two times, considering only the hour, minute, second and microsecond.

As with the compare/2 function both Time structs and other structures containing time can be used. If for instance a NaiveDateTime or DateTime is passed, only the hour, minute, second, and microsecond is considered. Any additional information about a date or time zone is ignored when calculating the difference.

The answer can be returned in any unit available from System.time_unit/0. If the first time value is earlier than the second, a negative number is returned.

This function returns the difference in seconds where seconds are measured according to Calendar.ISO.

Examples

iex> Time.diff(~T[00:29:12], ~T[00:29:10])
2

# When passing a `NaiveDateTime` the date part is ignored.
iex> Time.diff(~N[2017-01-01 00:29:12], ~T[00:29:10])
2

# Two `NaiveDateTime` structs could have big differences in the date
# but only the time part is considered.
iex> Time.diff(~N[2017-01-01 00:29:12], ~N[1900-02-03 00:29:10])
2

iex> Time.diff(~T[00:29:12], ~T[00:29:10], :microsecond)
2_000_000
iex> Time.diff(~T[00:29:10], ~T[00:29:12], :microsecond)
-2_000_000