25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-26 16:26:24 +01:00

Support timezone West of UTC (thanks to Edwin Fine)(EJAB-1301)

This commit is contained in:
Badlop 2010-09-13 12:05:10 +02:00
parent 4b5b98b465
commit 813022aec1

View File

@ -59,7 +59,13 @@ process_local_iq(_From, _To, #iq{type = get} = IQ_Rec) ->
{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, _} = calendar:seconds_to_time(Seconds_diff), {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}), {_, TZO_diff} = jlib:timestamp_to_iso({{0, 0, 0}, {0, 0, 0}}, {Hd, Md}),
Result = #xmlel{ns = ?NS_TIME, name = 'time', children = [ Result = #xmlel{ns = ?NS_TIME, name = 'time', children = [
#xmlel{ns = ?NS_TIME, name = 'tzo', children = [ #xmlel{ns = ?NS_TIME, name = 'tzo', children = [