all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Deniz Dogan <deniz.a.m.dogan@gmail.com>
To: herring@lanl.gov
Cc: Emacs-Devel devel <emacs-devel@gnu.org>
Subject: Re: What do I use if not `float-time'?
Date: Wed, 6 Jan 2010 21:40:53 +0100	[thread overview]
Message-ID: <7b501d5c1001061240s5076734cib932061058b237cb@mail.gmail.com> (raw)
In-Reply-To: <41805.130.55.118.19.1262791780.squirrel@webmail.lanl.gov>

2010/1/6 Davis Herring <herring@lanl.gov>:
>> Okay, so what do I use instead? I just want a "UNIX timestamp" as an
>> integer or string. What's the idiomatic way to get that?
>
> Use `current-time'.  The trick is that you then have to deal with multiple
> integers (because Emacs ints are (often) shorter than 32 bits).
> `float-time' exists to avoid that inconvenience at the cost of another.
> In practice, using the integer parts of calls to (float-time) should be
> fine so long as you don't do too much arithmetic on them: doubles have 53
> bits of mantissa, and so can represent any reasonable traditional
> (integer) time stamp exactly.
>
> To get a string version of the integer part (which you can't safely turn
> into an integer!), you can just use (format-time-string "%s").
>

Thanks, the `format-time-string' trick works like a charm. I actually
needed a string in the first place, so that was perfect.

-- 
Deniz Dogan




      parent reply	other threads:[~2010-01-06 20:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-06 15:15 What do I use if not `float-time'? Deniz Dogan
2010-01-06 15:29 ` Davis Herring
2010-01-06 20:27   ` Juri Linkov
2010-01-07  1:08     ` Stephen J. Turnbull
2010-01-06 20:40   ` Deniz Dogan [this message]

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

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

  git send-email \
    --in-reply-to=7b501d5c1001061240s5076734cib932061058b237cb@mail.gmail.com \
    --to=deniz.a.m.dogan@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=herring@lanl.gov \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.