datetime
Description
Wpart responsible for handling the timestamps (both dates and times). Since it is the most convenient format, dates inside the Erlang Virtual Machine are kept as the {{Year, Month, Day}, {Hour, Minute, Second}} tuples. wpart_datetime does the actual formatting and conversions.
The rendered widget is <input type="text" ... />.
Validation
option |
format |
description |
error message |
format |
"Format" |
Defines the format of the datetime |
{bad_date, Input} in case of bad date input, {bad_time, Input} in case of bad time input and {bad_input, Input} when the format could not be recognized |
other date or time limitations |
depends on the limitation |
The limitation is passed to the lower level validator (date or time) |
{bad_time, Input} or {bad_date, Input} |
HTML meta-attributes
name |
format |
description |
format |
"Format" |
Describes the format timestamps should be displayed with. The available formats are listed below. The default format is YYYY-MM-DD HH:NN:SS. |
Formats
format |
description |
example (for a tuple: {{1999, 10, 4}, {20, 10, 05}} |
YYYY |
year in four digit format |
1999 |
YY |
year in two digit format |
99 |
MM |
month in two digit format |
10 |
SMONTH |
month in a short word format |
Oct |
MONTH |
month in a word format |
October |
DD |
day in two digit format |
04 |
SDAY |
day of the week in a short word format |
Mon |
DAY |
day of the week in a word format |
Monday |
HH |
hour |
20 |
NN |
minutes |
10 |
SS |
seconds |
05 |
Other character |
passed through |
Other character |
Formatting examples
format |
input |
result |
YYYY-MM-DD HH:NN:SS |
{{2001, 01, 01}, {10, 10, 10}} |
"2001-01-01 10:10:10" |
HH:NN; DAY, SMONTH, YY |
{{1980, 04, 20}, {11, 49, 01}} |
"11:49; Sunday, Apr, 80" |
Examples
Records definitions
...
{datetime, [{format, "YY/MM/DD, HH:NN:SS"}
%% other parameters
]
},
...
HTML tag
<wpart:datetime format="HH:NN, date: MM SDAY - YYYY" OTHER_HTML_ATTRIBUTES />
