mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Support negative part-hour TZ values (thanks to Alexander Zhukov)(EJAB-1301)
This commit is contained in:
parent
26550efd91
commit
f9e2466867
@ -153,7 +153,7 @@ rsm_encode_count(Count, Arr)->
|
||||
i2b(I) when is_integer(I) -> list_to_binary(integer_to_list(I));
|
||||
i2b(L) when is_list(L) -> list_to_binary(L).
|
||||
|
||||
%% Timezone = utc | {Hours, Minutes}
|
||||
%% Timezone = utc | {Sign::string(), {Hours, Minutes}} | {Hours, Minutes}
|
||||
%% Hours = integer()
|
||||
%% Minutes = integer()
|
||||
timestamp_to_iso({{Year, Month, Day}, {Hour, Minute, Second}}, Timezone) ->
|
||||
@ -162,6 +162,8 @@ timestamp_to_iso({{Year, Month, Day}, {Hour, Minute, Second}}, Timezone) ->
|
||||
[Year, Month, Day, Hour, Minute, Second])),
|
||||
Timezone_string = case Timezone of
|
||||
utc -> "Z";
|
||||
{Sign, {TZh, TZm}} ->
|
||||
io_lib:format("~s~2..0w:~2..0w", [Sign, TZh, TZm]);
|
||||
{TZh, TZm} ->
|
||||
Sign = case TZh >= 0 of
|
||||
true -> "+";
|
||||
|
@ -59,14 +59,8 @@ process_local_iq(_From, _To, #iq{type = get} = IQ_Rec) ->
|
||||
{UTC, UTC_diff} = jlib:timestamp_to_iso(Now_universal, utc),
|
||||
Seconds_diff = calendar:datetime_to_gregorian_seconds(Now_local)
|
||||
- calendar:datetime_to_gregorian_seconds(Now_universal),
|
||||
{Hd, Md, _} = case Seconds_diff >= 0 of
|
||||
true ->
|
||||
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}),
|
||||
{Hd, Md, _} = calendar:seconds_to_time(abs(Seconds_diff)),
|
||||
{_, TZO_diff} = jlib:timestamp_to_iso({{0, 0, 0}, {0, 0, 0}}, {sign(Seconds_diff), {Hd, Md}}),
|
||||
Result = #xmlel{ns = ?NS_TIME, name = 'time', children = [
|
||||
#xmlel{ns = ?NS_TIME, name = 'tzo', children = [
|
||||
#xmlcdata{cdata = list_to_binary(TZO_diff)}]},
|
||||
@ -89,3 +83,6 @@ process_local_iq90(_From, _To, #iq{type = get} = IQ_Rec) ->
|
||||
exmpp_iq:result(IQ_Rec, Result);
|
||||
process_local_iq90(_From, _To, #iq{type = set} = IQ_Rec) ->
|
||||
exmpp_iq:error(IQ_Rec, 'not-allowed').
|
||||
|
||||
sign(N) when N < 0 -> "-";
|
||||
sign(_) -> "+".
|
||||
|
Loading…
Reference in New Issue
Block a user