unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Davis Herring" <herring@lanl.gov>
To: "Lennart Borgman" <lennart.borgman@gmail.com>
Cc: Andreas Schwab <schwab@linux-m68k.org>,
	Emacs-Devel devel <emacs-devel@gnu.org>
Subject: Re: 50 seconds is 1 hour?
Date: Tue, 1 Dec 2009 09:24:41 -0800 (PST)	[thread overview]
Message-ID: <48322.130.55.118.19.1259688281.squirrel@webmail.lanl.gov> (raw)
In-Reply-To: <e01d8a50912010744w7994bd0cl6e1316553f94559c@mail.gmail.com>

> 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	other threads:[~2009-12-01 17:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-01 15:14 50 seconds is 1 hour? Lennart Borgman
2009-12-01 15:25 ` Andreas Schwab
2009-12-01 15:28   ` Lennart Borgman
2009-12-01 15:42     ` Andreas Schwab
2009-12-01 15:44       ` Lennart Borgman
2009-12-01 17:24         ` Davis Herring [this message]
2009-12-01 17:34           ` Glenn Morris
2009-12-01 17:37             ` Lennart Borgman
2009-12-01 17:38             ` Davis Herring
2009-12-01 17:34           ` Lennart Borgman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48322.130.55.118.19.1259688281.squirrel@webmail.lanl.gov \
    --to=herring@lanl.gov \
    --cc=emacs-devel@gnu.org \
    --cc=lennart.borgman@gmail.com \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).