[rrd-developers] Re: Printing of time component

Tobias Oetiker oetiker at ee.ethz.ch
Thu Aug 9 22:39:52 MEST 2001

Today Alex van den Bogaerdt wrote:

 | Hi,
 | Can you please tell me if I'm on the right track here:
 | The VDEF variables have both a value (rate) component and a
 | time component.  Printing the rate is no problem, this is
 | already implemented and seems to work.  Now for printing the
 | time component:
 | 1) Which set of formatters can be used.  Doing a man strftime on
 |    a linux system shows that there may be some formatters that
 |    are not available on each system.  Is there a place where I can
 |    find a "safe set" of them, is it better to program everything
 |    myself (not a problem but seems to be re-inventing the wheel) or
 |    should I just use strftime and let each user find out which one
 |    can or cannot be used?  I'm particullarry worried about the
 |    availability of '%s' which I assume not to be so wide-spread as
 |    other strings.
 | 2) There is a little problem with %S (seconds) and %s (time since
 |    the epoch) as they are also used by value printing.  It seems to
 |    me that it is easy to define some parsing rules.  If the parser
 |    fails to do it right, the PRINT can be separated into two different
 |    ones and everything will be all right.
 |    a) If a value is printed and the next formatter string is %s or %S,
 |       a SI unit is substituted
 |    b) If no value is printed, it must mean time
 |    c) If a value is printed but between this value and the %s there is
 |       some other formatter, it means time.
 |    This means "%6.2lf %sbps" or "%6.2lf %Sbps will print 123.45 kbps,
 |    and "%6.2lf %H:%S" will print 123.45 23:15
 |    If you really want "%6.2lf %s" to print 123.45 997382402, then
 |    it should be programmed as two different (G)PRINTS.
what I would do, is use whatever strftime you get from the system
how about this. You tell people that they have to use two %% for
the lf part and one % for the strformat part ... this has the
effect the first the time gets resolved which also turns %% into %
and then you run it through printf which resolves the rest ...


"%%6.2lf %Y-%m-%d"

writing your own implementation of strftime looks a bit like
overkill ...



 ______    __   _
/_  __/_  / /  (_) Oetiker, ETZ J97, ETH, 8092 Zurich, Switzerland
 / // _ \/ _ \/ / phoneto:+41(0)1-632-5286  faxto:+41(0)1-632-1517
/_/ \.__/_.__/_/ mailto:oetiker at ee.ethz.ch http://people.ee.ethz.ch/~oetiker

Unsubscribe mailto:rrd-developers-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-developers-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-developers
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi

More information about the rrd-developers mailing list