Copyright © Dale Harvey
Format dates in erlang
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 examplesdate() = {year(), month(), day()}
day() = 1..31
hour() = 0..23
microsecond() = 0..999999
minute() = 0..59
month() = 1..12 | {month, 1..12}
now() = {integer(), integer(), integer()}
second() = 0..59
time() = {hour(), minute(), second()} | {hour(), minute(), second(), microsecond()}
year() = non_neg_integer()
format/1 | format current local time as Format. |
format/2 | format Date as Format. |
format_iso8601/1 | format date in the ISO8601 format This always puts 'Z' as time zone, since we have no notion of 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. |
tokenise/2 |
format(Format::string()) -> string()
format current local time as Format
format(Format::string(), Now::datetime() | now()) -> string()
format Date as Format
format_iso8601(Date::datetime()) -> string()
format date in the ISO8601 format This always puts 'Z' as time zone, since we have no notion of timezone
nparse(Date::string()) -> now()
parses the datetime from a string into 'now' format
parse(Date::string()) -> datetime()
parses the datetime from a string
parse(Date::string(), Now::datetime() | now()) -> datetime()
parses the datetime from a string
tokenise(Rest, Acc) -> any()
Generated by EDoc, Feb 15 2022, 15:17:48.