From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: Support for sub-second time in decoded time Date: Mon, 29 Jul 2019 11:46:14 -0500 Message-ID: <09ec6cb4-af22-52f9-9881-a52f1d0c9cfb@cs.ucla.edu> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="111656"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 Cc: emacs-devel@gnu.org To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 29 18:47:01 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hs8nd-000Sv5-M0 for ged-emacs-devel@m.gmane.org; Mon, 29 Jul 2019 18:47:01 +0200 Original-Received: from localhost ([::1]:55138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hs8nc-0008EM-HY for ged-emacs-devel@m.gmane.org; Mon, 29 Jul 2019 12:47:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33923) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hs8n5-00088Z-DR for emacs-devel@gnu.org; Mon, 29 Jul 2019 12:46:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hs8n4-00014G-EY for emacs-devel@gnu.org; Mon, 29 Jul 2019 12:46:27 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:51916) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hs8n4-0000zc-9Z for emacs-devel@gnu.org; Mon, 29 Jul 2019 12:46:26 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 4F11416007D; Mon, 29 Jul 2019 09:46:20 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id JA3lJtkMxDUc; Mon, 29 Jul 2019 09:46:19 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 978091626D6; Mon, 29 Jul 2019 09:46:19 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id EpgK35dM4mfp; Mon, 29 Jul 2019 09:46:19 -0700 (PDT) Original-Received: from [192.168.0.8] (ip72-206-6-38.fv.ks.cox.net [72.206.6.38]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 55DDC16007D; Mon, 29 Jul 2019 09:46:19 -0700 (PDT) In-Reply-To: Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:239005 Archived-At: On 7/29/19 4:48 AM, Lars Ingebrigtsen wrote: > Currently, encoded time has support for picoseconds. `decode-time' wil= l > throw away all sub-second time, which makes accurate round-tripping > impossible. No, it's quite possible. Say you want a resolution-R broken-down=20 representation of the Lisp timestamp T. Then you can use (decode-time T)=20 to get the broken-down time in seconds, and (mod (car (encode-time T R))=20 R) to get the subsecond part. Once you have that, you're off to the races= . Admittedly it is not that convenient. We could extend decode-time to=20 accept an additional argument FORM that would let the caller specify the=20 form of the returned value. decode-time could treat FORM much like=20 encode-time does, and encode-time would be extended to grok the new=20 forms so round-tripping would be simpler. This would be=20 upward-compatible with the current behavior. For example, under this proposal we'd have: (setq R 1000000000) (setq X (encode-time nil R))=C2=A0 =3D>=C2=A0 (1564418451413082782 . 1000= 000000) (setq Y (decode-time X nil))=C2=A0 =3D>=C2=A0 ((51413082782 . 1000000000)= 40 9 29 7=20 2019 1 t -25200) (equal X (encode-time Y R))=C2=A0 =3D>=C2=A0 t