emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 50 seconds is 1 hour?


From: Davis Herring
Subject: Re: 50 seconds is 1 hour?
Date: Tue, 1 Dec 2009 09:24:41 -0800 (PST)
User-agent: SquirrelMail/1.4.8-5.7.lanl7

> I meant "can't we use it for this too?".

Not really: it can't do anything useful for intervals longer than one day.
 Sure, up to 31 days you can get (n+1)dHHhMMmSSs with the format string
"%dd%Hh%Mm%Ss", but obviously the n+1 is absurdly ugly (trying to fix it
by subtracting 86400 gives 31 rather than 0 for small intervals).  And
after that it's entirely useless; a "month" is not a useful, fixed unit of
time in its reckoning.

The hack thus covers 0-86399 well (if you know you're in that range, so
you don't print the day), and 86400-2678399 in a very silly, broken way,
and it fails for the other 99.94% of time values, including all negative
intervals (which may or may not make sense depending on the application,
but "-3 seconds" or "3 seconds ago" is clearly much more correct than
"31d23h59m57s").  And it can't indicate partial seconds.

Clearly, extending it to handle all this would interfere terribly with its
correct usage.  So, no.  Perhaps you'd like to specify an interface for
the function you'd really like to have?  I'd be willing to write it if I
knew what exactly you wanted it to return.  (For instance, should it omit
fields that are 0?  That is, without varying any formatting arguments that
it might have, should it be able to return "5:34" and "1:00:31" for 334
and 3631 seconds?)

Davis

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]