Format dates in erlang.
Copyright (c) Dale Harvey
Licensed under the MIT license
This module formats erlang dates in the form {{Year, Month, Day}, {Hour, Minute, Second}} to printable strings, using (almost) equivalent formatting rules as http://uk.php.net/date, US vs European dates are disambiguated in the same way as http://uk.php.net/manual/en/function.strtotime.php That is, Dates in the m/d/y or d-m-y formats are disambiguated by looking at the separator between the various components: if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed. To avoid potential ambiguity, it's best to use ISO 8601 (YYYY-MM-DD) dates.
erlang has no concept of timezone so the following formats are not implemented: B e I O P T Z formats c and r will also differ slightly
See tests at bottom for examples
dt_unit() = second | minute | hour | day | month | year
dt_units() = seconds | minutes | hours | days | months | years
now() = {integer(), integer(), integer()}
| add/2 | Add 1 unit to the given DateTime. |
| add/3 | Add N units to the given DateTime. |
| compare/2 | Compate Date1 and Date2 |
| format/1 | format current local time as Format. |
| format/2 | format Date as Format. |
| local_timezone/0 | Return the local timezone. |
| nparse/1 | parses the datetime from a string into 'now' format. |
| parse/1 | parses the datetime from a string. |
| parse/2 | parses the datetime from a string. |
| timezone_offset/0 | Returns the time difference between UTC time and local time, in minutes. |
| to_iso8601/1 | Return date using iso8601 format. |
| today/0 | return now local datetime. |
| today_utc/0 | return now UTC datetime. |
| tomorrow/0 | return tomorrow local datetime. |
| tomorrow_utc/0 | return tomorrow UTC datetime. |
| yesterday/0 | return yesterday local datetime. |
| yesterday_utc/0 | return yesterday UTC datetime. |
add(Date::calendar:datetime(), N::dt_unit()) -> calendar:datetime()
Add 1 unit to the given DateTime.
add(DateTime::calendar:datetime(), N::integer(), X3::dt_units()) -> calendar:datetime()
Add N units to the given DateTime.
compare(Date1::calendar:datetime(), Date2::calendar:datetime()) -> -1 | 1 | 0
Compate Date1 and Date2
format(Format::string()) -> string()
format current local time as Format
format(Format::string(), Now::calendar:datetime() | now()) -> string()
format Date as Format
local_timezone() -> any()
Return the local timezone
nparse(Date::string()) -> now()
parses the datetime from a string into 'now' format
parse(Date::string()) -> calendar:datetime()
parses the datetime from a string
parse(Date::string(), Now::calendar:datetime() | now()) -> calendar:datetime()
parses the datetime from a string
timezone_offset() -> any()
Returns the time difference between UTC time and local time, in minutes.
to_iso8601(Date::calendar:datetime()) -> string()
Return date using iso8601 format
today() -> calendar:datetime()
return now local datetime.
today_utc() -> calendar:datetime()
return now UTC datetime.
tomorrow() -> calendar:datetime()
return tomorrow local datetime.
tomorrow_utc() -> calendar:datetime()
return tomorrow UTC datetime.
yesterday() -> calendar:datetime()
return yesterday local datetime.
yesterday_utc() -> calendar:datetime()
return yesterday UTC datetime.