mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Merge branch 'master' of github.com:processone/ejabberd
This commit is contained in:
commit
a7e3df4fec
18
src/jlib.erl
18
src/jlib.erl
@ -45,7 +45,7 @@
|
||||
iq_to_xml/1, parse_xdata_submit/1,
|
||||
is_standalone_chat_state/1,
|
||||
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,
|
||||
datetime_string_to_timestamp/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()
|
||||
-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},
|
||||
{Hour, Minute, Second}},
|
||||
Timezone) ->
|
||||
@ -632,13 +635,22 @@ timestamp_to_iso({{Year, Month, Day},
|
||||
end,
|
||||
{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}}) ->
|
||||
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 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().
|
||||
|
||||
now_to_utc_string({MegaSecs, Secs, MicroSecs}) ->
|
||||
|
@ -702,7 +702,7 @@ set_random_password(User, Server, Reason) ->
|
||||
set_password_auth(User, Server, NewPass).
|
||||
|
||||
build_random_password(Reason) ->
|
||||
Date = jlib:timestamp_to_iso(calendar:universal_time()),
|
||||
Date = jlib:timestamp_to_legacy(calendar:universal_time()),
|
||||
RandomString = randoms:get_string(),
|
||||
<<"BANNED_ACCOUNT--", Date/binary, "--", RandomString/binary, "--", Reason/binary>>.
|
||||
|
||||
|
@ -355,7 +355,7 @@ build_info_room({Name, Host, Pid}) ->
|
||||
false ->
|
||||
Last_message1 = queue:last(History),
|
||||
{_, _, _, Ts_last, _} = Last_message1,
|
||||
jlib:timestamp_to_iso(Ts_last)
|
||||
jlib:timestamp_to_legacy(Ts_last)
|
||||
end,
|
||||
|
||||
{<<Name/binary, "@", Host/binary>>,
|
||||
|
Loading…
Reference in New Issue
Block a user