Wireshark-dev: [Wireshark-dev] formatted time in dissector

From: Alan Partis <alpartis@xxxxxxxxxxxxxx>
Date: Thu, 5 May 2016 19:59:14 -0400 (EDT)
In the DIS dissector (packet-dis.c), I have constructed an nstime_t var
and populated its .secs and .nsecs fields with calculated values from the
protocol buffer.  I'd like to have this display in the packet dissection
pane in so-called formatted time i.e. "mm:ss.nnnnnn" where 'nnnnnn'
displays to microsecond accuracy.

Right now, the dissector simply calls proto_tree_add_time() and the time
is displayed as a number of seconds with nanoseconds i.e. "ssss.nnnnnnnnn"
with the final 3 digits always showing '000' (because the nstime_t
structure only hold a microsecond accuracy).

To achieve what I want, I've changed the dissector to instead call
proto_tree_add_time_format_value(..., "%02u:%02u.%06u", mm, ss, usec);

While that produces the desired result, it doesn't feel quite right to me.
Is there another way to get a proto_tree_add_time_xxx() function to print
automagically the format I want?  Or did I actually do it right in the
first place?

Thanks.

_______________________________________________________
Alan Partis
thundernet development group