sile/jsone

encode datatime

aposto opened this issue · 2 comments

jsx:encode([{<<"create_date">>,{{2015,6,25},{14,57,25}}}]) 
=> <<"{\"create_date\":\"2015-06-25T14:57:25Z\"}">>

jsone:encode([{<<"create_date">>,{{2015,6,25},{14,57,25}}}])
=> ** exception error: bad argument
sile commented

Datetime encoding is now supported from version 1.1.0.

%%
%% Examples
%%

%% UTC (default)
> jsone:encode({{2000, 3, 10}, {10, 3, 58}}).
<<"\"2000-03-10T10:03:58Z\"">>

%% Local time (timezone=JST)
> jsone:encode({{2000, 3, 10}, {10, 3, 58}}, [{datetime_format, {iso8601, local}}]).
<<"\"2000-03-10T10:03:58+09:00\"">>

%% Timezone offset
 > jsone:encode({{2000, 3, 10}, {10, 3, 58}}, [{datetime_format, {iso8601, -5*60*60}}]).
<<"\"2000-03-10T10:03:58-05:00\"">>

Thank you for your information.

Thank you.