Kalends.NaiveDateTime
NaiveDateTime can represents a "naive time". That is a point in time without a specified time zone.
Summary
from_erl!(erl_date_time) | Like from_erl/1 without "!", but returns the result directly without a tag. Will raise if date is invalid. Only use this if you are sure the date is valid |
from_erl(arg1) | Takes an Erlang-style date-time tuple. If the datetime is valid it returns a tuple with a tag and a naive DateTime. Naive in this context means that it does not have any timezone data |
to_erl(naivedatetime) | Takes a NaiveDateTime struct and returns an erlang style datetime tuple |
Functions
Takes an Erlang-style date-time tuple. If the datetime is valid it returns a tuple with a tag and a naive DateTime. Naive in this context means that it does not have any timezone data.
Examples
iex> from_erl({{2014, 9, 26}, {17, 10, 20}})
{:ok, %Kalends.NaiveDateTime{date: 26, hour: 17, min: 10, month: 9, sec: 20, year: 2014} }
iex> from_erl({{2014, 99, 99}, {17, 10, 20}})
{:error, :invalid_datetime}
Like from_erl/1 without "!", but returns the result directly without a tag. Will raise if date is invalid. Only use this if you are sure the date is valid.
Examples
iex> from_erl!({{2014, 9, 26}, {17, 10, 20}})
%Kalends.NaiveDateTime{date: 26, hour: 17, min: 10, month: 9, sec: 20, year: 2014}
iex from_erl!({{2014, 99, 99}, {17, 10, 20}})
# this will throw a MatchError