Time

Time

A Time struct and functions.

The Time struct contains the fields hour, minute, second and microseconds. New times can be built with the new/4 function or using the ~T sigil:

iex> ~T[23:00:07.001]
~T[23:00:07.001]

Both new/4 and sigil return a struct where the time fields can be accessed directly:

iex> time = ~T[23:00:07.001]
iex> time.hour
23
iex> time.microsecond
{1000, 3}

The functions on this module work with the Time struct as well as any struct that contains the same fields as the Time struct, such as 登录查看完整内容