Calendar.Time
The Time module provides a struct to represent a simple time without specifying a date, nor a time zone.
Summary↑
from_erl(arg1, usec \\ nil) | Create a Time struct using an erlang style tuple and optionally a fractional second |
to_erl(time) | Takes a Time struct and returns an erlang style time tuple |
Functions
Create a Time struct using an erlang style tuple and optionally a fractional second.
iex> from_erl({20,14,15})
{:ok, %Calendar.Time{usec: nil, hour: 20, min: 14, sec: 15}}
iex> from_erl({20,14,15}, 123456)
{:ok, %Calendar.Time{usec: 123456, hour: 20, min: 14, sec: 15}}
iex> from_erl({24,14,15})
{:error, :invalid_time}
iex> from_erl({-1,0,0})
{:error, :invalid_time}
iex> from_erl({20,14,15}, 1_000_000)
{:error, :invalid_time}
Takes a Time struct and returns an erlang style time tuple.