* format-time-string bug
@ 2004-04-13 1:54 Marcelo Toledo
2004-04-13 1:49 ` Kenichi Handa
2004-04-13 2:54 ` Danilo Segan
0 siblings, 2 replies; 3+ messages in thread
From: Marcelo Toledo @ 2004-04-13 1:54 UTC (permalink / raw)
A few days ago I was coding something related to time, then I needed to
use the function `format-time-string´ and the code above shows what I
have found wrong:
(setq t1 (current-time))
(sleep-for 3)
(setq t2 (current-time))
(format-time-string "(%H:%M:%S)" (time-subtract t2 t1))
the result of the last expression should be something near 00:00:03.
For me it is appearing 20:00:03. For other people it's appearing
diferent values but never what I am really expecting. Could someone
please try?
time-substract is returning the correct value, in this case something
near (0 3). The data format is a list of 3 integers. The first has the
most significant 16 bits of the seconds, while the second has the least
significant 16 bits. The third integer gives the microsecond count.
I didn't have time to identify witch function is bugged yet, but, if
someone more experienced could identify what is wrong, would be nice.
--
Marcelo Toledo
marcelo@marcelotoledo.org
http://www.marcelotoledo.org
Mobile: 55 71 9141-7181
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: format-time-string bug
2004-04-13 1:54 format-time-string bug Marcelo Toledo
@ 2004-04-13 1:49 ` Kenichi Handa
2004-04-13 2:54 ` Danilo Segan
1 sibling, 0 replies; 3+ messages in thread
From: Kenichi Handa @ 2004-04-13 1:49 UTC (permalink / raw)
Cc: emacs-devel
In article <87zn9g3an9.fsf@kali.intranet>, Marcelo Toledo <marcelo@marcelotoledo.org> writes:
> A few days ago I was coding something related to time, then I needed to
> use the function `format-time-string´ and the code above shows what I
> have found wrong:
> (setq t1 (current-time))
> (sleep-for 3)
> (setq t2 (current-time))
> (format-time-string "(%H:%M:%S)" (time-subtract t2 t1))
> the result of the last expression should be something near 00:00:03.
> For me it is appearing 20:00:03. For other people it's appearing
> diferent values but never what I am really expecting. Could someone
> please try?
20:00:03 is the correct value for you because it seems that
your timezone is -0400. As I'm in JST, I get "09:00:03".
If you want "00:00:03", you must call format-time-string as
below.
> (format-time-string "(%H:%M:%S)" (time-subtract t2 t1) t)
By the way, format-time-string is for time, not for a
period.
---
Ken'ichi HANDA
handa@m17n.org
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: format-time-string bug
2004-04-13 1:54 format-time-string bug Marcelo Toledo
2004-04-13 1:49 ` Kenichi Handa
@ 2004-04-13 2:54 ` Danilo Segan
1 sibling, 0 replies; 3+ messages in thread
From: Danilo Segan @ 2004-04-13 2:54 UTC (permalink / raw)
Cc: emacs-devel
Hi Marcelo,
Today at 3:54, Marcelo Toledo wrote:
> A few days ago I was coding something related to time, then I needed to
> use the function `format-time-string´ and the code above shows what I
> have found wrong:
Since you're passing the value of 1970-01-01 00:00:03 in GMT as the
time-value to format-string, you probably ought to try adding optional
parameter to format-time-string:
(format-time-string "(%H:%M:%S)" (time-subtract t2 t1) t)
^ note this
I somehow suspect that you're in GMT-4 timezone ;)
So, I doubt there's any bug here.
Cheers,
Danilo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-04-13 2:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-13 1:54 format-time-string bug Marcelo Toledo
2004-04-13 1:49 ` Kenichi Handa
2004-04-13 2:54 ` Danilo Segan
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).