From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#71572: [PATCH] seconds-to-string-approximate Date: Thu, 04 Jul 2024 08:29:03 +0300 Message-ID: <86msmxafog.fsf@gnu.org> References: <86r0cpicwt.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21114"; mail-complaints-to="usenet@ciao.gmane.io" Cc: adam@alphapapa.net, 71572@debbugs.gnu.org, jonas@bernoul.li, eggert@cs.ucla.edu To: JD Smith Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 04 07:32:19 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sPF4s-0005I2-JX for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Jul 2024 07:32:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sPF4d-0006yN-8c; Thu, 04 Jul 2024 01:32:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sPF4b-0006xl-Dd for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2024 01:32:01 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sPF4b-0000gm-4l for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2024 01:32:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sPF4c-000270-9a for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2024 01:32:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Jul 2024 05:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71572 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 71572-submit@debbugs.gnu.org id=B71572.17200710908065 (code B ref 71572); Thu, 04 Jul 2024 05:32:02 +0000 Original-Received: (at 71572) by debbugs.gnu.org; 4 Jul 2024 05:31:30 +0000 Original-Received: from localhost ([127.0.0.1]:41241 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPF45-000260-QW for submit@debbugs.gnu.org; Thu, 04 Jul 2024 01:31:30 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:49512) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPF42-00025k-OH for 71572@debbugs.gnu.org; Thu, 04 Jul 2024 01:31:28 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sPF1l-0008E6-Rx; Thu, 04 Jul 2024 01:29:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=aXYx2ukH6/uJCo8VQ8OIPcCyTQQ3mjfXjF59vqIjtlc=; b=pTjtC4kni5+RJhqvpX7j O/lJ/enML+NB8LXhdYyiyjEtrSMFtLTP5tB0Oev45MBWi/2mf/vsDL9xH+/m5cjeMOdqu6oqH3D9L Jti5Ny02MWJxYT94tQKrzBqlhO0uJejhMvH6gyArYf80GDIGvZ+3dZ6OX3Tg2zIu1yQR89k41v9eu uEvs+iL9USNDnirxoIw5MpalRVzAC9pUhF/uJ47eo71FIe4Mzyv9vucu6EMwuNzjt0YfQdyLmVC08 SjoEqlXinX1hLO8BB3mX5PiuIcKH8QVDzCkgEzkiIMeyPvIL1ff4SIeutVw6DzfaXzdvd0lsb6qjQ kJezi5Oc5UUhVA==; In-Reply-To: (message from JD Smith on Sat, 22 Jun 2024 22:16:40 -0400) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:288344 Archived-At: > From: JD Smith > Date: Sat, 22 Jun 2024 22:16:40 -0400 > Cc: Eli Zaretskii , > 71572@debbugs.gnu.org, > Adam Porter , > jonas@bernoul.li > > > Why not look at what mastodon.el does, as the comment in seconds-to-string suggests? For example, mastodon-tl--human-duration lets you specify whatever resolution you want, instead of limiting you to either 0.5 or 1 as in the proposed patch. > > I see that mastodon is a package in ELPA, so doesn't satisfy the need in core. I took a look at this function. The RESOLUTION mentioned is not equivalent to the HALF argument, it is the minimum resolution in seconds. So setting it to e.g. 3600 results in truncating to the hour, but changes nothing below the hour. Setting it to the number of seconds in a year gives something quite similar to magit--age (though I notice the mastodon function truncates, instead of rounds; see, e.g., 2.98y in the table below). > > Here's a comparison among: > > - the current seconds-to-string > - mastodon-tl--human-duration > - mastodon with a 3600s resolution > - mastodon with 1yr "resolution" > - the new seconds-to-string with option READABLE=t > - new seconds-to-string with abbreviated units and half unit resolution > > Delay (s) s-to-s mastodon mastodon (3600s) mast (1yr) s-to-s (rdb) s-to-s (rdb=abbrev, half) > 0.5 450.00ms 0 sec 0 sec 0 sec 0 seconds ½s > 1.0 1.03s 1 sec 1 sec 1 sec 1 second 1s > 2.4 2.38s 2 secs 2 secs 2 secs 2 seconds 2½s > 5.5 5.48s 5 secs 5 secs 5 secs 5 seconds 5½s > 12.6 12.59s 12 secs 12 secs 12 secs 13 seconds 12½s > 29.0 28.96s 28 secs 28 secs 28 secs 29 seconds 29s > 66.6 66.62s 1 min 1 min 1 min 1 minute 1m > 153.2 2.55m 2 mins 2 mins 2 mins 3 minutes 2½m > 352.4 5.87m 5 mins 5 mins 5 mins 6 minutes 6m > 810.5 13.51m 13 mins 13 mins 13 mins 14 minutes 13½m > 1864.2 31.07m 31 mins 31 mins 31 mins 31 minutes 31m > 4287.6 71.46m 1 hour, 11 mins 1 hour 1 hour 1 hour 1h > 9861.6 2.74h 2 hours, 44 mins 2 hours 2 hours 3 hours 2½h > 22681.6 6.30h 6 hours, 18 mins 6 hours 6 hours 6 hours 6½h > 52167.8 14.49h 14 hours, 29 mins 14 hours 14 hours 14 hours 14½h > 119985.9 1.39d 1 day, 9 hours 1 day, 9 hours 1 day 1 day 1½d > 275967.5 3.19d 3 days, 4 hours 3 days, 4 hours 3 days 3 days 3d > 634725.2 7.35d 1 week 1 week 1 week 1 week 1w > 1459867.9 16.90d 2 weeks, 2 days 2 weeks, 2 days 2 weeks 2 weeks 2½w > 3357696.2 38.86d 1 month, 1 week 1 month, 1 week 1 month 1 month 1½M > 7722701.2 89.38d 2 months, 4 weeks 2 months, 4 weeks 2 months 3 months 3M > 17762212.9 205.58d 6 months, 3 weeks 6 months, 3 weeks 6 months 7 months 7M > 40853089.6 1.29y 1 year, 3 months 1 year, 3 months 1 year 1 year 1½Y > 93962106.0 2.98y 2 years, 11 months 2 years, 11 months 2 years 3 years 3Y > 216112843.8 6.85y 6 years, 10 months 6 years, 10 months 6 years 7 years 7Y > 497059540.7 15.75y 15 years, 9 months 15 years, 9 months 15 years 16 years 16Y Basically, this shows that: . mastodon truncates where seconds-to-string rounds . seconds-to-string lacks the "1 hour 11 min" output format . seconds-to-string sometimes produces inaccurate results, as in 5.5 => 5.48s The last item worries me: can we fix this, please? The second item sounds like a useful feature, so maybe an optional behavior could provide it as well? Thanks.