unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Support for sub-second time in decoded time
Date: Mon, 29 Jul 2019 16:12:34 +0200	[thread overview]
Message-ID: <m34l35vsj1.fsf@gnus.org> (raw)
In-Reply-To: <jwvtvb50wqs.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 29 Jul 2019 10:03:30 -0400")

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> `current-time' returns its data as (HIGH LOW USEC PSEC), but now that we
>> have bignum support, perhaps we don't need to do it this way.  What
>> about just having a field in decoded times that's the fraction of a
>> second?  So 34.5603 seconds would be represented as
>>
>> (34 ... 5603)
>
> `encode-time` uses a fraction-representation (NOM . DENOM), which is
> probably easier to manipulate.

You mean internally?  It doesn't seem to be mentioned in the doc string,
but it's an entire essay now...

> [ Note: I find `encode-time` vs `decode-time` very confusing.  ]

I think the pair makes sense on the same level as
{decode,encode}-coding-string does.  That is, encoded time is what Emacs
uses internally for most things, and decoded time is pretty close to
what you er find in nature.

Or at least it used to be; `endode-time' has gotten really complicated
lately, and the doc string doesn't seem to be correct, ether, for some
of the more odd things it apparently does.

(let ((time (current-time)))
  (equal time (encode-time time)))
=> t

(encode-time)
-> Debugger entered--Lisp error: (wrong-number-of-arguments encode-time 0)

But if we ignore all that, it's still conceptually sound.  :-)

---
encode-time is a built-in function in ‘src/timefns.c’.

(encode-time &optional TIME FORM &rest OBSOLESCENT-ARGUMENTS)

  Probably introduced at or before Emacs version 19.29.
  This function does not change global state, including the match data.

Convert optional TIME to a timestamp.
Optional FORM specifies how the returned value should be encoded.
This can act as the reverse operation of ‘decode-time’, which see.

If TIME is a list (SECOND MINUTE HOUR DAY MONTH YEAR IGNORED DST ZONE)
it is a decoded time in the style of ‘decode-time’, so that (encode-time
(decode-time ...)) works.  TIME can also be a time value.
See ‘format-time-string’ for the various forms of a time value.
For example, an omitted TIME stands for the current time.
---

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



  reply	other threads:[~2019-07-29 14:12 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-29  9:48 Support for sub-second time in decoded time Lars Ingebrigtsen
2019-07-29 14:03 ` Stefan Monnier
2019-07-29 14:12   ` Lars Ingebrigtsen [this message]
2019-07-29 14:43     ` Stefan Monnier
2019-07-29 15:00       ` Lars Ingebrigtsen
2019-07-29 17:50         ` Stefan Monnier
2019-07-30 11:33           ` Lars Ingebrigtsen
2019-07-29 16:08     ` encode-time vs decode-time Stefan Monnier
2019-07-30 10:32       ` Lars Ingebrigtsen
2019-07-30 11:34         ` Andy Moreton
2019-07-30 11:37           ` Lars Ingebrigtsen
2019-07-30 17:54             ` Paul Eggert
2019-07-30 22:50               ` Paul Eggert
2019-07-31 19:03               ` Lars Ingebrigtsen
2019-07-31 19:31                 ` Stefan Monnier
2019-08-06  1:48                 ` Paul Eggert
2019-08-06 14:21                   ` Eli Zaretskii
2019-08-06 15:59                     ` Paul Eggert
2019-08-06 18:23                       ` Eli Zaretskii
2019-08-07  1:02                         ` Paul Eggert
2019-08-07  2:41                           ` Stefan Monnier
2019-08-07 14:47                             ` Eli Zaretskii
2019-08-11 23:39                               ` Lars Ingebrigtsen
2019-08-17  6:47                             ` Paul Eggert
2019-08-07 11:33                           ` Lars Ingebrigtsen
2019-08-17  7:54                             ` Paul Eggert
2019-08-17  8:16                               ` Eli Zaretskii
2019-08-17  9:33                                 ` Paul Eggert
2019-08-17 20:46                               ` Lars Ingebrigtsen
2019-08-17 20:56                                 ` Paul Eggert
2019-08-17 21:42                                   ` Stefan Monnier
2019-08-17 22:53                                     ` Paul Eggert
2019-08-19 21:12                                       ` Stefan Monnier
2019-08-21 10:55                                         ` Adam Porter
2019-08-21 20:20                                           ` Paul Eggert
2019-08-26 10:59                                             ` Adam Porter
2019-08-26 21:35                                               ` Paul Eggert
2019-08-07 14:44                           ` Eli Zaretskii
2019-08-07 11:41                   ` Lars Ingebrigtsen
2019-08-17  9:25                     ` Paul Eggert
2019-08-17 20:51                       ` Lars Ingebrigtsen
2019-07-29 14:23 ` Support for sub-second time in decoded time Eli Zaretskii
2019-07-29 14:59   ` Lars Ingebrigtsen
2019-07-29 16:46 ` Paul Eggert
2019-07-30 11:43   ` Lars Ingebrigtsen

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=m34l35vsj1.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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).