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: Sat, 07 Dec 2024 15:02:15 +0200 Message-ID: <86jzcbir3c.fsf@gnu.org> References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> <3530cd89-b5a2-4b25-95bf-1896c8ee4aef@cs.ucla.edu> <8CC4B1BB-B56A-4C3E-8B51-0E2D5B65C296@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39688"; 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 Sat Dec 07 14:03:25 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 1tJuSz-000AAr-35 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 07 Dec 2024 14:03:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJuSd-0003EM-Ud; Sat, 07 Dec 2024 08:03:03 -0500 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 1tJuSc-0003Du-4u for bug-gnu-emacs@gnu.org; Sat, 07 Dec 2024 08:03:02 -0500 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 1tJuSb-0007Aa-SK for bug-gnu-emacs@gnu.org; Sat, 07 Dec 2024 08:03:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=Ny2gIhc0wTaOqodrZgdFd8I6Gw7TWgj3RdeYjEHBsqA=; b=ClGAux/itmLTlHCvU8cvnqxXxEoqOFiLCriTSidoAANxsjm+e6WxJJfv79+tzviUxQjcN18VXxLdLwklNbLr3MpZHC9ooUxExas7RftFd7yobDGLI6M7s0mC9Uncd3Q2r3YZCoJvrWRDy2ks5UD31tpoX1CP1QP4F30CAxyk2eErAGyQWVYptoecgQ4J/L+DId0rJbSCgyhBJa9XSx1VSIYVa5Y2fU6+OgBtfQtAEmIZXgIT4uLehREJSdbPAyAmhNsV5Iby1qS2cIUH7ok96MI94tTd1Jv7mAXrNsyNw7jWYnvsost9QlnVKUMYaw4627IJp3ulkqivt0wjKNuEEw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tJuSb-0003v5-L6 for bug-gnu-emacs@gnu.org; Sat, 07 Dec 2024 08:03:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 07 Dec 2024 13:03:01 +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.173357655415017 (code B ref 71572); Sat, 07 Dec 2024 13:03:01 +0000 Original-Received: (at 71572) by debbugs.gnu.org; 7 Dec 2024 13:02:34 +0000 Original-Received: from localhost ([127.0.0.1]:45895 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJuS9-0003u8-Dw for submit@debbugs.gnu.org; Sat, 07 Dec 2024 08:02:33 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:53508) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJuS7-0003tu-5j for 71572@debbugs.gnu.org; Sat, 07 Dec 2024 08:02:31 -0500 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 1tJuRz-0006zW-LV; Sat, 07 Dec 2024 08:02:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=Ny2gIhc0wTaOqodrZgdFd8I6Gw7TWgj3RdeYjEHBsqA=; b=Eok6KqfTFfC9 Ch5QZiodZBi8DryD6pWcLh4quHSM3oGXuYw5xPVyuf7B4GAJQVblv0nJtEFTs5HrlVuJXSX3nf9cu bt/6Dl5knC2vCJqG3NbfKgkrHzN1TW6+6mH2TUllUd5gnn64a5EMkgbD7IlB/ESI3dHtKosj+JyE2 dqWi4d3ayhe893ZtSnjxnsSGf6MtzpN0/Yw0ZtzWxWQsacsMbG9E4uUo1rhWzPGCZKmg5NJGQc9cn f6EH8dWAMU9/0ATLvZk3nd3OD3jScQP4XVOg/jB/AK/0TdgLlCeVOVzVNF764DyfEu5OVcWASgC+3 RuIq7AtGYrcE9bguM5eRHw==; In-Reply-To: (message from JD Smith on Sat, 30 Nov 2024 13:58:52 -0500) 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:296559 Archived-At: > From: JD Smith > Date: Sat, 30 Nov 2024 13:58:52 -0500 > Cc: Eli Zaretskii , > Adam Porter , > jonas@bernoul.li, > Paul Eggert > > I was recently reminded of the need for a more capable seconds-to-string. > > Anyone have any additional comments on this proposed patch? If not, I'd suggest someone with access > merges. A few minor nits below, and then we can install: > --- a/doc/lispref/os.texi > +++ b/doc/lispref/os.texi > @@ -2155,6 +2155,12 @@ Time Calculations > structure. For instance, the 120th day in 2004 is April 29th. > @end defun > > +@defun seconds-to-string delay &optional readable abbrev precision > +Return a string describing a given @var{delay} (in seconds). Optional > +arguments can be used to configure a human readable delay using various > +formats. For example, a delay of 9861.5 seconds with @var{readable} set > +to the symbol @code{expanded} returns "2 hours 44 minutes". The strings should be in @samp (and then you can drop the quotes). > +** Time & Date > + > ++++ > +*** 'seconds-to-string' includes new arguments to produce human-readable > +delay strings in a variety of formats, for example "6 months 3 weeks" or > +"5m 52.5s". This should have a heading line, which is a single complete sentence. > +(defvar seconds-to-string-readable > + `(("Y" "year" "years" ,(round (* 60 60 24 365.2425))) > + ("M" "month" "months" ,(round (* 60 60 24 30.436875))) > + ("w" "week" "weeks" ,(* 60 60 24 7)) > + ("d" "day" "days" ,(* 60 60 24)) > + ("h" "hour" "hours" ,(* 60 60)) > + ("m" "minute" "minutes" 60) > + ("s" "second" "seconds" 1)) > + "Formatting used by the function `seconds-to-string' with READABLE set.") Please exp.lain in more detail the format of this list's elements, so that people could modify it more easily in the future. > +(defun seconds-to-string (delay &optional readable abbrev precision) > + "Convert time interval DELAY (in seconds) to a short string. ^^^^^^^^^^^^ Why "short"? > +By default, the returned string has two decimal precision in the > +smallest unit that is larger than DELAY from the variable > +`seconds-to-string'. I couldn't parse this sentence. "Two decimal precision"? is that a typo? Thanks.