unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: lawrence mitchell <wence@gmx.li>
Subject: Re: How to: 96 bit Date-time arithmetic?
Date: Sat, 31 Aug 2002 21:49:08 +0100	[thread overview]
Message-ID: <wkptvyah4r.fsf@ID-97657.usr.dfncis.de> (raw)
In-Reply-To: un22ak65c7svc3@corp.supernews.com

Siegfried Heintze wrote:

> While I am still curious about 96 bit arithmetic, here an alternative
> attempt. Why does not it work?

> (setq x (decode-time (current-time)))
> (setq y (list (car x) (cadr x)  (caddr x) (1- (cadddr x))
>        (nth 5 x) (nth 6 x) (nth 7 x)(nth 8 x) ))
       ^ (nth 4 x)
> (apply 'encode-time x) ; no error

> (apply 'encode-time y) ; error -- why?

in `nth', N counts from zero.

Hence you want (nth 4 x) before (nth 5 x)
Notice that:

(length x)
    => 9
(length y)
    => 8

I'd probably do
(setcar (nthcdr 3 x) (1- (nth 3 x)))
instead, as it's somewhat easier to read.

On another note of style, you probably don't want to use setq
unless you've already bound x in a `let' form, or x is indeed a
global variable. e.g.
(let ((x (decode-time (current-time))))
  (setcar (nthcdr 3 x) (1- (nth 3 x)))
  x)
To return the modified value of x.
-- 
lawrence mitchell <wence@gmx.li>

  reply	other threads:[~2002-08-31 20:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-31 15:39 How to: 96 bit Date-time arithmetic? Siegfried Heintze
2002-08-31 18:21 ` Siegfried Heintze
2002-08-31 20:49   ` lawrence mitchell [this message]
2002-09-04  7:57 ` Christian Lemburg
2002-09-04 13:58   ` Alan Shutko

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=wkptvyah4r.fsf@ID-97657.usr.dfncis.de \
    --to=wence@gmx.li \
    /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.
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).