mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
Support negative part-hour TZ values (thanks to Alexander Zhukov)(EJAB-1301)
This commit is contained in:
parent
1d1496a667
commit
26ac75bdc9
@ -561,7 +561,7 @@ rsm_encode_count(Count, Arr)->
|
|||||||
i2l(I) when is_integer(I) -> integer_to_list(I);
|
i2l(I) when is_integer(I) -> integer_to_list(I);
|
||||||
i2l(L) when is_list(L) -> L.
|
i2l(L) when is_list(L) -> L.
|
||||||
|
|
||||||
%% Timezone = utc | {Hours, Minutes}
|
%% Timezone = utc | {Sign::string(), {Hours, Minutes}} | {Hours, Minutes}
|
||||||
%% Hours = integer()
|
%% Hours = integer()
|
||||||
%% Minutes = integer()
|
%% Minutes = integer()
|
||||||
timestamp_to_iso({{Year, Month, Day}, {Hour, Minute, Second}}, Timezone) ->
|
timestamp_to_iso({{Year, Month, Day}, {Hour, Minute, Second}}, Timezone) ->
|
||||||
@ -572,6 +572,8 @@ timestamp_to_iso({{Year, Month, Day}, {Hour, Minute, Second}}, Timezone) ->
|
|||||||
Timezone_string =
|
Timezone_string =
|
||||||
case Timezone of
|
case Timezone of
|
||||||
utc -> "Z";
|
utc -> "Z";
|
||||||
|
{Sign, {TZh, TZm}} ->
|
||||||
|
io_lib:format("~s~2..0w:~2..0w", [Sign, TZh, TZm]);
|
||||||
{TZh, TZm} ->
|
{TZh, TZm} ->
|
||||||
Sign = case TZh >= 0 of
|
Sign = case TZh >= 0 of
|
||||||
true -> "+";
|
true -> "+";
|
||||||
|
@ -76,14 +76,8 @@ process_local_iq(_From, _To, #iq{type = Type, sub_el = SubEl} = IQ) ->
|
|||||||
{UTC, UTC_diff} = jlib:timestamp_to_iso(Now_universal, utc),
|
{UTC, UTC_diff} = jlib:timestamp_to_iso(Now_universal, utc),
|
||||||
Seconds_diff = calendar:datetime_to_gregorian_seconds(Now_local)
|
Seconds_diff = calendar:datetime_to_gregorian_seconds(Now_local)
|
||||||
- calendar:datetime_to_gregorian_seconds(Now_universal),
|
- calendar:datetime_to_gregorian_seconds(Now_universal),
|
||||||
{Hd, Md, _} = case Seconds_diff >= 0 of
|
{Hd, Md, _} = calendar:seconds_to_time(abs(Seconds_diff)),
|
||||||
true ->
|
{_, TZO_diff} = jlib:timestamp_to_iso({{0, 0, 0}, {0, 0, 0}}, {sign(Seconds_diff), {Hd, Md}}),
|
||||||
calendar:seconds_to_time(Seconds_diff);
|
|
||||||
false ->
|
|
||||||
{Hd0, Md0, Sd0} = calendar:seconds_to_time(-Seconds_diff),
|
|
||||||
{-Hd0, Md0, Sd0}
|
|
||||||
end,
|
|
||||||
{_, TZO_diff} = jlib:timestamp_to_iso({{0, 0, 0}, {0, 0, 0}}, {Hd, Md}),
|
|
||||||
IQ#iq{type = result,
|
IQ#iq{type = result,
|
||||||
sub_el = [{xmlelement, "time",
|
sub_el = [{xmlelement, "time",
|
||||||
[{"xmlns", ?NS_TIME}],
|
[{"xmlns", ?NS_TIME}],
|
||||||
@ -93,4 +87,5 @@ process_local_iq(_From, _To, #iq{type = Type, sub_el = SubEl} = IQ) ->
|
|||||||
[{xmlcdata, UTC ++ UTC_diff}]}]}]}
|
[{xmlcdata, UTC ++ UTC_diff}]}]}]}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
sign(N) when N < 0 -> "-";
|
||||||
|
sign(_) -> "+".
|
||||||
|
Loading…
Reference in New Issue
Block a user