[ejabberd] XEP-0202

Samuel Tardieu sam at rfc1149.net
Tue May 29 03:37:50 MSD 2007


>>>>> "Badlop" == Badlop  <badlop at gmail.com> writes:

Badlop> The only important difference I could find is that I don't use
Badlop> calendar:time_difference because that function is marked as
Badlop> obsolete on the Erlang documentation

I tend to prefer your implementation over mine as you are preparing
the deprecation (or removal) of XEP-0090 (and you're not using a
function marked as obsolete as you note above).

However, I think your patch contains a race condition that may
generate a bogus timezone offset:

 Seconds_diff = calendar:datetime_to_gregorian_seconds(calendar:local_time())
  - calendar:datetime_to_gregorian_seconds(calendar:universal_time()),
 {Hd, Md, _} = calendar:seconds_to_time(Seconds_diff),
 {_, TZO_diff} = jlib:timestamp_to_iso({{0, 0, 0}, {0, 0, 0}}, {Hd, Md})

calendar:local_time() and calendar:universal_time() calls may cross a
one-second bounday, in which case you may generate a TZ offset such
as 01:59.

Using now() once and then calendar:now_to_{local,universal}_time will
give a correct result.

Do you agree with this analysis?

  Sam
-- 
Samuel Tardieu -- sam at rfc1149.net -- http://www.rfc1149.net/



More information about the ejabberd mailing list