Mandrake v0.0.2 Mandrake.DateTime
Mandrake functions for date and time.
Summary
Functions
Add date to time
Add time to date
Format date to dd mm yyyy with the given divider
Extract date to date_time
Extract time to date_time
Format date, time or date_time with the given divider
Format date/time with the given pattern and list using :io_lib.format
Returns a function for date or time formatting
Get current date and time
Get current date
Get current local date and time
Get current local date
Get current local time
Get current time
Returns true if first date_time is < than second
Returns true if first date_time is > than second
Returns the difference in seconds beetween two date_time elements (date_2 - date_1)
Returns days and time correspondig given seconds
Functions
Add date to time.
Examples
iex> Mandrake.DateTime.add_date({15, 34, 18})
{{2015, 11, 29}, {15, 34, 18}}
Add time to date.
Examples
iex> Mandrake.DateTime.add_time({2015, 11, 29})
{{2015, 11, 29}, {0, 0, 0}}
Format date to dd mm yyyy with the given divider.
Examples
iex> Mandrake.DateTime.dd_mm_yyyy({2015,12,31}, "/")
"31/12/2015"
Extract date to date_time.
Examples
iex> Mandrake.DateTime.extract_date({{2015, 11, 29}, {15, 34, 18}})
{2015, 11, 29}
Extract time to date_time.
Examples
iex> Mandrake.DateTime.extract_time({{2015, 11, 29}, {15, 34, 18}})
{15, 34, 18}
Format date, time or date_time with the given divider.
Examples
iex> Mandrake.DateTime.format({{2015,12,31}, {10,30,15}}, "/")
"2015/12/31 10:30:15"
iex> Mandrake.DateTime.format({2015,12,31}, "/")
"2015/12/31"
iex> Mandrake.DateTime.format({10,30,15})
"10:30:15"
Format date/time with the given pattern and list using :io_lib.format.
Examples
iex> Mandrake.DateTime.format_date_time("~2..0B:~2..0B:~2..0B", [10 ,30 ,15 ])
"10:30:15"
Returns a function for date or time formatting.
Examples
iex> formatWithSlash = Mandrake.DateTime.format_with_divider("/")
...> formatWithSlash.({{2015,12,31}, {10,30,15}})
"2015/12/31 10:30:15"
Get current date and time.
Examples
iex> Mandrake.DateTime.get()
{{2015, 11, 29}, {15, 34, 18}}
Get current local date and time.
Examples
iex> Mandrake.DateTime.get_local()
{{2015, 11, 29}, {15, 34, 18}}
Get current local date.
Examples
iex> Mandrake.DateTime.get_local_date()
{2015, 11, 29}
Get current local time.
Examples
iex> Mandrake.DateTime.get_local_time()
{15, 34, 18}
Returns true if first date_time is < than second.
Examples
iex> Mandrake.DateTime.is_future({{2015, 11, 29}, {15, 34, 18}}, {{2015, 11, 28}, {15, 34, 18}})
false
Returns true if first date_time is > than second.
Examples
iex> Mandrake.DateTime.is_past({{2015, 11, 29}, {15, 34, 18}}, {{2015, 11, 28}, {15, 34, 18}})
true
Returns the difference in seconds beetween two date_time elements (date_2 - date_1).
Examples
iex> Mandrake.DateTime.offset({{2015, 11, 29}, {15, 34, 18}}, {{2015, 11, 30}, {15, 34, 18}})
86400