[ejabberd] mod_time

Badlop badlop at gmail.com
Wed Sep 21 14:11:36 MSK 2016


If you mean to provide result with resolution up to milliseconds, here
is a quick and dirty patch:

--- a/src/mod_time.erl
+++ b/src/mod_time.erl
@@ -61,6 +61,7 @@ process_local_iq(_From, _To,
         Now_local = calendar:universal_time_to_local_time(Now_universal),
         {UTC, UTC_diff} = jlib:timestamp_to_iso(Now_universal,
                                                 utc),
+         Ms = iolist_to_binary(string:right(integer_to_list(erlang:system_time(milli_seconds)
rem 1000), 3, $0)),
         Seconds_diff =
             calendar:datetime_to_gregorian_seconds(Now_local) -
               calendar:datetime_to_gregorian_seconds(Now_universal),
@@ -79,7 +80,7 @@ process_local_iq(_From, _To,
                                #xmlel{name = <<"utc">>, attrs = [],
                                       children =
                                           [{xmlcdata,
-                                              <<UTC/binary,
+                                              <<UTC/binary, ".", Ms/binary,
                                                UTC_diff/binary>>}]}]}]}
    end.


The result is:
<iq type='get' to='localhost'>
  <query xmlns='urn:xmpp:time'/>
</iq>

<iq from='localhost' to='user1 at localhost/tka1' type='result'>
  <time xmlns='urn:xmpp:time'>
    <tzo>+02:00</tzo>
    <utc>2016-09-21T11:07:12.664Z</utc>
  </time>
</iq>


---
Badlop
ProcessOne

On 14 September 2016 at 09:40, jacob jabber <ejabberd.jacob at gmail.com> wrote:
> hi
> mod_time returns time to seconds, how to change it for returns that to
> millisecond?
> thanks alot.
>
> --
>
> Best Regards
>
> _______________________________________________
> ejabberd mailing list
> ejabberd at jabber.ru
> http://lists.jabber.ru/mailman/listinfo/ejabberd
>


More information about the ejabberd mailing list