[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: What do I use if not `float-time'?
From: |
Deniz Dogan |
Subject: |
Re: What do I use if not `float-time'? |
Date: |
Wed, 6 Jan 2010 21:40:53 +0100 |
2010/1/6 Davis Herring <address@hidden>:
>> 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