aboutsummaryrefslogtreecommitdiff
path: root/src/mod_time.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mod_time.erl')
-rw-r--r--src/mod_time.erl13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/mod_time.erl b/src/mod_time.erl
index e96c0ea72..52c52502a 100644
--- a/src/mod_time.erl
+++ b/src/mod_time.erl
@@ -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),
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}}),
IQ#iq{type = result,
sub_el = [{xmlelement, "time",
[{"xmlns", ?NS_TIME}],
@@ -93,4 +87,5 @@ process_local_iq(_From, _To, #iq{type = Type, sub_el = SubEl} = IQ) ->
[{xmlcdata, UTC ++ UTC_diff}]}]}]}
end.
-
+sign(N) when N < 0 -> "-";
+sign(_) -> "+".