24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-05-31 21:07:55 +02:00

Merge branch 'master' of github.com:processone/ejabberd

This commit is contained in:
Mickael Remond 2016-01-24 10:07:25 +01:00
commit a7e3df4fec
3 changed files with 17 additions and 5 deletions

View File

@ -45,7 +45,7 @@
iq_to_xml/1, parse_xdata_submit/1, iq_to_xml/1, parse_xdata_submit/1,
is_standalone_chat_state/1, is_standalone_chat_state/1,
add_delay_info/3, add_delay_info/4, add_delay_info/3, add_delay_info/4,
timestamp_to_iso/1, timestamp_to_iso/2, timestamp_to_legacy/1, timestamp_to_iso_basic/1, timestamp_to_iso/2,
now_to_utc_string/1, now_to_local_string/1, now_to_utc_string/1, now_to_local_string/1,
datetime_string_to_timestamp/1, datetime_string_to_timestamp/1,
term_to_base64/1, base64_to_term/1, term_to_base64/1, base64_to_term/1,
@ -612,6 +612,9 @@ create_delay_tag(DateTime, Host, Desc) when is_binary(Host) ->
%% Minutes = integer() %% Minutes = integer()
-spec timestamp_to_iso(calendar:datetime(), tz()) -> {binary(), binary()}. -spec timestamp_to_iso(calendar:datetime(), tz()) -> {binary(), binary()}.
%% This is the XEP-0082 date and time format
%% http://xmpp.org/extensions/xep-0082.html
timestamp_to_iso({{Year, Month, Day}, timestamp_to_iso({{Year, Month, Day},
{Hour, Minute, Second}}, {Hour, Minute, Second}},
Timezone) -> Timezone) ->
@ -632,13 +635,22 @@ timestamp_to_iso({{Year, Month, Day},
end, end,
{iolist_to_binary(Timestamp_string), iolist_to_binary(Timezone_string)}. {iolist_to_binary(Timestamp_string), iolist_to_binary(Timezone_string)}.
-spec timestamp_to_iso(calendar:datetime()) -> binary().
timestamp_to_iso({{Year, Month, Day}, -spec timestamp_to_legacy(calendar:datetime()) -> binary().
%% This is the jabber legacy format
%% http://xmpp.org/extensions/xep-0091.html#time
timestamp_to_legacy({{Year, Month, Day},
{Hour, Minute, Second}}) -> {Hour, Minute, Second}}) ->
iolist_to_binary(io_lib:format("~4..0B~2..0B~2..0BT~2..0B:~2..0B:~2..0B", iolist_to_binary(io_lib:format("~4..0B~2..0B~2..0BT~2..0B:~2..0B:~2..0B",
[Year, Month, Day, Hour, Minute, Second])). [Year, Month, Day, Hour, Minute, Second])).
-spec timestamp_to_iso_basic(calendar:datetime()) -> binary().
%% This is the ISO 8601 basic bormat
timestamp_to_iso_basic({{Year, Month, Day},
{Hour, Minute, Second}}) ->
iolist_to_binary(io_lib:format("~4..0B~2..0B~2..0BT~2..0B~2..0B~2..0B",
[Year, Month, Day, Hour, Minute, Second])).
-spec now_to_utc_string(erlang:timestamp()) -> binary(). -spec now_to_utc_string(erlang:timestamp()) -> binary().
now_to_utc_string({MegaSecs, Secs, MicroSecs}) -> now_to_utc_string({MegaSecs, Secs, MicroSecs}) ->

View File

@ -702,7 +702,7 @@ set_random_password(User, Server, Reason) ->
set_password_auth(User, Server, NewPass). set_password_auth(User, Server, NewPass).
build_random_password(Reason) -> build_random_password(Reason) ->
Date = jlib:timestamp_to_iso(calendar:universal_time()), Date = jlib:timestamp_to_legacy(calendar:universal_time()),
RandomString = randoms:get_string(), RandomString = randoms:get_string(),
<<"BANNED_ACCOUNT--", Date/binary, "--", RandomString/binary, "--", Reason/binary>>. <<"BANNED_ACCOUNT--", Date/binary, "--", RandomString/binary, "--", Reason/binary>>.

View File

@ -355,7 +355,7 @@ build_info_room({Name, Host, Pid}) ->
false -> false ->
Last_message1 = queue:last(History), Last_message1 = queue:last(History),
{_, _, _, Ts_last, _} = Last_message1, {_, _, _, Ts_last, _} = Last_message1,
jlib:timestamp_to_iso(Ts_last) jlib:timestamp_to_legacy(Ts_last)
end, end,
{<<Name/binary, "@", Host/binary>>, {<<Name/binary, "@", Host/binary>>,