From unknown Sat Jun 21 10:11:45 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#71572 <71572@debbugs.gnu.org> To: bug#71572 <71572@debbugs.gnu.org> Subject: Status: [PATCH] seconds-to-string-approximate Reply-To: bug#71572 <71572@debbugs.gnu.org> Date: Sat, 21 Jun 2025 17:11:45 +0000 retitle 71572 [PATCH] seconds-to-string-approximate reassign 71572 emacs submitter 71572 JD Smith severity 71572 wishlist tag 71572 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 15 13:24:25 2024 Received: (at submit) by debbugs.gnu.org; 15 Jun 2024 17:24:25 +0000 Received: from localhost ([127.0.0.1]:34681 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sIX8a-0004A0-TH for submit@debbugs.gnu.org; Sat, 15 Jun 2024 13:24:25 -0400 Received: from lists.gnu.org ([209.51.188.17]:40970) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sIX8X-00049g-Vh for submit@debbugs.gnu.org; Sat, 15 Jun 2024 13:24:23 -0400 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 1sIX8W-0004Uh-Rb for bug-gnu-emacs@gnu.org; Sat, 15 Jun 2024 13:24:20 -0400 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sIX8S-0008FO-Gx for bug-gnu-emacs@gnu.org; Sat, 15 Jun 2024 13:24:18 -0400 Received: by mail-qk1-x734.google.com with SMTP id af79cd13be357-7953f1dcb01so246213885a.3 for ; Sat, 15 Jun 2024 10:24:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718472254; x=1719077054; darn=gnu.org; h=to:cc:date:message-id:subject:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=tEgXJ0zt2kVwQ7fz1Bay67qQEr2ZrCy6pptRY+wP0hA=; b=DNxRcji5wZt4+zQpLfoVYJJIqIIGVqe8X5vgMBh6fiJHwkNYYvCQL2OeMuS1atN9Z9 Qm/ZH7lTYDJgJiHagQQhJfSd3i422idtV6ZN/BDn+FOj28x1UR8PWcwlf7IRQrZu47wX 2y4YgoR7z0y3cEuj/LRjrFMJupKK52Vis8dnI32hRtmCCpA4OjKSqthzZ00d9/XDqINP rJQzCA22SUpMR6ObM9TP3lZU/78oc1UVFXErjkoFJk+gvWviVxjMshYs59W5cZvef0iv ITFhmd4CuIIsZEQErU6XEl+stvtF+PoUBXcdC8ofOS/mV4ug1pj24ePfMQ47HSnv6rfN 6clQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718472254; x=1719077054; h=to:cc:date:message-id:subject:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=tEgXJ0zt2kVwQ7fz1Bay67qQEr2ZrCy6pptRY+wP0hA=; b=I0J9+JZknYhFg+VcUZCs70CNcDoMjaEYPXcel+WRPPk17vyL2VqmBkfv9IbvSRE4UO nXwQvFDdmXeh8FJsSqxirMAfrTBfMOld+pnV7Eb+vumhUCE7LabWLoMwsKtCCsqA1/cS N2PRVDGiD7rILx4DMexKSYqXNkrmiPybRXShdR34GmZ9q9L9XnaBWkgjC1lIO/4Wg7tv z18bOZUn9pDg3zLq7GmWFw5ZRS4eA1DsjK8QITkKgeKZ7nihk04kGof5iU637RlIiBnT KKcKl5qmSNGt4gsmotu9pHReae4vJ8JaCHDKH1zgwmu6UV3ltotrZUsDWD4jsJpT0uqX Of6g== X-Gm-Message-State: AOJu0Yz9lMaXczWagCmkQ0jYNjkDDW6ogiM6bcJBKQE+Y/ZeOL+uRwq2 ZYgJt9a1h5/7+2tYaf6rtykxM4UurNK0MKgtVOiS9vfELoCdGzYVf6NBiA== X-Google-Smtp-Source: AGHT+IEYqAEllbKn9bIHhxWIUOJq1ZlStZPX8gi/B2KBjS4lwQqNL/rxZYlI7dI3HdxS0W5B0OSYnw== X-Received: by 2002:a05:620a:254b:b0:795:4745:df49 with SMTP id af79cd13be357-798d26a392amr629568085a.65.1718472253775; Sat, 15 Jun 2024 10:24:13 -0700 (PDT) Received: from smtpclient.apple (cm-24-53-187-34.buckeyecom.net. [24.53.187.34]) by smtp.gmail.com with ESMTPSA id af79cd13be357-798aaeeba56sm263067185a.52.2024.06.15.10.24.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Jun 2024 10:24:13 -0700 (PDT) From: JD Smith Content-Type: multipart/mixed; boundary="Apple-Mail=_DF256C8E-CD44-4309-983F-3A06CCC42DF6" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: [PATCH] seconds-to-string-approximate Message-Id: Date: Sat, 15 Jun 2024 13:24:00 -0400 To: bug-gnu-emacs@gnu.org X-Mailer: Apple Mail (2.3774.600.62) Received-SPF: pass client-ip=2607:f8b0:4864:20::734; envelope-from=jdtsmith@gmail.com; helo=mail-qk1-x734.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: Adam Porter , jonas@bernoul.li X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --Apple-Mail=_DF256C8E-CD44-4309-983F-3A06CCC42DF6 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 A very useful and widely used time operation is to approximate a given = delay or age (in seconds) using a human-readable unit =E2=80=94 think "2 = hours", "5 days", "3 weeks", or "7 months". We have = `seconds-to-string', but it provides more precision than is often = required, skips some meaningful "human readable" duration units like = weeks and months, and uses abbreviated units exclusively. =20 For those familiar with magit, the `magit--age' function has provided = this capability for quite some time (e.g. for short commit age), and = other packages have adapted it. It would be useful to have a version in = core. This patch provides a `seconds-to-string-approximate' function based = loosely on `magit--age' and `seconds-to-string'. It allows using = abbreviated or full units, and can optionally round to the nearest = half-unit. --Apple-Mail=_DF256C8E-CD44-4309-983F-3A06CCC42DF6 Content-Disposition: attachment; filename=seconds-to-string-approximate.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="seconds-to-string-approximate.patch" Content-Transfer-Encoding: quoted-printable diff=20--git=20a/lisp/calendar/time-date.el=20= b/lisp/calendar/time-date.el=0Aindex=20eca80f1e8b6..079001bafe2=20100644=0A= ---=20a/lisp/calendar/time-date.el=0A+++=20b/lisp/calendar/time-date.el=0A= @@=20-420,6=20+420,37=20@@=20seconds-to-string=0A=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(<=3D=20(car=20= here)=20delay)))=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20(concat=20= (format=20"%.2f"=20(/=20delay=20(car=20(cddr=20here))))=20(cadr=20= here))))))=0A=20=0A+(defvar=20seconds-to-string-approximate=0A+=20=20= `(("Y"=20"year"=20=20=20"years"=20=20=20,(round=20(*=2060=2060=2024=20= 365.2425)))=0A+=20=20=20=20("M"=20"month"=20=20"months"=20=20,(round=20= (*=2060=2060=2024=2030.436875)))=0A+=20=20=20=20("w"=20"week"=20=20=20= "weeks"=20=20=20,(*=2060=2060=2024=207))=0A+=20=20=20=20("d"=20"day"=20=20= =20=20"days"=20=20=20=20,(*=2060=2060=2024))=0A+=20=20=20=20("h"=20= "hour"=20=20=20"hours"=20=20=20,(*=2060=2060))=0A+=20=20=20=20("m"=20= "minute"=20"minutes"=2060)=0A+=20=20=20=20("s"=20"second"=20"seconds"=20= 1))=0A+=20=20"Formatting=20used=20by=20the=20function=20= `seconds-to-string-approximate'.")=0A+;;;###autoload=0A+(defun=20= seconds-to-string-approximate=20(delay=20&optional=20abbreviate=20half)=0A= +=20=20"Convert=20the=20time=20interval=20DELAY=20in=20seconds=20to=20a=20= string=20approximation.=0A+Abbreviate=20the=20units=20if=20ABBREVIATE=20= is=20non-nil.=20=20If=20HALF=20is=20non-nil,=0A+round=20to=20the=20= nearest=20half-unit,=20otherwise=20round=20to=20the=20nearest=20unit."=0A= +=20=20(cond=20((>=200=20delay)=0A+=20=20=20=20=20=20=20=20=20(concat=20= "-"=20(seconds-to-string-approximate=20(-=20delay)=20abbreviate=20= half)))=0A+=20=20=20=20=20=20=20=20((=3D=20(round=20delay=20(if=20half=20= 0.5=201.))=200)=0A+=20=20=20=20=20=20=20=20=20(format=20"0%s"=20(if=20= abbreviate=20"s"=20"=20seconds")))=0A+=20=20=20=20=20=20=20=20(t=20(let=20= ((stsa=20seconds-to-string-approximate)=20here=20cnt)=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20(while=20(and=20(setq=20here=20(pop=20stsa))=20stsa=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(<=20(/=20delay=20(nth=203=20here))=201)))=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20(setq=20cnt=20(round=20(/=20(float=20delay)=20(nth=203=20= here))=20(if=20half=200.5=201.)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20(concat=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20(let=20((c=20(if=20= half=20(/=20cnt=202)=20cnt)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(if=20(>=20c=200)=20(number-to-string=20c)=20""))=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(if=20(and=20half=20(=3D=20(mod=20cnt=202)=20= 1))=20"=C2=BD"=20"")=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20(if=20= abbreviate=20""=20"=20")=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (cond=20(abbreviate=20(car=20here))=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20((<=3D=20cnt=20(if=20half=202=201))=20(nth=201=20= here))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(t=20= (nth=202=20here))))))))=0A+=0A=20(defun=20date-days-in-month=20(year=20= month)=0A=20=20=20"The=20number=20of=20days=20in=20MONTH=20in=20YEAR."=0A= =20=20=20(unless=20(and=20(numberp=20month)=20(<=3D=201=20month=2012))=0A= --Apple-Mail=_DF256C8E-CD44-4309-983F-3A06CCC42DF6-- From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 15 14:05:11 2024 Received: (at control) by debbugs.gnu.org; 15 Jun 2024 18:05:11 +0000 Received: from localhost ([127.0.0.1]:37538 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sIXm2-0005zm-LN for submit@debbugs.gnu.org; Sat, 15 Jun 2024 14:05:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:41848) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sIXlx-0005yl-Dj; Sat, 15 Jun 2024 14:05:06 -0400 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 1sIXJu-0002CH-MI; Sat, 15 Jun 2024 13:36:06 -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=DiXeSMmNTyG6TCNdz0dvi5dKl4hhbuH3uEHKrna1FKY=; b=lIx1FGSQVAGckmH3UQ90 UefpTybSDyF0/N+I3dMvbL9CKhul+ewKbGr7fkL/OaNKS19Ybdha6rXSeePWh5b61sTqOtSt+5cAB KqbJUoDCfqBPIyTyF3iO3jFeWVHMnu04tq2ot9cX18ONjnqza9p4b7YwKlyQv0eBwGR3y0LRKLdju DUOY0mVPWGhq+HQYn93ow21nMJgaLxW9PFSj4OeW2rj+wIAoO02InL1oC0lobM5gExV3Y/TsgXkLT vKaACWh+gbFQhvmFI/G6yn4CqwfjTGD2Df2qZk1cpqAQkw6cWXWYz6sEZawAt47LzaCR367WLpaqq TG67wxQReuvPDw==; Date: Sat, 15 Jun 2024 20:36:01 +0300 Message-Id: <8634pet8fy.fsf@gnu.org> From: Eli Zaretskii To: JD Smith In-Reply-To: (message from JD Smith on Sat, 15 Jun 2024 13:24:00 -0400) Subject: Re: bug#71573: [PATCH] seconds-to-string-approximate References: MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control Cc: 71573@debbugs.gnu.org, adam@alphapapa.net, jonas@bernoul.li X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) merge 71573 71572 thanks > Cc: Adam Porter , jonas@bernoul.li > From: JD Smith > Date: Sat, 15 Jun 2024 13:24:00 -0400 > A very useful and widely used time operation is to approximate a given delay or age (in seconds) using a human-readable unit — think "2 hours", "5 days", "3 weeks", or "7 months". We have `seconds-to-string', but it provides more precision than is often required, skips some meaningful "human readable" duration units like weeks and months, and uses abbreviated units exclusively. > > For those familiar with magit, the `magit--age' function has provided this capability for quite some time (e.g. for short commit age), and other packages have adapted it. It would be useful to have a version in core. > > This patch provides a `seconds-to-string-approximate' function based loosely on `magit--age' and `seconds-to-string'. It allows using abbreviated or full units, and can optionally round to the nearest half-unit. This is a duplicate of bug#71572, merging. From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 22 04:45:37 2024 Received: (at 71572) by debbugs.gnu.org; 22 Jun 2024 08:45:37 +0000 Received: from localhost ([127.0.0.1]:44338 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sKwNM-0000AE-NJ for submit@debbugs.gnu.org; Sat, 22 Jun 2024 04:45:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45050) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sKwNK-0000A1-Ub for 71572@debbugs.gnu.org; Sat, 22 Jun 2024 04:45:36 -0400 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 1sKwND-0008Ow-2o; Sat, 22 Jun 2024 04:45:27 -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=9aD5uk5ae2313Kw03hBKg5dYtZojPx4ohBB/+gJ92ag=; b=LyOHKdU5CnHvAWBh8fln VW8RL+qxDARzBxUD2pZvNABXWZcMSvCC0nQrrMKzea+QyEMHyUX2vR7xXaVJj2vbJfRo9nqm+k6L/ oTUfwzk+BE/isUNG6Zy7QTZiJ8mGX0riAmUdvP4hqLLeaPU5TwhadjKsVQkJJ3ccWtNbR056UAySO bYsa8UHJ6gJb/eBu6Hzv8qE55exgyxO0YRlxhhuk/iTlfybF0RcwWk2gvlmikqMBb6pBQqIkcrJiw QjinC9sZqepJDLYjmPsD2Joy7qtyU9ov+l5XOyZuPAkyWuz2twNvrMHR1/0u+7fEwN22dZn7HyWdu w2EcdZKSgiKDwg==; Date: Sat, 22 Jun 2024 11:45:22 +0300 Message-Id: <86r0cpicwt.fsf@gnu.org> From: Eli Zaretskii To: JD Smith , Paul Eggert In-Reply-To: (message from JD Smith on Sat, 15 Jun 2024 13:24:00 -0400) Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate References: MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 71572 Cc: adam@alphapapa.net, 71572@debbugs.gnu.org, jonas@bernoul.li X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Cc: Adam Porter , jonas@bernoul.li > From: JD Smith > Date: Sat, 15 Jun 2024 13:24:00 -0400 > > A very useful and widely used time operation is to approximate a given delay or age (in seconds) using a human-readable unit — think "2 hours", "5 days", "3 weeks", or "7 months". We have `seconds-to-string', but it provides more precision than is often required, skips some meaningful "human readable" duration units like weeks and months, and uses abbreviated units exclusively. > > For those familiar with magit, the `magit--age' function has provided this capability for quite some time (e.g. for short commit age), and other packages have adapted it. It would be useful to have a version in core. > > This patch provides a `seconds-to-string-approximate' function based loosely on `magit--age' and `seconds-to-string'. It allows using abbreviated or full units, and can optionally round to the nearest half-unit. Paul, any comments to the patch? From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 22 17:56:45 2024 Received: (at 71572) by debbugs.gnu.org; 22 Jun 2024 21:56:45 +0000 Received: from localhost ([127.0.0.1]:33470 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sL8iy-0005va-Un for submit@debbugs.gnu.org; Sat, 22 Jun 2024 17:56:45 -0400 Received: from crab.oak.relay.mailchannels.net ([23.83.215.42]:54329) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sL8ix-0005vQ-75 for 71572@debbugs.gnu.org; Sat, 22 Jun 2024 17:56:43 -0400 X-Sender-Id: dreamhost|x-authsender|adam@alphapapa.net Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id A9EAF5C1F21; Sat, 22 Jun 2024 21:56:41 +0000 (UTC) Received: from pdx1-sub0-mail-a235.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 54B3F5C16AB; Sat, 22 Jun 2024 21:56:41 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1719093401; a=rsa-sha256; cv=none; b=VWkyaLFmFfOyTuQtUMfixVFIaFrj8GZJXlxGuYwBwxUA8VJPiFVIAHBnjAqQw+C89xefmw xP4JYM4yGEAACEOyhvkOTi5IM058S5NnJuQt/MOd9DuuQXNL1rM8hQ9d3Dv9URuGZJt+Hp QJqERbrk9vEQ04liFbvkOBMhPIgfjNzVsiJpUVcM/JXaE8HyvlBfrtYBUfJ7vAY9EJ6gDt o+yO6fPMYwrCLez7/1BKBPMEtwnVy0Nhc4jHs60WGtvtWg08edKPw1lJTaT+/Shp8xpMeI FBsjW+H88+0qlnbeqrUPi9Ci/5gr3Y/G8jv+eMH9OWHTuWJZ2pbLZnQOiMfHvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1719093401; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eSKRsPT74GkfYnbCqCE8EJtI34StjHqHOT8QDV8tdLQ=; b=qSnHTQ1jF1COltz2nyYsC8YxN5p9SBO3cKZzaGD434xAVGZIdTD/R7rRyEaaK6eI3QCYIc ROgnl7tUqcEeUDGLfp/jEXstlbm+4HIe4Jme5RNLv+eiiinkCe7Y5tIm606GMTQFvDCvVs 5X9DR6otcqmB/VC+NtyDc5nccRtuOYUrhnig+y7YSGR5haGP6+EudVDk0b8HeXzF7CQ2eM 3nzOrIPaHsedRqtZFGYgvqag6Ugj8Oc1RdXbR5aXmg0NFcPVv3eNtCANLsvJTsyfjcYhjC C1IglOen4ZpaLolx9mjhzlUr3YE36pVIbn+nVDq2SrczNns2jkebVs5LJoiFhA== ARC-Authentication-Results: i=1; rspamd-79677bdb95-965kd; auth=pass smtp.auth=dreamhost smtp.mailfrom=adam@alphapapa.net X-Sender-Id: dreamhost|x-authsender|adam@alphapapa.net X-MC-Relay: Junk X-MailChannels-SenderId: dreamhost|x-authsender|adam@alphapapa.net X-MailChannels-Auth-Id: dreamhost X-Versed-Daffy: 1fa990c756dccb08_1719093401592_2373822015 X-MC-Loop-Signature: 1719093401592:1901154522 X-MC-Ingress-Time: 1719093401592 Received: from pdx1-sub0-mail-a235.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.121.33.136 (trex/6.9.2); Sat, 22 Jun 2024 21:56:41 +0000 Received: from [10.17.178.125] (unknown [172.98.33.7]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: adam@alphapapa.net) by pdx1-sub0-mail-a235.dreamhost.com (Postfix) with ESMTPSA id 4W67NS4P5fz2D; Sat, 22 Jun 2024 14:56:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alphapapa.net; s=dreamhost; t=1719093401; bh=eSKRsPT74GkfYnbCqCE8EJtI34StjHqHOT8QDV8tdLQ=; h=Date:Subject:To:Cc:From:Content-Type:Content-Transfer-Encoding; b=IR23DR+eIedIpVfkkC1O1lHIfHEIF+5qg93dEqSeakdgqNuNrCDVb8Gacto/zATxa R428snOCM7JwdehdoqbXjr/o638nohwkvJNJoRCsCRPUZAEQOLHFWD3FH6WcFsykp4 6SasfFMYYcdpI6N7gUKA3DYvbizOWlYR1Ws9n/xpK+L7sdgZ/2qwAQoJcj8EEuVfc7 ywwavyLod944dqngjp9Tn5fBP33FhgzuBu2PDrq9m7CIpW83pV+J+Dc4AmHyceFf/y 4tuRTKcPmBa30BBaA4XEk0f/OyI9mcZzc7YDmId9bLyI2hJO2w5h2tGa3SzFJY0Mdc YNNyUkXgQ7peg== Message-ID: <86def446-b00d-4127-b5eb-b3fd7859e869@alphapapa.net> Date: Sat, 22 Jun 2024 16:56:39 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate To: Eli Zaretskii , JD Smith , Paul Eggert References: <86r0cpicwt.fsf@gnu.org> Content-Language: en-US From: Adam Porter In-Reply-To: <86r0cpicwt.fsf@gnu.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.6 (/) X-Debbugs-Envelope-To: 71572 Cc: 71572@debbugs.gnu.org, jonas@bernoul.li X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.4 (/) May I also recommend that the function be benchmarked, and potentially that it be profiled and optimized if needed? A function like this may be used on hundreds or even thousands of items in a single operation (e.g. formatting a long list of items into a vtable), so it's important that it not be too slow. I don't think I've seen mention of performance yet (forgive me if I missed it). From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 22 19:42:37 2024 Received: (at 71572) by debbugs.gnu.org; 22 Jun 2024 23:42:37 +0000 Received: from localhost ([127.0.0.1]:36246 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sLANR-0000hj-2m for submit@debbugs.gnu.org; Sat, 22 Jun 2024 19:42:37 -0400 Received: from mail.cs.ucla.edu ([131.179.128.66]:44882) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sLANP-0000hR-Bl for 71572@debbugs.gnu.org; Sat, 22 Jun 2024 19:42:36 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 9390E3C011BC5; Sat, 22 Jun 2024 16:42:29 -0700 (PDT) Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10032) with ESMTP id xm0rGX843nsd; Sat, 22 Jun 2024 16:42:27 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 6CE413C011BE0; Sat, 22 Jun 2024 16:42:27 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.cs.ucla.edu 6CE413C011BE0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu; s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C; t=1719099747; bh=VfHaxLAwpzqvcNkXkojshlUtOU6+mo6htO/OgdaNH9w=; h=Message-ID:Date:MIME-Version:To:From; b=ONqaeR7FPi+0coUuRTXQrwdzzexrJJkJY7Q7j53uu6Puhj6NRXbReoSiLur+C7/zv t+/LgAyGnBZFmoa9Ltu2nDZrgxsVYrDqgSkoiaWzBoAelOhbxvGfNILc3k0pAxJGFe 0jK/e4YMro70FjgPUNTrCK5h5Ie2ooMIsLeZV/rW+TG078Sp1jlKFfBkt2IcHWjZUg enueuIqwMIrxQ9KSqV6tMXV1a6lxru6M9IjLKhCejZNgwvP2ViHacD6bvjwkiAS64v vFUmT6i7iGnx359F3A0F9IS7UVOnzY36K9KF7AFiWW9+NEtSQ4knNtakcPjXmLtx6I XnVjTiOsGyR6w== X-Virus-Scanned: amavis at mail.cs.ucla.edu Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10026) with ESMTP id ZZZxdHxlwFk6; Sat, 22 Jun 2024 16:42:27 -0700 (PDT) Received: from [192.168.184.241] (unknown [165.166.182.66]) by mail.cs.ucla.edu (Postfix) with ESMTPSA id D9D903C011BC5; Sat, 22 Jun 2024 16:42:26 -0700 (PDT) Message-ID: Date: Sat, 22 Jun 2024 19:42:25 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate To: Eli Zaretskii , JD Smith References: <86r0cpicwt.fsf@gnu.org> Content-Language: en-US From: Paul Eggert In-Reply-To: <86r0cpicwt.fsf@gnu.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Spam-Score: 3.5 (+++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On 6/22/24 04:45, Eli Zaretskii wrote: >> Cc: Adam Porter , jonas@bernoul.li >> From: JD Smith >> Date: Sat, 15 Jun 2024 13:24:00 -0400 >> >> A very useful and [...] Content analysis details: (3.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [165.166.182.66 listed in zen.spamhaus.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Debbugs-Envelope-To: 71572 Cc: adam@alphapapa.net, 71572@debbugs.gnu.org, jonas@bernoul.li X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 2.5 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: On 6/22/24 04:45, Eli Zaretskii wrote: >> Cc: Adam Porter , jonas@bernoul.li >> From: JD Smith >> Date: Sat, 15 Jun 2024 13:24:00 -0400 >> >> A very useful and [...] Content analysis details: (2.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [165.166.182.66 listed in zen.spamhaus.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 T_SCC_BODY_TEXT_LINE No description available. -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager On 6/22/24 04:45, Eli Zaretskii wrote: >> Cc: Adam Porter , jonas@bernoul.li >> From: JD Smith >> Date: Sat, 15 Jun 2024 13:24:00 -0400 >> >> A very useful and widely used time operation is to approximate a given= delay or age (in seconds) using a human-readable unit =E2=80=94 think "2= hours", "5 days", "3 weeks", or "7 months". We have `seconds-to-string= ', but it provides more precision than is often required, skips some mean= ingful "human readable" duration units like weeks and months, and uses ab= breviated units exclusively. >> >> For those familiar with magit, the `magit--age' function has provided = this capability for quite some time (e.g. for short commit age), and othe= r packages have adapted it. It would be useful to have a version in core= . >> >> This patch provides a `seconds-to-string-approximate' function based l= oosely on `magit--age' and `seconds-to-string'. It allows using abbrevia= ted or full units, and can optionally round to the nearest half-unit. >=20 > Paul, any comments to the patch? For starters: Why define a new function, instead of adding optional arguments to the=20 existing one? Why not look at what mastodon.el does, as the comment in=20 seconds-to-string suggests? For example, mastodon-tl--human-duration=20 lets you specify whatever resolution you want, instead of limiting you=20 to either 0.5 or 1 as in the proposed patch. Isn't the master branch was in an long-term sort-of-frozen state, until=20 a branch is created for Emacs 30? If so I imagine changes in this area=20 should wait. From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 22 22:18:03 2024 Received: (at 71572) by debbugs.gnu.org; 23 Jun 2024 02:18:03 +0000 Received: from localhost ([127.0.0.1]:40056 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sLCnq-0000Oy-BP for submit@debbugs.gnu.org; Sat, 22 Jun 2024 22:18:03 -0400 Received: from mail-io1-f45.google.com ([209.85.166.45]:60653) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sLCnn-0000OV-Rx for 71572@debbugs.gnu.org; Sat, 22 Jun 2024 22:18:00 -0400 Received: by mail-io1-f45.google.com with SMTP id ca18e2360f4ac-7f39d30e362so37716239f.0 for <71572@debbugs.gnu.org>; Sat, 22 Jun 2024 19:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719109014; x=1719713814; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=sMpff6FxhODlyq/XQcKye3CKdK66fJf9NuDiuN+5ko8=; b=gJdZ/Zfzd9IlIcKeEiGTbL+YgjpM7qZCzxuLEvOEok/mFmR0Pb2ejUWDsMJWHhPWVC s5+t0s7Y6zyBTHg0BPtZJpraxpT9vnDdE64AeYhxCe9ARaB3WsDoXoZPygfwmiVoc1s8 qfTY2w6px/53ZfV2c1ThnqjibQhpX9O4LfTHWAggHM1FMHmiVviM5Lvv2SVrNQGffoK6 3gh004O4lWJ+7yyN6JN6TJc5OYuss0KmqIiNfFxqOJxOCKUJbKOIMZ1FeL5RLCOiXKqE DwPJN3STQ6fooxvxFRg6BwQ6D2N3vzb5ubw3g/Tm4hzCcBft29qjAGH94EYjXGqnmiRN ns2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719109014; x=1719713814; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sMpff6FxhODlyq/XQcKye3CKdK66fJf9NuDiuN+5ko8=; b=j3RaiK5JIjnzy44httLn/AWPSHCT6GGoB/l0hMMYD/wt8kNwG4qcCwN6ghZ0gxl1wp GQc9t7jUWUCfbMibJW16rygQOKXg5tZ/yBtkWksxchXj2yNlGAGMCn1crGymLBO7nPIt ZZYDdYCKlMBzlB72lAkSYWtvirb1NAipF2JsNRvfYjFH4tQcwC3S8EBD64AiiXN+zH2I lURWHd1veNb3lW4MukAwTAKF79EUemtz7yHLRySV53vVv5d10aA3xSvZ+fX/GJvOzo1Q qD84KvcvMAM7Ym5xZmMVUqN/b0A3w993M3NQ9u/R80+8ScP0JrQXuDv/aaIZKDOOOMmz ogrw== X-Forwarded-Encrypted: i=1; AJvYcCXc8rRL8oLRlHyNu3jvgcY4Tk90/DNs21/F4R9KCrAoUNL97TQaKDs9KARXILXvAU5hiOyc/JRQexo8LTGIMixR5xkssjU= X-Gm-Message-State: AOJu0Yy0xnlA4lk2JIg6AzBrNTdHrAEVZ3vQE20SN8tQkFtb+Onc190U cCLNp/J6HGzAuySMhhjbIPYau2TZYOGfOKTiEom7b0LUpxW3kJug X-Google-Smtp-Source: AGHT+IESTA6dXdayKrVRIx12lH/h+08NmjD2TaqtTY8oiRfJ7/NL4ku60a63/LvPIoX43QAVG+mF2A== X-Received: by 2002:a05:6602:6c04:b0:7eb:81d6:c914 with SMTP id ca18e2360f4ac-7f3a7471000mr146381739f.4.1719109013751; Sat, 22 Jun 2024 19:16:53 -0700 (PDT) Received: from smtpclient.apple (cm-24-53-187-34.buckeyecom.net. [24.53.187.34]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4b9d113f653sm1208704173.77.2024.06.22.19.16.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Jun 2024 19:16:53 -0700 (PDT) From: JD Smith Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_7B0A21E6-71E7-4D62-AA68-5822ED656ACB" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate Date: Sat, 22 Jun 2024 22:16:40 -0400 In-Reply-To: To: Paul Eggert References: <86r0cpicwt.fsf@gnu.org> X-Mailer: Apple Mail (2.3774.600.62) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 71572 Cc: Adam Porter , 71572@debbugs.gnu.org, Eli Zaretskii , jonas@bernoul.li X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Apple-Mail=_7B0A21E6-71E7-4D62-AA68-5822ED656ACB Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jun 22, 2024, at 7:42=E2=80=AFPM, Paul Eggert = wrote: >=20 > On 6/22/24 04:45, Eli Zaretskii wrote: >>>=20 >> Paul, any comments to the patch? >=20 > For starters: Thanks for the comment. > Why define a new function, instead of adding optional arguments to the = existing one? No real reason; new patch doing so attached. > 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=3Dt - 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=3Dabbrev, half) 0.5 450.00ms 0 sec 0 sec = 0 sec 0 seconds =C2=BDs 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=C2=BDs 5.5 5.48s 5 secs 5 secs 5 = secs 5 seconds 5=C2=BDs 12.6 12.59s 12 secs 12 secs 12 = secs 13 seconds 12=C2=BDs 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=C2=BDm 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=C2=BDm 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=C2=BDh 22681.6 6.30h 6 hours, 18 mins 6 hours 6 = hours 6 hours 6=C2=BDh 52167.8 14.49h 14 hours, 29 mins 14 hours 14 = hours 14 hours 14=C2=BDh 119985.9 1.39d 1 day, 9 hours 1 day, 9 hours = 1 day 1 day 1=C2=BDd 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=C2=BDw 3357696.2 38.86d 1 month, 1 week 1 month, 1 week 1 = month 1 month 1=C2=BDM 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=C2=BDY 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 The last column is obviously the most compact while still conveying a = good amount of information, but the 1yr mastodon and normal READABLE = s-to-s are also quite good (effectively equivalent to magit--age) for a = quick glance and maintaining ~constant widths. I do find it awkward to = set the RESOLUTION argument to >30 million seconds to achieve this. It = took me a bit to understand what this argument does.=20 Code use to produce: (concat (format "%11s %10s %18s %18s %12s %12s %s\n" "Delay (s)" "s-to-s" "mastodon" "mastodon (3600s)" "mast (1yr)" "s-to-s (rdb)" = "s-to-s (rdb=3Dabbrev, half)") (cl-loop for s =3D 0.45 then (* s 2.3) while (< s (* 365.25 24 3600 = 22)) concat (format "%11.1f %10s %18s %18s %12s %12s %s\n" s (seconds-to-string s) (car (mastodon-tl--human-duration s)) (car (mastodon-tl--human-duration s 3600)) (car (mastodon-tl--human-duration s (* 365.25 = 24 3600))) (seconds-to-string s t) (seconds-to-string s 'abbrev 'half)))) =EF=BF=BC= --Apple-Mail=_7B0A21E6-71E7-4D62-AA68-5822ED656ACB Content-Type: multipart/mixed; boundary="Apple-Mail=_BAAFEC3A-8FE1-4F22-84C3-4558A83F7E88" --Apple-Mail=_BAAFEC3A-8FE1-4F22-84C3-4558A83F7E88 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Jun 22, 2024, at 7:42=E2=80=AFPM, Paul Eggert = <eggert@cs.ucla.edu> wrote:

On 6/22/24 04:45, Eli = Zaretskii wrote:

Paul, any comments to the = patch?

For = starters:

Thanks for the = comment.

Why define a = new function, instead of adding optional arguments to the existing = one?

No real reason; new = patch doing so attached.

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=3Dt
- 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=3Dabbrev, = half)
      =   0.5    450.00ms           =     0 sec               0 = sec         0 sec     0 seconds =  =C2=BDs
    =     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=C2=BDs
        5.5       5.48s   =            5 secs       =        5 secs        5 secs =     5 seconds  5=C2=BDs
       12.6     =  12.59s             12 secs   =           12 secs       12 secs =    13 seconds  12=C2=BDs
       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=C2=BDm
      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=C2=BDm
     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=C2=BDh
    22681.6       6.30h =    6 hours, 18 mins             = 6 hours       6 hours       6 hours =  6=C2=BDh
    = 52167.8      14.49h   14 hours, 29 mins   =          14 hours      14 hours =      14 hours  14=C2=BDh
   119985.9       1.39d =      1 day, 9 hours      1 day, 9 hours =         1 day         1 day =  1=C2=BDd
  =  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=C2=BDw
  3357696.2      38.86d     1 = month, 1 week     1 month, 1 week       1 month =       1 month  1=C2=BDM
  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=C2=BDY
 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

The last = column is obviously the most compact while still conveying a good amount = of information, but the 1yr mastodon and normal READABLE s-to-s are also = quite good (effectively equivalent to magit--age) for a quick glance and = maintaining ~constant widths.  I do find it awkward to set = the RESOLUTION argument to >30 million seconds to achieve = this.  It took me a bit to understand what this argument = does. 

Code use to = produce:

(concat
 (format = "%11s  %10s  %18s  %18s  %12s  %12s  %s\n" = "Delay (s)" "s-to-s"
  =        "mastodon" "mastodon (3600s)" "mast (1yr)" = "s-to-s (rdb)" "s-to-s (rdb=3Dabbrev, half)")
 (cl-loop for s =3D 0.45 then (* s 2.3) while = (< s (* 365.25 24 3600 22))
          concat (format "%11.1f =  %10s  %18s  %18s  %12s  %12s  %s\n" = s
      =                   =  (seconds-to-string s)
                  =        (car (mastodon-tl--human-duration = s))
      =                   =  (car (mastodon-tl--human-duration s 3600))
              =            (car = (mastodon-tl--human-duration s (* 365.25 24 = 3600)))
      =                   =  (seconds-to-string s t)
                  =        (seconds-to-string s 'abbrev = 'half))))

= --Apple-Mail=_BAAFEC3A-8FE1-4F22-84C3-4558A83F7E88 Content-Disposition: attachment; filename=time-data-readable-seconds.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="time-data-readable-seconds.patch" Content-Transfer-Encoding: quoted-printable ---=20time-date.el=092024-06-22=2021:51:21=0A+++=20time-date_new.el=09= 2024-06-22=2021:53:13=0A@@=20-406,10=20+406,41=20@@=0A=20=20=20=20=20=20=20= =20=20(list=20(*=203600=2024=20400)=20"d"=20(*=203600.0=2024.0))=0A=20=20= =20=20=20=20=20=20=20(list=20nil=20"y"=20(*=20365.25=2024=203600)))=0A=20= =20=20"Formatting=20used=20by=20the=20function=20`seconds-to-string'.")=0A= +=0A+(defvar=20seconds-to-string-readable=0A+=20=20`(("Y"=20"year"=20=20=20= "years"=20=20=20,(round=20(*=2060=2060=2024=20365.2425)))=0A+=20=20=20=20= ("M"=20"month"=20=20"months"=20=20,(round=20(*=2060=2060=2024=20= 30.436875)))=0A+=20=20=20=20("w"=20"week"=20=20=20"weeks"=20=20=20,(*=20= 60=2060=2024=207))=0A+=20=20=20=20("d"=20"day"=20=20=20=20"days"=20=20=20= =20,(*=2060=2060=2024))=0A+=20=20=20=20("h"=20"hour"=20=20=20"hours"=20=20= =20,(*=2060=2060))=0A+=20=20=20=20("m"=20"minute"=20"minutes"=2060)=0A+=20= =20=20=20("s"=20"second"=20"seconds"=201))=0A+=20=20"Formatting=20used=20= by=20the=20function=20`seconds-to-string'=20with=20READABLE=20set.")=0A+=0A= =20;;;###autoload=0A-(defun=20seconds-to-string=20(delay)=0A-=20=20= "Convert=20the=20time=20interval=20in=20seconds=20to=20a=20short=20= string."=0A-=20=20(cond=20((>=200=20delay)=20(concat=20"-"=20= (seconds-to-string=20(-=20delay))))=0A+(defun=20seconds-to-string=20= (delay=20&optional=20readable=20half)=0A+=20=20"Convert=20the=20time=20= interval=20in=20seconds=20to=20a=20short=20string.=0A+If=20READABLE=20is=20= non-nil,=20convert=20DELAY=20into=20a=20readable=20string.=20=20If=20it=20= is=0A+the=20value=20`abbrev',=20abbreviate=20the=20units.=20=20If=20HALF=20= is=20set,=20round=20to=20the=0A+nearest=20half=20unit."=0A+=20=20(cond=20= ((>=200=20delay)=20(concat=20"-"=20(seconds-to-string=20(-=20delay)=20= readable=20half)))=0A+=20=20=20=20=20=20=20=20(readable=0A+=20=20=20=20=20= =20=20=20=20(let=20((abbrev=20(eq=20readable=20'abbrev))=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(stsa=20seconds-to-string-readable)=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20here=20cnt)=0A+=20=20=20=20=20=20=20= =20=20=20=20(if=20(=3D=20(round=20delay=20(if=20half=200.5=201.))=200)=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(format=20"0%s"=20(if=20= abbrev=20"s"=20"=20seconds"))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= (while=20(and=20(setq=20here=20(pop=20stsa))=20stsa=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(<=20(/=20delay=20= (nth=203=20here))=201)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20(setq=20= cnt=20(round=20(/=20(float=20delay)=20(nth=203=20here))=20(if=20half=20= 0.5=201.)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20(concat=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(let=20((c=20(if=20half=20(/=20cnt=202)=20= cnt)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(if=20(>=20c=20= 0)=20(number-to-string=20c)=20""))=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(if=20(and=20half=20(=3D=20(mod=20cnt=202)=201))=20"=C2=BD"=20"")=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20(if=20abbrev=20""=20"=20")=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20(cond=20(abbrev=20(car=20= here))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= ((<=3D=20cnt=20(if=20half=202=201))=20(nth=201=20here))=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(t=20(nth=202=20here)))))))=0A= =20=20=20=20=20=20=20=20=20((=3D=200=20delay)=20"0s")=0A=20=20=20=20=20=20= =20=20=20(t=20(let=20((sts=20seconds-to-string)=20here)=0A=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(while=20(and=20(car=20(setq=20here=20(pop=20= sts)))=0A= --Apple-Mail=_BAAFEC3A-8FE1-4F22-84C3-4558A83F7E88 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii
--Apple-Mail=_BAAFEC3A-8FE1-4F22-84C3-4558A83F7E88-- --Apple-Mail=_7B0A21E6-71E7-4D62-AA68-5822ED656ACB-- From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 23 01:13:19 2024 Received: (at 71572) by debbugs.gnu.org; 23 Jun 2024 05:13:20 +0000 Received: from localhost ([127.0.0.1]:44685 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sLFXT-0005zI-JS for submit@debbugs.gnu.org; Sun, 23 Jun 2024 01:13:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56050) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sLFXQ-0005z5-M7 for 71572@debbugs.gnu.org; Sun, 23 Jun 2024 01:13:18 -0400 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 1sLFXD-0003qh-PW; Sun, 23 Jun 2024 01:13:07 -0400 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=PL0ZlvjfjAs4T9QoCjdJJudQaoLChEMWsw43xDZApsM=; b=H+ndxPSv9Z7G /dvUyF7ARIY9RtFYpR/61+rSDmn3IweBAmtclwoXvjIceXVsMQmFWvC8oRw+OmYFZgZG7GBjiYW8Q 0eZFxk5Z9vc6AQS/E+Gte/utz7ByDJ8RMfx/pQ3WIdCpY/dFFvc+zQ9zR5ftxJ7nxmxJXaMS5hJTp XkM3hwXnDlb4cwJZjICUN3mMKAuuOK1+EXV/mQcokzPTM17Z5Syql+Kbmdw9bpyMaixJRQSKZ3PBh IbS66ra58dHjtz2uRbbeHQvWvjNwy3NJw8mrUtSqN3nNqXmUB7oIjPLlfaXntgb3QftTTycFLJNvv Ykw45XXJS7mF1EN9O4TNIg==; Date: Sun, 23 Jun 2024 08:13:01 +0300 Message-Id: <86bk3sfdia.fsf@gnu.org> From: Eli Zaretskii To: Paul Eggert In-Reply-To: (message from Paul Eggert on Sat, 22 Jun 2024 19:42:25 -0400) Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate References: <86r0cpicwt.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 71572 Cc: adam@alphapapa.net, 71572@debbugs.gnu.org, jonas@bernoul.li, jdtsmith@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Date: Sat, 22 Jun 2024 19:42:25 -0400 > Cc: 71572@debbugs.gnu.org, adam@alphapapa.net, jonas@bernoul.li > From: Paul Eggert > > Isn't the master branch was in an long-term sort-of-frozen state, until > a branch is created for Emacs 30? If so I imagine changes in this area > should wait. Yes, this is for Emacs 31. From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 30 01:37:55 2024 Received: (at control) by debbugs.gnu.org; 30 Jun 2024 05:37:55 +0000 Received: from localhost ([127.0.0.1]:54480 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sNnG7-0003vy-IF for submit@debbugs.gnu.org; Sun, 30 Jun 2024 01:37:55 -0400 Received: from mail-ed1-f45.google.com ([209.85.208.45]:49662) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sNnG6-0003vq-6w for control@debbugs.gnu.org; Sun, 30 Jun 2024 01:37:54 -0400 Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-585e6ad9dbcso2123048a12.3 for ; Sat, 29 Jun 2024 22:37:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719725814; x=1720330614; darn=debbugs.gnu.org; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=wFfiyoNQ8kBB2stHeLKL8qeLlBc9MLkYmt2xL+4mrK0=; b=TDPa+IcpnV1vN2aK8Eb5scWRZslwJTUqnlLLjzbc4fnlM3/5fD6QoLNJfAtCQEy+N7 mxNXoSx0q7j+QCfghnzmHGHvJQ3N1W61g/tLYF+xzW1vxaQBEA0J/kv2kFQYTioTMKQP ipI9I1/V85QDkahw99FRl9Mj0Q32mEUQTMAFYA+8XV+ME9yxC6LTXgps220/MdXGgMn1 RjUQkpgk+5/3De+VclzYK3XXkj6uakfz3N362egvy12mbw+DpAUIzqEVYJkYw49jBoLp YfyOPs4kGcFrUPhN2Gzkh+mteMjK1Op/9Wjv3wbPNrkEiiJ5n1Dls3pSpdk3UaKlsf89 Ih8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719725814; x=1720330614; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=wFfiyoNQ8kBB2stHeLKL8qeLlBc9MLkYmt2xL+4mrK0=; b=gmeuSjZ3WDZ2/8F5XXRfsArxcKBTALtSbprkYZK+YafmtaGsG3vrEdkNK5lHYLF8Zi 9ceyxZUdYaeDIVb34nT2qDmt/vS4aeBac17a0ScF5a8lLG9Cu063TqUnm3vato+PIWiI YTyCNLsg012Ln2m7ISNvzPXyjg2ptp1hJxSJ0MLjR1qB2toGH0zUj6EuwwIQt2FsHqa3 +uO4xfs5qhVFZuyF4hpFeeUwJjh1RmIVCruj6qXxEYHnLR8qjh5B9oNvBasfN4TXAKeI i2bKdXs+Wg+OTHHEYmvzPZgH8DUjfJOmDqLmbeScRrDXnQBCIZ1Uoy/I+Vxl4E2J9YeJ C4yw== X-Gm-Message-State: AOJu0Yyl503wUdpMIUV/UbkcgKqRaEjxTK0Ndoe6O69Zo1+yGLQz4foo C46ZmvTuy7Qs9dx5QuFNJk18i7As/wwiTXqGcgsndKD39GNEEoxjZX2RbM+mEKpLBB4lrgsKFEm cu9FwyfCKAgihgZZJTZ6RcDuLXktm6SMkBF4= X-Google-Smtp-Source: AGHT+IF3/MyrsJ/EvIdmgu7tUXljGvjNgFzBS+khS+YswmuXYP38qpdRFJKIOsgjet0Zrvm75XLr7gbNkNurJQH0bV0= X-Received: by 2002:a05:6402:5255:b0:57d:55fd:d991 with SMTP id 4fb4d7f45d1cf-5879eed8c54mr2023808a12.9.1719725813604; Sat, 29 Jun 2024 22:36:53 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sat, 29 Jun 2024 22:36:52 -0700 From: Stefan Kangas MIME-Version: 1.0 Date: Sat, 29 Jun 2024 22:36:52 -0700 Message-ID: Subject: control message for bug #71573 To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) severity 71573 wishlist quit From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 03 16:34:09 2024 Received: (at 71572) by debbugs.gnu.org; 3 Jul 2024 20:34:09 +0000 Received: from localhost ([127.0.0.1]:40782 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sP6g4-0004WD-QT for submit@debbugs.gnu.org; Wed, 03 Jul 2024 16:34:09 -0400 Received: from mail-yw1-f171.google.com ([209.85.128.171]:49170) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sP6g2-0004Vd-7b for 71572@debbugs.gnu.org; Wed, 03 Jul 2024 16:34:07 -0400 Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-6512866fa87so14309047b3.2 for <71572@debbugs.gnu.org>; Wed, 03 Jul 2024 13:34:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720038778; x=1720643578; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=dGqZ7M/CPzLFfHnB/uUlJEPlkKP6Xkbn6+Qr0BVcTbM=; b=hXwM+qORbdRY4xZ4/RNu9JCDDqCjN4dCQfAhvl5pvqbKhhFDKYrxoUa8+BOc2jHrjY seX6c8y3MwAZrfDo1IJ6M9Ww4YL8Gb8WKMN/k4W1GA1lxmRJyWS1qR3OpppSj9OheOa7 jUpxMn3AFYXc5c1sZTBqQOyEV+zs7c4coZJZBgEHttWJAyNnln8HjEgRyLuC4d3jBRnb mrQA2qU8KAdasfpY5z6iLVoDvYi5ozlDV+a280y2dA0wAAcqbEQaC6amBqIgr116TkIG yNgA7zhA6f7GZm7KIPGiA1k8PTSQxeNpuBlp4H/clud2hbwMm0d0/3OyxuEhnPtcqs2C zdmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720038778; x=1720643578; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dGqZ7M/CPzLFfHnB/uUlJEPlkKP6Xkbn6+Qr0BVcTbM=; b=IhFPlrRRNImjBfAZlBEdWxVZdI9JFq79YeEN7TXg5p9XpCCkT2Igrk6gLMfshbHpzo F/F5/TEuIxOxz6GHfbzhhu6uW9KR+Jxiw0NA9mDUmTdNtyKd2vYruhDrCwJN7/VCYJgy xOGOcSYzztN6UIVNB6mD4MzNWz3z6qokpNLqueZ2Uy7gQChxYxma4fEU44n1TdFylRXF Ykjb3PrhyZH+Bjba0jFKxvyVcT8ZYiv+wsL0J6K87EaH6NdOZQ43F5SznddTqUiQVL+v K7ZbgKX+4jToR0+kHwSmsyIdD6hxxFCrwb3RSi6ZtCCFFeHqH2W2nxkraNHxa2KTB7mk 7Mfg== X-Forwarded-Encrypted: i=1; AJvYcCUz/Z7MkWmjm8aIT5nRVi2WoMgiw+7el4PIC7jFihWi8lBdUefZPNzIP0LxUgtbl7oAUm/7HXbwcIhp+N/tW693GAlZTiY= X-Gm-Message-State: AOJu0YwDSSjEqpYNG7JW2mUm0/rc1utlMUGBGGQlwN+QLCdZxtWAEOEA nbmxXyVmMWiUU61xGhdyNBXby39qvPUhPXCY7oh/f9BSqoQ3vudo X-Google-Smtp-Source: AGHT+IE13o63h2ANe4tY6UAJaQIFJDxSEJGTF+TprGL15TEjk1kzH/kDhEaFqGZvD5GIWXWhssjm4g== X-Received: by 2002:a05:690c:6706:b0:627:de5d:cf36 with SMTP id 00721157ae682-64c73dd32ccmr109420827b3.39.1720038778468; Wed, 03 Jul 2024 13:32:58 -0700 (PDT) Received: from smtpclient.apple ([131.183.131.33]) by smtp.gmail.com with ESMTPSA id 00721157ae682-64a99e5db6csm22778537b3.9.2024.07.03.13.32.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jul 2024 13:32:57 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate From: JD Smith In-Reply-To: <86bk3sfdia.fsf@gnu.org> Date: Wed, 3 Jul 2024 16:32:46 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: <4FCEB720-E74B-4EB1-AE59-7446EC73B874@gmail.com> References: <86r0cpicwt.fsf@gnu.org> <86bk3sfdia.fsf@gnu.org> To: Eli Zaretskii , Paul Eggert , 71572@debbugs.gnu.org X-Mailer: Apple Mail (2.3774.600.62) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 71572 Cc: Adam Porter , jonas@bernoul.li X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On Jun 23, 2024, at 1:13=E2=80=AFAM, Eli Zaretskii = wrote: >=20 >> Date: Sat, 22 Jun 2024 19:42:25 -0400 >> Cc: 71572@debbugs.gnu.org, adam@alphapapa.net, jonas@bernoul.li >> From: Paul Eggert >>=20 >> Isn't the master branch was in an long-term sort-of-frozen state, = until=20 >> a branch is created for Emacs 30? If so I imagine changes in this = area=20 >> should wait. >=20 > Yes, this is for Emacs 31. Any further thoughts on this approach?= From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 04 01:31:30 2024 Received: (at 71572) by debbugs.gnu.org; 4 Jul 2024 05:31:30 +0000 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 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 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==; Date: Thu, 04 Jul 2024 08:29:03 +0300 Message-Id: <86msmxafog.fsf@gnu.org> From: Eli Zaretskii To: JD Smith In-Reply-To: (message from JD Smith on Sat, 22 Jun 2024 22:16:40 -0400) Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate References: <86r0cpicwt.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 71572 Cc: adam@alphapapa.net, 71572@debbugs.gnu.org, jonas@bernoul.li, eggert@cs.ucla.edu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > 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. From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 04 01:32:09 2024 Received: (at 71572) by debbugs.gnu.org; 4 Jul 2024 05:32:10 +0000 Received: from localhost ([127.0.0.1]:41246 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPF4j-00027e-CK for submit@debbugs.gnu.org; Thu, 04 Jul 2024 01:32:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32870) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPF4d-00026o-Jk for 71572@debbugs.gnu.org; Thu, 04 Jul 2024 01:32:08 -0400 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 1sPF2P-0008Hg-KF; Thu, 04 Jul 2024 01:29:45 -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=cUs+qRtsWqa3O5H0rvRUyMAxiANhlx3BYroI4nyz0HM=; b=rrzfj0yBdLm+wrDlWUrZ VVlpZUxDmbTsa3HuVDRpv2es6+xUk4g7yWCEgS+pFPdkEVoTulDpVd3o6Gwwrx7rr2DFBDTG14eiV C9GQ6vgdqOdIdmxYghfVSsLXeDEWmXArBjLwiMaiENInDYf4BwneRnAGwMYyNTT/Pp5GboVSeKhvS WhpE9tzvYeZJFQ213MUbl4skF+PLEtyxcid11hqBeHht+lqNVhldcUT+o53rJcBKho6eYMil0QNkP OydXkM2DRlB4UATVhsAoPSjW75PUtKhusjGqIjp1L0kpzfXPLBo7bXEMxBTkbkx45yJH07CDJT+xE 8UZaolm4wa9FOQ==; Date: Thu, 04 Jul 2024 08:29:31 +0300 Message-Id: <86le2hafno.fsf@gnu.org> From: Eli Zaretskii To: JD Smith In-Reply-To: <4FCEB720-E74B-4EB1-AE59-7446EC73B874@gmail.com> (message from JD Smith on Wed, 3 Jul 2024 16:32:46 -0400) Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate References: <86r0cpicwt.fsf@gnu.org> <86bk3sfdia.fsf@gnu.org> <4FCEB720-E74B-4EB1-AE59-7446EC73B874@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 71572 Cc: adam@alphapapa.net, 71572@debbugs.gnu.org, jonas@bernoul.li, eggert@cs.ucla.edu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: JD Smith > Date: Wed, 3 Jul 2024 16:32:46 -0400 > Cc: Adam Porter , > jonas@bernoul.li > > > > On Jun 23, 2024, at 1:13 AM, Eli Zaretskii wrote: > > > >> Date: Sat, 22 Jun 2024 19:42:25 -0400 > >> Cc: 71572@debbugs.gnu.org, adam@alphapapa.net, jonas@bernoul.li > >> From: Paul Eggert > >> > >> Isn't the master branch was in an long-term sort-of-frozen state, until > >> a branch is created for Emacs 30? If so I imagine changes in this area > >> should wait. > > > > Yes, this is for Emacs 31. > > Any further thoughts on this approach? I've just sent a few. From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 04 02:04:34 2024 Received: (at 71572) by debbugs.gnu.org; 4 Jul 2024 06:04:34 +0000 Received: from localhost ([127.0.0.1]:41273 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPFa6-00031W-9n for submit@debbugs.gnu.org; Thu, 04 Jul 2024 02:04:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44164) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPFa3-00031I-CZ for 71572@debbugs.gnu.org; Thu, 04 Jul 2024 02:04:32 -0400 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 1sPFZr-0003dF-Od; Thu, 04 Jul 2024 02:04:19 -0400 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=bMXLgTyZSVbqDUO65JuvpEs4PpClp1/5uhDu95/dOnM=; b=GLj/2I90nZVc rqSmzjGc6at4FelUthRCAjz25NYPdHXVkUQcYv8og2Vb2QUiwV3VPBlje20e5SdmDaSwOzq/Lwikv GM22DnOwkMhKzq5/OxZyyDa5tgnjWwiPgBXUsyNIsCiG7TJJPhMY9YEQmwAdgL3NGfhATZpzkkAkO jLzhfHOJvWOjW4J2MIFzzil87S3VKjY7pXrtOrqMjdEixHYvPqmBCR3hzQGxhtPs0YezHmT3JJG9G nPPdN4dDXSMwhvABH3zpQVn1uRudLt7FHDX2iNWScUwswpHH8Jza3RYWUu7BbdlF9wR/ZGaRTGWbx NLy7A4WsveuB0HHOEgKgcw==; Date: Thu, 04 Jul 2024 09:04:18 +0300 Message-Id: <86frspae1p.fsf@gnu.org> From: Eli Zaretskii To: jdtsmith@gmail.com In-Reply-To: <86msmxafog.fsf@gnu.org> (message from Eli Zaretskii on Thu, 04 Jul 2024 08:29:03 +0300) Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 71572 Cc: adam@alphapapa.net, 71572@debbugs.gnu.org, jonas@bernoul.li, eggert@cs.ucla.edu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Cc: adam@alphapapa.net, 71572@debbugs.gnu.org, jonas@bernoul.li, > eggert@cs.ucla.edu > Date: Thu, 04 Jul 2024 08:29:03 +0300 > From: Eli Zaretskii > > 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? And one more nit: should this function be described in the ELisp manual? From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 04 03:09:22 2024 Received: (at 71572) by debbugs.gnu.org; 4 Jul 2024 07:09:23 +0000 Received: from localhost ([127.0.0.1]:41360 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPGao-0004kH-MC for submit@debbugs.gnu.org; Thu, 04 Jul 2024 03:09:22 -0400 Received: from mail.cs.ucla.edu ([131.179.128.66]:43652) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPGam-0004k3-Id for 71572@debbugs.gnu.org; Thu, 04 Jul 2024 03:09:21 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id B5EC83C011BE0; Thu, 4 Jul 2024 00:09:12 -0700 (PDT) Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10032) with ESMTP id vnFY93xTxQ_o; Thu, 4 Jul 2024 00:09:12 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 43FDC3C013279; Thu, 4 Jul 2024 00:09:12 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.cs.ucla.edu 43FDC3C013279 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu; s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C; t=1720076952; bh=RpBoiHM/6ddD/J2GUB5DD7hrTOH4vBrqWRJfwyaSE1Y=; h=Message-ID:Date:MIME-Version:To:From; b=h3HTGLxsP5GZ36ZdbU/yWjyTnH5DAWy0QhoEWD/O/+eGxLKqUAX86daMx0OHMvBtb TEMRhkPMgRzPGCftDYIp2F7Pe2xbdw8eDMDymI1LVDNqN0uwy9wiZSpsDv+HMlmLs3 v8cczpAd9lhTg+32lKjEKhlOWMAJOpNGNbV8QvEHKtpnrQl7YbaT9KLKb0xFyJK4pM /vX5K7mTZVsu++08Z+ucpVWXbtrPxKM1yrupO03AevhLG5f4EtehtyxfVKZzsfvRwI U9fZKddAzBNfnlQUuZecy+lxcmQFJWMAJBPXmzqttayoGPUNMR5dkwK/5zJtCoRagX rx3DYf6WrVNIw== X-Virus-Scanned: amavis at mail.cs.ucla.edu Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10026) with ESMTP id 58LYn8TZ45n3; Thu, 4 Jul 2024 00:09:12 -0700 (PDT) Received: from [10.0.3.65] (unknown [92.207.175.29]) by mail.cs.ucla.edu (Postfix) with ESMTPSA id E83DC3C011BE0; Thu, 4 Jul 2024 00:09:10 -0700 (PDT) Message-ID: <3530cd89-b5a2-4b25-95bf-1896c8ee4aef@cs.ucla.edu> Date: Thu, 4 Jul 2024 08:09:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate To: Eli Zaretskii , JD Smith References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> Content-Language: en-US From: Paul Eggert In-Reply-To: <86msmxafog.fsf@gnu.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 71572 Cc: adam@alphapapa.net, 71572@debbugs.gnu.org, jonas@bernoul.li X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 7/4/24 06:29, Eli Zaretskii wrote: > Basically, this shows that: > > . mastodon truncates where seconds-to-string rounds For high precision timestamps it's often better to truncate, for various reasons. That's what the C code does with timestamps, anyway. seconds-to-string historically has rounded several times which of course is not best but apparently is good enough for its intended application area. > . seconds-to-string lacks the "1 hour 11 min" output format That format could be confusing with negative delays, e.g., "-1 hour 11 min". > . seconds-to-string sometimes produces inaccurate results, as in > 5.5 => 5.48s No, it's the other way round: seconds-to-string is more accurate than the alternatives. That's merely a misfeature in the test script. seconds-to-string is passed the argument 5.475149999999998, and formats it as "5.48" whereas the test script formats it as "5.5". I'm not sold on the "half" argument; seems like a cuteness rather than a feature that's all that useful (among other things, it assumes Unicode or something like it). What's really going on here is that there's an optional argument specifying style and I imagine that style preferences will differ (Mastodon style, etc.). I imagine that style preferences could proliferate. Is there an ISO or similar standard for this sort of thing? From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 04 11:29:09 2024 Received: (at 71572) by debbugs.gnu.org; 4 Jul 2024 15:29:09 +0000 Received: from localhost ([127.0.0.1]:42763 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPOOS-0004yS-Gy for submit@debbugs.gnu.org; Thu, 04 Jul 2024 11:29:09 -0400 Received: from mail-qv1-f53.google.com ([209.85.219.53]:52727) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPOOQ-0004xv-13 for 71572@debbugs.gnu.org; Thu, 04 Jul 2024 11:29:06 -0400 Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-6b5eb69e04cso4643486d6.1 for <71572@debbugs.gnu.org>; Thu, 04 Jul 2024 08:29:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720106878; x=1720711678; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=VB9w5VZNFAkAlyvhk0jKfaHKIidps99md7Y/93o9xkA=; b=iq9uv7Xykgls99NhRqNM/eHDdbDEOwp4ED7qA0oRB3rysFhVfPmDTL++0z7siw18RI 8eMM0fnGRuUJ/OtE9eEfr1KSo3pbaIJfbXW72ZRDS/9ZfiFvJxa+h8UgJ+m2WiBxkFJ/ MYBZhqAx2cWPczy0BmvhUlBZgc1yLFr26w/2lxXiDqMvh1MDlESudAGQzXMu0o4Czizh lI8SsvjrQ9CCbaQ+ZcYE6OeVeydtIpY7SCjZgaZw7P8QPW0t4F/XSonBC61g6RxX78MM S7KuCI6Jphv63hy18oOxeOgOX0Yo0z6Ifr01zr7J3hssmYLvkCzuYfZ3MnixNzvDAkZB cojg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720106878; x=1720711678; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VB9w5VZNFAkAlyvhk0jKfaHKIidps99md7Y/93o9xkA=; b=ipOh+8H/8bzgCAm32EFmd4mahjMaxRLMAcakjMqyP/fd/TBoDj6QHKY9ZELz+BQCAU bBx9ymKQup9xM9Uu5xrK8tVkn/L5IAYV5ULM8+KdGCYuNunR4fN7RNaOx4B0SbJ6QTB6 axi1fV+tAk86BLauK8w0psmlpN+wewUkxHjTgqXcrZzzwvt0SuOrVHFfMFxGPKsoBMbA MPo7g7w/PjAAZK7yCArg8KRs4gMIWKCUQQnG6qEa9Mi8vKntPKtIrSv36C5eZ7zuQHJ7 9UefA6SnxRkA8Qn+wE4m15f2ExxvVkyrA6JDqzPrA0Nx+eon8hAFdkBGhgtdCjEsLUh/ VC8A== X-Forwarded-Encrypted: i=1; AJvYcCWmZH6EESEICO4hPBXsjr6Z35stpKuzovsYDEaXY6/EW5GBoV7As7v2naTQ0s04FQ1/0L4CrGAwT9TsDSRnoiD+xT7CQCA= X-Gm-Message-State: AOJu0YybQt1T4V6kb70PBBdDBIDylM1r1JKDmKP226dAUtU7e7FUFnib yYnTMRnJyvXgZ+Wg1pdURTY/6iQcATfKkn3/tYf8mW47o2lf+Ugb X-Google-Smtp-Source: AGHT+IG5AUL3NS5RqBaAcbFwdPslpAPLm3hsnx9vA/Zkj/K7u1mroApvmzIxM/19wVJRH+MhsFqvhQ== X-Received: by 2002:a05:6214:2485:b0:6b5:4865:948e with SMTP id 6a1803df08f44-6b5ed005361mr21851466d6.32.1720106877728; Thu, 04 Jul 2024 08:27:57 -0700 (PDT) Received: from smtpclient.apple (cm-24-53-187-34.buckeyecom.net. [24.53.187.34]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b59e368b6esm65324966d6.15.2024.07.04.08.27.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jul 2024 08:27:56 -0700 (PDT) From: JD Smith Message-Id: <1FFF1E0D-A0E0-4EB9-AC97-AEB0BFADFBBC@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_44515253-DC03-4933-9260-26CB75A7BFBE" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate Date: Thu, 4 Jul 2024 11:27:41 -0400 In-Reply-To: <86msmxafog.fsf@gnu.org> To: Eli Zaretskii References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> X-Mailer: Apple Mail (2.3774.600.62) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 71572 Cc: Adam Porter , 71572@debbugs.gnu.org, jonas@bernoul.li, Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Apple-Mail=_44515253-DC03-4933-9260-26CB75A7BFBE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jul 4, 2024, at 1:29=E2=80=AFAM, Eli Zaretskii = wrote: >>=20 >> Here's a comparison among: >>=20 >> - 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=3Dt >> - new seconds-to-string with abbreviated units and half unit = resolution >=20 > Basically, this shows that: >=20 > . mastodon truncates where seconds-to-string rounds I definitely think rounding makes more sense for a readable unit; = consider 2.98y. > . seconds-to-string lacks the "1 hour 11 min" output format > . seconds-to-string sometimes produces inaccurate results, as in > 5.5 =3D> 5.48s > The last item worries me: can we fix this, please? The latter issue results simply from my truncation of the initial delay = column to 1 decimal digit. E.g. .45s * 2.3^3 =3D 5.47515s, so s2s has = it right. > The second item sounds like a useful feature, so maybe an optional > behavior could provide it as well? I've expanded the call format to (delay &optional readable abbrev half) = , with READABLE=3D'expanded an option to get the "1 hour 11 min" = expanded format, i.e. one larger and one smaller unit (if appropriate). = Patch below. Updated output at the same delays for the various new options (r: = readable, e: readable=3Dexpanded, a: abbrev, h: half): Delay (s) s2s s2s-r s2s-ra s2s-rah = s2s-e s2s-ea s2s-eah 0.45 450.00ms 0 seconds 0s =C2=BDs 0 = seconds 0s =C2=BDs 1.03 1.03s 1 second 1s 1s 1 = second 1s 1s 2.38 2.38s 2 seconds 2s 2=C2=BDs 2 = seconds 2s 2=C2=BDs 5.48 5.48s 5 seconds 5s 5=C2=BDs 5 = seconds 5s 5=C2=BDs 12.59 12.59s 13 seconds 13s 12=C2=BDs 13 = seconds 13s 12=C2=BDs 28.96 28.96s 29 seconds 29s 29s 29 = seconds 29s 29s 66.62 66.62s 1 minute 1m 1m 1 minute 7 = seconds 1m 7s 1m 6=C2=BDs 153.22 2.55m 3 minutes 3m 2=C2=BDm 2 minutes 33 = seconds 2m 33s 2m 33s 352.40 5.87m 6 minutes 6m 6m 5 minutes 52 = seconds 5m 52s 5m 52=C2=BDs 810.52 13.51m 14 minutes 14m 13=C2=BDm 13 minutes 31 = seconds 13m 31s 13m 30=C2=BDs 1864.19 31.07m 31 minutes 31m 31m 31 minutes 4 = seconds 31m 4s 31m 4s 4287.64 71.46m 1 hour 1h 1h 1 hour 11 = minutes 1h 11m 1h 11=C2=BDm 9861.58 2.74h 3 hours 3h 2=C2=BDh 2 hours 44 = minutes 2h 44m 2h 44=C2=BDm 22681.64 6.30h 6 hours 6h 6=C2=BDh 6 hours 18 = minutes 6h 18m 6h 18m 52167.76 14.49h 14 hours 14h 14=C2=BDh 14 hours 29 = minutes 14h 29m 14h 29=C2=BDm 119985.86 1.39d 1 day 1d 1=C2=BDd 1 day = 9 hours 1d 9h 1d 9=C2=BDh 275967.47 3.19d 3 days 3d 3d 3 days 5 = hours 3d 5h 3d 4=C2=BDh 634725.18 7.35d 1 week 1w 1w 7 = days 7d 1w =C2=BDd 1459867.91 16.90d 2 weeks 2w 2=C2=BDw 2 = weeks 3 days 2w 3d 2w 3d 3357696.19 38.86d 1 month 1M 1=C2=BDM 1 = month 1 week 1M 1w 1M 1w 7722701.24 89.38d 3 months 3M 3M 2 months 4 = weeks 2M 4w 2M 4w 17762212.85 205.58d 7 months 7M 7M 6 months 3 = weeks 6M 3w 6M 3=C2=BDw 40853089.56 1.29y 1 year 1Y 1=C2=BDY 1 year = 4 months 1Y 4M 1Y 3=C2=BDM 93962106.00 2.98y 3 years 3Y 3Y 2 years 12 = months 2Y 12M 2Y 11=C2=BDM 216112843.80 6.85y 7 years 7Y 7Y 6 years 10 = months 6Y 10M 6Y 10M 497059540.74 15.75y 16 years 16Y 16Y 15 years 9 = months 15Y 9M 15Y 9M This is produced with: (concat (format "%12s %10s %10s %6s %7s %21s %7s %s\n" "Delay (s)" "s2s" "s2s-r" "s2s-ra" "s2s-rah" "s2s-e" "s2s-ea" = "s2s-eah" ) (cl-loop for s =3D 0.45 then (* s 2.3) while (< s (* 365.25 24 3600 = 22)) concat (format "%12.2f %10s %10s %6s %7s %21s %7s %s\n" = s (seconds-to-string s) (seconds-to-string s 'readable) (seconds-to-string s 'readable 'abbrev) (seconds-to-string s 'readable 'abbrev 'half) (seconds-to-string s 'expanded) (seconds-to-string s 'expanded 'abbrev) (seconds-to-string s 'expanded 'abbrev = 'half)))) =EF=BF=BC= --Apple-Mail=_44515253-DC03-4933-9260-26CB75A7BFBE Content-Type: multipart/mixed; boundary="Apple-Mail=_B38B2BEC-FA7C-478A-BD03-EEA617C79540" --Apple-Mail=_B38B2BEC-FA7C-478A-BD03-EEA617C79540 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
On Jul 4, = 2024, at 1:29=E2=80=AFAM, Eli Zaretskii <eliz@gnu.org> = wrote:

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=3Dt
- new seconds-to-string with abbreviated units = and half unit = resolution
<snip>

Basically, this shows that:

. = mastodon truncates where seconds-to-string = rounds

I definitely = think rounding makes more sense for a readable unit; consider = 2.98y.

. seconds-to-string = lacks the "1 hour 11 min" output = format
. = seconds-to-string sometimes produces inaccurate results, as in
=   5.5 =3D> = 5.48s
The = last item worries me: can we fix this, = please?

The latter issue results simply = from my truncation of the initial delay column to 1 decimal digit. =  E.g. .45s * 2.3^3 =3D 5.47515s, so s2s has it = right.

The second item = sounds like a useful feature, so maybe an optional
behavior could = provide it as well?

I've = expanded the call format to (delay &optional readable abbrev half) , = with READABLE=3D'expanded an option to get the "1 hour 11 min" expanded = format, i.e. one larger and one smaller unit (if appropriate). =  Patch below.

Updated output at the same = delays for the various new options (r: readable, e: readable=3Dexpanded, = a: abbrev, h: half):

  =  Delay (s)        s2s       = s2s-r  s2s-ra  s2s-rah           =        s2s-e   s2s-ea =  s2s-eah
    =     0.45   450.00ms   0 seconds     =  0s       =C2=BDs           =    0 seconds       0s =  =C2=BDs
    =     1.03      1.03s    1 second =      1s       1s       =         1 second       1s =  1s
    =     2.38      2.38s   2 seconds   =    2s      2=C2=BDs         =      2 seconds       2s =  2=C2=BDs
    =     5.48      5.48s   5 seconds   =    5s      5=C2=BDs         =      5 seconds       5s =  5=C2=BDs
    =    12.59     12.59s  13 seconds     = 13s     12=C2=BDs             13 = seconds      13s  12=C2=BDs
       28.96     = 28.96s  29 seconds     29s      29s   =           29 seconds      29s =  29s
    =    66.62     66.62s    1 minute   =    1m       1m     1 minute 7 seconds =    1m 7s  1m 6=C2=BDs
      153.22      2.55m   3 = minutes      3m      2=C2=BDm   2 = minutes 33 seconds   2m 33s  2m 33s
      352.40     =  5.87m   6 minutes      6m       = 6m   5 minutes 52 seconds   5m 52s  5m = 52=C2=BDs
    =   810.52     13.51m  14 minutes     14m =     13=C2=BDm  13 minutes 31 seconds  13m 31s =  13m 30=C2=BDs
  =    1864.19     31.07m  31 minutes     = 31m      31m   31 minutes 4 seconds   31m 4s =  31m 4s
    =  4287.64     71.46m      1 hour   =    1h       1h      1 hour 11 = minutes   1h 11m  1h 11=C2=BDm
     9861.58     =  2.74h     3 hours      3h     =  2=C2=BDh     2 hours 44 minutes   2h 44m  2h = 44=C2=BDm
    = 22681.64      6.30h     6 hours     =  6h      6=C2=BDh     6 hours 18 minutes =   6h 18m  6h 18m
    52167.76     14.49h    14 hours =     14h     14=C2=BDh    14 hours 29 = minutes  14h 29m  14h 29=C2=BDm
   119985.86      1.39d =       1 day      1d     =  1=C2=BDd          1 day 9 hours   =  1d 9h  1d 9=C2=BDh
   275967.47      3.19d     =  3 days      3d       3d   =       3 days 5 hours    3d 5h  3d = 4=C2=BDh
  =  634725.18      7.35d      1 week =      1w       1w       =           7 days       7d =  1w =C2=BDd
  = 1459867.91     16.90d     2 weeks     =  2w      2=C2=BDw         2 = weeks 3 days    2w 3d  2w 3d
  3357696.19     38.86d   =   1 month      1M      1=C2=BDM =         1 month 1 week    1M 1w  1M = 1w
  7722701.24   =   89.38d    3 months      3M     =   3M       2 months 4 weeks    2M 4w =  2M 4w
 17762212.85    205.58d    7 months =      7M       7M       6 = months 3 weeks    6M 3w  6M 3=C2=BDw
 40853089.56      1.29y   =    1 year      1Y      1=C2=BDY =        1 year 4 months    1Y 4M  1Y = 3=C2=BDM
 93962106.00 =      2.98y     3 years      3Y =       3Y      2 years 12 months   2Y = 12M  2Y 11=C2=BDM
216112843.80      6.85y     7 years =      7Y       7Y      6 = years 10 months   6Y 10M  6Y 10M
497059540.74     15.75y    16 = years     16Y      16Y      15 = years 9 months   15Y 9M  15Y 9M

This is produced = with:

(concat
 (format = "%12s %10s  %10s  %6s  %7s  %21s  %7s =  %s\n"
    =      "Delay (s)" "s2s" "s2s-r" "s2s-ra" "s2s-rah" "s2s-e" = "s2s-ea" "s2s-eah" )
 (cl-loop for s =3D 0.45 then (* s 2.3) while (< s (* = 365.25 24 3600 22))
  =         concat (format "%12.2f %10s  %10s =  %6s  %7s  %21s  %7s  %s\n" = s
      =                   =  (seconds-to-string s)
                  =        (seconds-to-string s = 'readable)
    =                     =  (seconds-to-string s 'readable 'abbrev)
              =            (seconds-to-string s 'readable = 'abbrev 'half)
    =                     =  (seconds-to-string s 'expanded)
              =            (seconds-to-string s 'expanded = 'abbrev)
    =                     =  (seconds-to-string s 'expanded 'abbrev = 'half))))

= --Apple-Mail=_B38B2BEC-FA7C-478A-BD03-EEA617C79540 Content-Disposition: attachment; filename=time-data-readable-seconds-2.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="time-data-readable-seconds-2.patch" Content-Transfer-Encoding: quoted-printable ---=20time-date.el=092024-06-22=2021:51:21=0A+++=20time-date_new.el=09= 2024-07-04=2011:16:22=0A@@=20-406,10=20+406,62=20@@=0A=20=20=20=20=20=20=20= =20=20(list=20(*=203600=2024=20400)=20"d"=20(*=203600.0=2024.0))=0A=20=20= =20=20=20=20=20=20=20(list=20nil=20"y"=20(*=20365.25=2024=203600)))=0A=20= =20=20"Formatting=20used=20by=20the=20function=20`seconds-to-string'.")=0A= +=0A+(defvar=20seconds-to-string-readable=0A+=20=20`(("Y"=20"year"=20=20=20= "years"=20=20=20,(round=20(*=2060=2060=2024=20365.2425)))=0A+=20=20=20=20= ("M"=20"month"=20=20"months"=20=20,(round=20(*=2060=2060=2024=20= 30.436875)))=0A+=20=20=20=20("w"=20"week"=20=20=20"weeks"=20=20=20,(*=20= 60=2060=2024=207))=0A+=20=20=20=20("d"=20"day"=20=20=20=20"days"=20=20=20= =20,(*=2060=2060=2024))=0A+=20=20=20=20("h"=20"hour"=20=20=20"hours"=20=20= =20,(*=2060=2060))=0A+=20=20=20=20("m"=20"minute"=20"minutes"=2060)=0A+=20= =20=20=20("s"=20"second"=20"seconds"=201))=0A+=20=20"Formatting=20used=20= by=20the=20function=20`seconds-to-string'=20with=20READABLE=20set.")=0A+=0A= =20;;;###autoload=0A-(defun=20seconds-to-string=20(delay)=0A-=20=20= "Convert=20the=20time=20interval=20in=20seconds=20to=20a=20short=20= string."=0A-=20=20(cond=20((>=200=20delay)=20(concat=20"-"=20= (seconds-to-string=20(-=20delay))))=0A+(defun=20seconds-to-string=20= (delay=20&optional=20readable=20abbrev=20half)=0A+=20=20"Convert=20time=20= interval=20DELAY=20(in=20seconds)=20to=20a=20short=20string.=0A+By=20= default,=20the=20returned=20string=20has=20two=20decimal=20precision=20= in=20the=0A+smallest=20unit=20that=20is=20larger=20than=20DELAY=20from=20= the=20variable=0A+`seconds-to-string'.=20=20If=20READABLE=20is=20= non-nil,=20convert=20DELAY=20into=0A+a=20readable=20string,=20using=20= the=20information=20in=20the=20variable=0A+`seconds-to-string-readable'.=20= =20If=20it=20is=20the=20symbol=20`expanded',=0A+use=20two=20units=20to=20= describe=20DELAY,=20if=20appropriate.=20=20E.g.=20\"1=20hour=0A+32=20= minutes\".=20=20If=20ABBREV=20is=20non-nil,=20abbreviate=20the=20= readable=0A+units.=20=20If=20HALF=20is=20non-nil,=20round=20the=20= smallest=20unit=20displayed=20to=0A+the=20nearest=20half=20unit."=0A+=20=20= (cond=20((>=200=20delay)=20(concat=20"-"=20(seconds-to-string=20(-=20= delay)=20readable=20half)))=0A+=20=20=20=20=20=20=20=20(readable=0A+=20=20= =20=20=20=20=20=20=20(let*=20((stsa=20seconds-to-string-readable)=0A+=09=09= (expanded=20(eq=20readable=20'expanded))=0A+=09=09(round-to=20(if=20half=20= 0.5=201))=0A+=09=09(padding=20(if=20abbrev=20""=20"=20"))=0A+=09=09here=20= cnt=20cnt-pre=20here-pre)=0A+=09=20=20=20(if=20(=3D=20(round=20delay=20= round-to)=200)=0A+=09=20=20=20=20=20=20=20(format=20"0%s"=20(if=20abbrev=20= "s"=20"=20seconds"))=0A+=09=20=20=20=20=20(while=20(and=20(setq=20here=20= (pop=20stsa))=20stsa=0A+=09=09=09=20(<=20(/=20delay=20(nth=203=20here))=20= 1)))=0A+=09=20=20=20=20=20(or=20(and=20expanded=20stsa=0A+=09=09=20=20=20= =20=20=20(progn=0A+=09=09=09(setq=20here-pre=20here=20here=20(car=20= stsa)=0A+=09=09=09=20=20=20=20=20=20cnt-pre=20(floor=20(/=20(float=20= delay)=20(nth=203=20here-pre)))=0A+=09=09=09=20=20=20=20=20=20cnt=20= (round=20(/=20(-=20(float=20delay)=20(*=20cnt-pre=20(nth=203=20= here-pre)))=0A+=09=09=09=09=09=20=20=20=20(nth=203=20here))=0A+=09=09=09=09= =09=20round-to))=0A+=09=09=09(if=20(>=20cnt=200)=20t=20(setq=20here-pre=20= nil))))=0A+=09=20=20=20=20=20=20=20(setq=20cnt=20(round=20(/=20(float=20= delay)=20(nth=203=20here))=20round-to)))=0A+=09=20=20=20=20=20(cl-labels=0A= +=09=09=20((unit=20(cnt=20here=20&optional=20half)=0A+=09=09=20=20=20=20= (cond=20(abbrev=20(car=20here))=0A+=09=09=09=20=20((<=3D=20cnt=20(if=20= half=202=201))=20(nth=201=20here))=0A+=09=09=09=20=20(t=20(nth=202=20= here)))))=0A+=09=20=20=20=20=20=20=20(concat=0A+=09=09(when=20here-pre=0A= +=09=09=20=20(concat=20(number-to-string=20cnt-pre)=20padding=0A+=09=09=09= =20=20(unit=20cnt-pre=20here-pre)=20"=20"))=0A+=09=09(let=20((c=20(if=20= half=20(/=20cnt=202)=20cnt)))=0A+=09=09=20=20(if=20(>=20c=200)=20= (number-to-string=20c)=20""))=0A+=09=09(if=20(and=20half=20(=3D=20(mod=20= cnt=202)=201))=20"=C2=BD"=20"")=0A+=09=09padding=20(unit=20cnt=20here=20= half))))))=0A=20=20=20=20=20=20=20=20=20((=3D=200=20delay)=20"0s")=0A=20=20= =20=20=20=20=20=20=20(t=20(let=20((sts=20seconds-to-string)=20here)=0A=20= =20=20=20=20=20=20=20=20=20=20=20=20=20(while=20(and=20(car=20(setq=20= here=20(pop=20sts)))=0A= --Apple-Mail=_B38B2BEC-FA7C-478A-BD03-EEA617C79540 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii
--Apple-Mail=_B38B2BEC-FA7C-478A-BD03-EEA617C79540-- --Apple-Mail=_44515253-DC03-4933-9260-26CB75A7BFBE-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 04 11:59:22 2024 Received: (at 71572) by debbugs.gnu.org; 4 Jul 2024 15:59:22 +0000 Received: from localhost ([127.0.0.1]:42817 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPOrh-0005sm-Ok for submit@debbugs.gnu.org; Thu, 04 Jul 2024 11:59:22 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44424) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPOrf-0005sX-8D for 71572@debbugs.gnu.org; Thu, 04 Jul 2024 11:59:20 -0400 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 1sPOrT-0004yB-O0; Thu, 04 Jul 2024 11:59:07 -0400 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=O0QHICrjRwMJEiOkUZixSb2mQtyJH05TDcV9vU6azCY=; b=CWVSyEnP01Sg +YON6hV1GqxKQdLjNYK7oj0CIklXTPpe3nC0eS2JHXv/ZF7VMQMpWaOYIynwmHSefjqM5dr4DFn37 hg5uWqNYXvWvwsCEEC69+eSnWUIw/GPjLSmFEkkZnk0bMrwxHbdJB8kYKuISo+DWyl2Kc3yt8vKXV etP9Y69EozpNIUhBhufXdS1NmKNd1hxtk4nk8yNge3uNk9fgPcnT/ejvJoyMB/HgKvSutkIjYdoL4 tVTTwmunh84DBZVRwNdS7gkSxP1vb81tixgxQw69cDE1fIo7neWhReD9Kl05Xk2GY8W0IsJP7GRTw T0fSFbjtXWZPoKg0xuJ2rw==; Date: Thu, 04 Jul 2024 18:59:00 +0300 Message-Id: <86cynt87y3.fsf@gnu.org> From: Eli Zaretskii To: JD Smith In-Reply-To: <1FFF1E0D-A0E0-4EB9-AC97-AEB0BFADFBBC@gmail.com> (message from JD Smith on Thu, 4 Jul 2024 11:27:41 -0400) Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> <1FFF1E0D-A0E0-4EB9-AC97-AEB0BFADFBBC@gmail.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 71572 Cc: adam@alphapapa.net, 71572@debbugs.gnu.org, jonas@bernoul.li, eggert@cs.ucla.edu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: JD Smith > Date: Thu, 4 Jul 2024 11:27:41 -0400 > Cc: Paul Eggert , > 71572@debbugs.gnu.org, > Adam Porter , > jonas@bernoul.li > > > The second item sounds like a useful feature, so maybe an optional > > behavior could provide it as well? > > I've expanded the call format to (delay &optional readable abbrev half) , with READABLE='expanded an option to get the "1 hour 11 min" expanded format, i.e. one larger and one smaller unit (if appropriate). Patch below. Still no documentation... From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 04 12:34:41 2024 Received: (at 71572) by debbugs.gnu.org; 4 Jul 2024 16:34:42 +0000 Received: from localhost ([127.0.0.1]:42850 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPPPt-0006qV-D7 for submit@debbugs.gnu.org; Thu, 04 Jul 2024 12:34:41 -0400 Received: from mout01.posteo.de ([185.67.36.65]:43051) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPPPr-0006qH-8N for 71572@debbugs.gnu.org; Thu, 04 Jul 2024 12:34:40 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id AABCF240027 for <71572@debbugs.gnu.org>; Thu, 4 Jul 2024 18:34:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1720110870; bh=zbUX1KYJD5ewDd66U3iYLAi5YVVW/U8JKgEG1+j9I1k=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=cTgix/VSHBUOgAwYDwxyB/JxkVeG1adPQiQPZnM/UbKrDmn1dybBUueq2ZmSNYE6b tYK30npD+2KmAq6jTo4RNXePmLpV4N+fGVDEmym9eCIlFuUM/HRYRI1mVOrpHBO647 n+UVroRTuhl/U0i6ZYGlz26awl4i7WgEwFyP1GE3A0uq9s7Mgg+5qgkdIC0xqMUbsP BR3bY4szzW3PL7gQel+TL0IrfEQUV1b1+U9lsJ1ixUq/5mY6GBARhNIdyPGinee+Wy 3bnpwFBmU348UZHsGJE0urfyPBTKGp0Eu6DX41YDx1t90soxWTfLMMJewR2qrbPpVX xppVUv6wwemDg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4WFMg73vDgz9rxD; Thu, 4 Jul 2024 18:34:27 +0200 (CEST) From: Ihor Radchenko To: JD Smith Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate In-Reply-To: <1FFF1E0D-A0E0-4EB9-AC97-AEB0BFADFBBC@gmail.com> References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> <1FFF1E0D-A0E0-4EB9-AC97-AEB0BFADFBBC@gmail.com> Date: Thu, 04 Jul 2024 16:36:03 +0000 Message-ID: <87plrt9kss.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 71572 Cc: Adam Porter , 71572@debbugs.gnu.org, Eli Zaretskii , jonas@bernoul.li, Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) JD Smith writes: > The latter issue results simply from my truncation of the initial delay column to 1 decimal digit. E.g. .45s * 2.3^3 = 5.47515s, so s2s has it right. > >> The second item sounds like a useful feature, so maybe an optional >> behavior could provide it as well? > > I've expanded the call format to (delay &optional readable abbrev half) , with READABLE='expanded an option to get the "1 hour 11 min" expanded format, i.e. one larger and one smaller unit (if appropriate). Patch below. Have you seen `org-duration-from-minutes'? In Org mode, we have a rather complex (but flexible) system to customize the duration format: (defcustom org-duration-format '(("d" . nil) (special . h:mm)) "Format definition for a duration. The value can be set to, respectively, the symbols `h:mm:ss' or `h:mm', which means a duration is expressed as, respectively, a \"H:MM:SS\" or \"H:MM\" string. Alternatively, the value can be a list of entries following the pattern: (UNIT . REQUIRED?) UNIT is a unit string, as defined in `org-duration-units'. The time duration is formatted using only the time components that are specified here. Units with a zero value are skipped, unless REQUIRED? is non-nil. In that case, the unit is always used. The list can also contain one of the following special entries: (special . h:mm) (special . h:mm:ss) Units shorter than an hour are ignored. The hours and minutes part of the duration is expressed unconditionally with H:MM, or H:MM:SS, pattern. (special . PRECISION) A duration is expressed with a single unit, PRECISION being the number of decimal places to show. The unit chosen is the first one required or with a non-zero integer part. If there is no such unit, the smallest one is used. Eventually, if the list contains the symbol `compact', the duration is expressed in a compact form, without any white space between units. For example, ((\"d\" . nil) (\"h\" . t) (\"min\" . t)) means a duration longer than a day is expressed in days, hours and minutes, whereas a duration shorter than a day is always expressed in hours and minutes, even when shorter than an hour. On the other hand, the value ((\"d\" . nil) (\"min\" . nil)) means a duration longer than a day is expressed in days and minutes, whereas a duration shorter than a day is expressed entirely in minutes, even when longer than an hour. The following format ((\"d\" . nil) (special . h:mm)) means that any duration longer than a day is expressed with both a \"d\" unit and a \"H:MM\" part, whereas a duration shorter than a day is expressed only as a \"H:MM\" string. Eventually, ((\"d\" . nil) (\"h\" . nil) (special . 2)) expresses a duration longer than a day as a decimal number, with a 2-digits fractional part, of \"d\" unit. A duration shorter than a day uses \"h\" unit instead." -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 04 13:17:54 2024 Received: (at 71572) by debbugs.gnu.org; 4 Jul 2024 17:17:54 +0000 Received: from localhost ([127.0.0.1]:42892 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPQ5i-0007zU-HN for submit@debbugs.gnu.org; Thu, 04 Jul 2024 13:17:54 -0400 Received: from mail-ot1-f54.google.com ([209.85.210.54]:57756) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPQ5g-0007zD-B6 for 71572@debbugs.gnu.org; Thu, 04 Jul 2024 13:17:53 -0400 Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-7034d975f18so337540a34.3 for <71572@debbugs.gnu.org>; Thu, 04 Jul 2024 10:17:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720113403; x=1720718203; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=l5y930XUHq5+w0527au5mmDTGn4iZHK4hkHoBYpBKXg=; b=ZcK0GjeiOkLEVV5sA07I+ppdLfYR4tVEQXOeSoYunCN+HFI02kx7o2qO+r/gi/TV11 0Esgdm9KS3EUszgix0lw9oNwh5rQju9PDwSVKykofALgeXROEMTssCHY/HCoNXWpsKQy EZTN/hpHX6bo/DNM/NTqhDNPlWwg6AAd2DqehhmNJOiUfrGWZWRkPZgG/B3cdRI4Ho1y 4qTgB6dzegg6Fzf+Q5WrgA3QuXzwKlYKJxW+7ZgJ6vh4NpTZS84NCBROVzzjhsZ7w29l Z2ybyIsfTu6vXMRljNNf9dugXr4DA8UraDSalPK11jqCYPSJLdI8++TRdu0Htzlxo62w BZ7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720113403; x=1720718203; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l5y930XUHq5+w0527au5mmDTGn4iZHK4hkHoBYpBKXg=; b=ioakP/fqYYIxWxCw3vdoWDQZwaKu578KpbwH0Wlooc318pmo8CjqoNgiQ71cfHdYrB e5Au3GfgIZV/oYVTbxQnFzELkXMA6OrjXTNVcT0ipfj6iPY8mEkKAov37Yyk42Zqh0k1 BmSrrijGBcc1+C5CMci1RBFrt5+JiRITgQbX+zyC22Y9DW8lb/hBGLIZzrspCtj+P1d5 e57rlhT4PRkjtqolYP897uR+vUYZMEfWB7AYUDNREsDYoDFmjerp6a8S7QRzmPrsf8PK +0VWIraZh5bXeBacHNHeGugMumB2nbRfUU9P32SLtKLP0E5Sd0b418MgaCbMaQC83tUJ ujUA== X-Forwarded-Encrypted: i=1; AJvYcCXPzidJVkUzbSQqKglaV7VE8RGwVZN8XvvDerTEFNJFSN4wK80noJRrP9BcLl74r6vu1Qx/4xpA/LVwOJ6XWOx05YRDstQ= X-Gm-Message-State: AOJu0Yxskjhk7AehekdAZwmu6/Tu66gh06r6IFoEuZWMy3hoxgJQ5EhS 77oGJ03WNwBE1XMeAWZQw+ieexbHYV9ov6w6as1R1Gr7nYhD8O/3 X-Google-Smtp-Source: AGHT+IHq8FzTBGbyGDb7FjL0CSc3s32La4X5NiOmGdXp2C1l7N5I6OeTjy/3//3yLi+QqmIhEXkU+A== X-Received: by 2002:a9d:6d92:0:b0:702:1f38:a86e with SMTP id 46e09a7af769-7034a757498mr2759975a34.12.1720113403505; Thu, 04 Jul 2024 10:16:43 -0700 (PDT) Received: from smtpclient.apple (cm-24-53-187-34.buckeyecom.net. [24.53.187.34]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79d6926472asm692029085a.7.2024.07.04.10.16.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jul 2024 10:16:42 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate From: JD Smith In-Reply-To: <86cynt87y3.fsf@gnu.org> Date: Thu, 4 Jul 2024 13:16:32 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: <8A7EBBD1-45FF-45E2-900A-56408341E978@gmail.com> References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> <1FFF1E0D-A0E0-4EB9-AC97-AEB0BFADFBBC@gmail.com> <86cynt87y3.fsf@gnu.org> To: Eli Zaretskii X-Mailer: Apple Mail (2.3774.600.62) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 71572 Cc: Adam Porter , 71572@debbugs.gnu.org, jonas@bernoul.li, Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On Jul 4, 2024, at 11:59=E2=80=AFAM, Eli Zaretskii = wrote: >=20 >> From: JD Smith >> Date: Thu, 4 Jul 2024 11:27:41 -0400 >> Cc: Paul Eggert , >> 71572@debbugs.gnu.org, >> Adam Porter , >> jonas@bernoul.li >>=20 >>> The second item sounds like a useful feature, so maybe an optional >>> behavior could provide it as well? >>=20 >> I've expanded the call format to (delay &optional readable abbrev = half) , with READABLE=3D'expanded an option to get the "1 hour 11 min" = expanded format, i.e. one larger and one smaller unit (if appropriate). = Patch below. >=20 > Still no documentation... It seems sensible to finalize the design before documenting. Where do = you think the documentation should go?= From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 04 13:24:32 2024 Received: (at 71572) by debbugs.gnu.org; 4 Jul 2024 17:24:32 +0000 Received: from localhost ([127.0.0.1]:42900 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPQC8-0008AY-DC for submit@debbugs.gnu.org; Thu, 04 Jul 2024 13:24:32 -0400 Received: from mail-qk1-f182.google.com ([209.85.222.182]:47440) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPQC5-0008AG-IB for 71572@debbugs.gnu.org; Thu, 04 Jul 2024 13:24:30 -0400 Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-79c06c08149so56456185a.3 for <71572@debbugs.gnu.org>; Thu, 04 Jul 2024 10:24:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720113801; x=1720718601; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=Z7l9nlKQ2qViTS8FNXne7BF8fAyMEkTEnRoQbzk950M=; b=iXKSA+sZtyS+is4M+ZRzFypz2iRVEnYayF/PcweQMNchy/TgMkHr3O5loKJEI8nO9P 3bcYKUY6iCk2SqEsXHHZ765y6Oot24LYLfeQpj504vwvgONtfpueBDoxVSJNvcOSbVWb xf0Kwl5Sw1J0Rs2dTVUPLJxRw6Wtx61Nu+J6m0w8Fccib2Q8mnQuVuopmaq0QAeAXMsH aoUWFEPn/UXONVQKwHwsFwSsTIXlt/o4YSzMbQOkWNIlQt4wp2Bx+fINC5jzrll4bDeV Oy028g5BDslC6Z4iL4Szx0tkxf6KORQGY/TqYpTNpETxOHXCsyFrFnEFDmBWGz5xIrBW oknQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720113801; x=1720718601; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Z7l9nlKQ2qViTS8FNXne7BF8fAyMEkTEnRoQbzk950M=; b=QcDyQVD3xtrVwS6N57+tL8II/vjIFzrr4uZgLJvC6aTYfebzkK8RcdY44CHoiBMql/ JfsB5wU4AChnpXHsnAzOyozXonMQczKvUkpNBrrVIunu/XVN66QgoJH2Zmn6Muv2FOLj XLVwN/dWBImzt0HwJhg2Aw7lYTMt/Ih7TaEkcPFF5G02OV+ahHo3q3jAY3SLZX+1K3V/ UiA/Qz22O6gt3wEq70PUJz1XJAJWE3WmN+A5m6ZG5SNanoGMFzY22SePXAY1SQCeVvEZ 7qOa1BRG/j2W0wFmjqbHpROTj1yiVlTAeuwJqGoMOKyrBZjKj1WfGlPfW4l9RAQr8sdY 0KyQ== X-Forwarded-Encrypted: i=1; AJvYcCXmKplP8OTczJpqfiGrlN6Pw0TLmtCugN3NvWw4KqLSGa9nOuqwbKxPBKSqt3JcDlgN0mCO1EtwR9qurz513SVGOa6geAk= X-Gm-Message-State: AOJu0YwCTjm+aXW+87zdbNwjq0HhVKSVMSN/Sa/TL7uzsMFSWkU5reBN /IPModaiBBOSOwEnUzElwlHbEpd7HwC9E7Ez0MxrfOTuWBM4QfAG X-Google-Smtp-Source: AGHT+IEasKLmvNzJo3PVnIfaQP/3OzxsUWkDyRFFczAxl+oKv/G05+IQwP/J5qZC5HFpZt/xZqYscg== X-Received: by 2002:a05:620a:2492:b0:79d:535f:b799 with SMTP id af79cd13be357-79eee27403fmr294205085a.50.1720113801250; Thu, 04 Jul 2024 10:23:21 -0700 (PDT) Received: from smtpclient.apple (cm-24-53-187-34.buckeyecom.net. [24.53.187.34]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4465149842csm61422071cf.61.2024.07.04.10.23.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jul 2024 10:23:20 -0700 (PDT) From: JD Smith Message-Id: <88073600-0BF6-4EA1-9EE4-9455FDF20EAC@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_ABF01B31-9B8B-4AFD-929D-EEBD0DB95AF9" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate Date: Thu, 4 Jul 2024 13:23:09 -0400 In-Reply-To: <87plrt9kss.fsf@localhost> To: Ihor Radchenko References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> <1FFF1E0D-A0E0-4EB9-AC97-AEB0BFADFBBC@gmail.com> <87plrt9kss.fsf@localhost> X-Mailer: Apple Mail (2.3774.600.62) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 71572 Cc: Adam Porter , 71572@debbugs.gnu.org, Eli Zaretskii , jonas@bernoul.li, Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Apple-Mail=_ABF01B31-9B8B-4AFD-929D-EEBD0DB95AF9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jul 4, 2024, at 12:36=E2=80=AFPM, Ihor Radchenko = wrote: >=20 > Have you seen `org-duration-from-minutes'? > In Org mode, we have a rather complex (but flexible) system to = customize > the duration format: I had not seen that function, thanks for pointing it out. Looks useful = and rather flexible. Would you be able to re-use the example code I = posted earlier to show how it formats various ages with typical = configuration? For activities (which is the package where the conversation about this = need started), you can have ages from seconds to many years, so you need = something that accommodates that dynamic range well. magit--age was the = inspiration, and we're in fact just reusing Jonas' configuration = variable.= --Apple-Mail=_ABF01B31-9B8B-4AFD-929D-EEBD0DB95AF9 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Jul 4, 2024, at 12:36=E2=80=AFPM, Ihor Radchenko = <yantar92@posteo.net> wrote:

Have = you seen `org-duration-from-minutes'?
In Org = mode, we have a rather complex (but flexible) system to = customize
the duration = format:

I had not seen that = function, thanks for pointing it out.  Looks useful and rather = flexible.  Would you be able to re-use the example code I posted = earlier to show how it formats various ages with typical = configuration?

For activities (which is the = package where the conversation about this need started), you can have = ages from seconds to many years, so you need something that accommodates = that dynamic range well.  magit--age was the inspiration, and we're = in fact just reusing Jonas' configuration variable.
= --Apple-Mail=_ABF01B31-9B8B-4AFD-929D-EEBD0DB95AF9-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 04 13:56:43 2024 Received: (at 71572) by debbugs.gnu.org; 4 Jul 2024 17:56:43 +0000 Received: from localhost ([127.0.0.1]:42914 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPQhH-0000aY-41 for submit@debbugs.gnu.org; Thu, 04 Jul 2024 13:56:43 -0400 Received: from mout01.posteo.de ([185.67.36.65]:35561) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPQhF-0000aG-6g for 71572@debbugs.gnu.org; Thu, 04 Jul 2024 13:56:41 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id C7E64240027 for <71572@debbugs.gnu.org>; Thu, 4 Jul 2024 19:56:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1720115792; bh=o/dOpi+KLj0SE9YZdYX/kuIBBGGmCR4GY5Zpd8WTE1k=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=LtTP0SAQBnEwg2+kbO7bd8AlBH+nqqlw746DSdfYEZ7OID/CygT9w39IlJgH72xlz fW6m/J3tj4b97IBREZoQ8e6cntSk5DPL7o639WC0L1s5PVTUeiFO3MoeeNxbNlAbqE QvwUxdKHQ9LFKmqQdilaOxzEXC9kshbK44a9LQlXHdbjniEr8nszEyMauvv9E/1PlL 7MEbRmdUO1sMW8iQBCbF5T0nLptbPNjOoc6T28L3NujneWivO1GF/PCHvKFPyMt0II w0ghYThq+1Xp1Cb7ecpPcDsqvwnOwU6RlgoP6dpoMDJJtDqhzBO0NRwLaoTs3XaPKB XmEXInb+nvsaA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4WFPTl3W6Bz6tyn; Thu, 4 Jul 2024 19:56:27 +0200 (CEST) From: Ihor Radchenko To: JD Smith Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate In-Reply-To: <88073600-0BF6-4EA1-9EE4-9455FDF20EAC@gmail.com> References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> <1FFF1E0D-A0E0-4EB9-AC97-AEB0BFADFBBC@gmail.com> <87plrt9kss.fsf@localhost> <88073600-0BF6-4EA1-9EE4-9455FDF20EAC@gmail.com> Date: Thu, 04 Jul 2024 17:57:55 +0000 Message-ID: <87jzi19h0c.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 71572 Cc: Adam Porter , 71572@debbugs.gnu.org, Eli Zaretskii , jonas@bernoul.li, Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) JD Smith writes: > I had not seen that function, thanks for pointing it out. Looks useful a= nd rather flexible. Would you be able to re-use the example code I posted = earlier to show how it formats various ages with typical configuration? > > For activities (which is the package where the conversation about this ne= ed started), you can have ages from seconds to many years, so you need some= thing that accommodates that dynamic range well. magit--age was the inspir= ation, and we're in fact just reusing Jonas' configuration variable. Delay (s) s-to-s mastodon mastodon (3600s) mast (1y= r) s-to-s (rdb) Org Org (frac) s-to-s (rdb=3Dabbrev, = half) 0.5 450.00ms 0 sec 0 sec 0 s= ec 0s 0min 0.01min =C2=BDs 1.0 1.03s 1 sec 1 sec 1 s= ec 1s 0min 0.02min 1s 2.4 2.38s 2 secs 2 secs 2 se= cs 2s 0min 0.04min 2=C2=BDs 5.5 5.48s 5 secs 5 secs 5 se= cs 5s 0min 0.09min 5=C2=BDs 12.6 12.59s 12 secs 12 secs 12 se= cs 13s 0min 0.21min 12=C2=BDs 29.0 28.96s 28 secs 28 secs 28 se= cs 29s 0min 0.48min 29s 66.6 66.62s 1 min 1 min 1 m= in 1m 1min 1.11min 1m 153.2 2.55m 2 mins 2 mins 2 mi= ns 3m 2min 2.55min 2=C2=BDm 352.4 5.87m 5 mins 5 mins 5 mi= ns 6m 5min 5.87min 6m 810.5 13.51m 13 mins 13 mins 13 mi= ns 14m 13min 13.51min 13=C2=BDm 1864.2 31.07m 31 mins 31 mins 31 mi= ns 31m 31min 31.07min 31m 4287.6 71.46m 1 hour, 11 mins 1 hour 1 ho= ur 1h 1h 11min 1.19h 1h 9861.6 2.74h 2 hours, 44 mins 2 hours 2 hou= rs 3h 2h 44min 2.74h 2=C2=BDh 22681.6 6.30h 6 hours, 18 mins 6 hours 6 hou= rs 6h 6h 18min 6.30h 6=C2=BDh 52167.8 14.49h 14 hours, 29 mins 14 hours 14 hou= rs 14h 14h 29min 14.49h 14=C2=BDh 119985.9 1.39d 1 day, 9 hours 1 day, 9 hours 1 d= ay 1d 1d 9h 19min 1.39d 1=C2=BDd 275967.5 3.19d 3 days, 4 hours 3 days, 4 hours 3 da= ys 3d 3d 4h 39min 3.19d 3d 634725.2 7.35d 1 week 1 week 1 we= ek 1w 7d 8h 18min 7.35d 1w 1459867.9 16.90d 2 weeks, 2 days 2 weeks, 2 days 2 wee= ks 2w 16d 21h 31min 16.90d 2=C2=BDw 3357696.2 38.86d 1 month, 1 week 1 month, 1 week 1 mon= th 1M 1m 8d 20h 41min 1.30m 1=C2=BDM 7722701.2 89.38d 2 months, 4 weeks 2 months, 4 weeks 2 mont= hs 3M 2m 29d 9h 11min 2.98m 3M 17762212.9 205.58d 6 months, 3 weeks 6 months, 3 weeks 6 mont= hs 7M 6m 25d 13h 56min 6.85m 7M 40853089.6 1.29y 1 year, 3 months 1 year, 3 months 1 ye= ar 1Y 1y 3m 17d 14h 4min 1.29y 1=C2=BDY 93962106.0 2.98y 2 years, 11 months 2 years, 11 months 2 yea= rs 3Y 2y 11m 27d 35min 2.98y 3Y 216112843.8 6.85y 6 years, 10 months 6 years, 10 months 6 yea= rs 7Y 6y 10m 9d 19h 20min 6.85y 7Y 497059540.7 15.75y 15 years, 9 months 15 years, 9 months 15 yea= rs 16Y 15y 9m 4d 6h 5min 15.75y 16Y (concat (format "%11s %10s %18s %18s %12s %12s %20s %14s %s\n" "Delay (s)" "s= -to-s" "mastodon" "mastodon (3600s)" "mast (1yr)" "s-to-s (rdb)" "Org" "Org (fra= c)" "s-to-s (rdb=3Dabbrev, half)") (cl-loop for s =3D 0.45 then (* s 2.3) while (< s (* 365.25 24 3600 22)) concat (format "%11.1f %10s %18s %18s %12s %12s %20s %14s %s\n" s (seconds-to-string s) (car (mastodon-tl--human-duration s)) (car (mastodon-tl--human-duration s 3600)) (car (mastodon-tl--human-duration s (* 365.25 24 3600))) (seconds-to-string-approximate s t) (org-duration-from-minutes (/ s 60) '(("y" . nil) = ("m" . nil) ("d" . nil) ("h" . nil) ("min" . nil))) (org-duration-from-minutes (/ s 60) '(("y" . nil) = ("m" . nil) ("d" . nil) ("h" . nil) ("min" . nil) (special . 2) compact)) (seconds-to-string-approximate s 'abbrev 'half)))) --=20 Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 04 14:06:17 2024 Received: (at 71572) by debbugs.gnu.org; 4 Jul 2024 18:06:17 +0000 Received: from localhost ([127.0.0.1]:42924 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPQqW-0000ru-N5 for submit@debbugs.gnu.org; Thu, 04 Jul 2024 14:06:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59284) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sPQqT-0000rg-Sp for 71572@debbugs.gnu.org; Thu, 04 Jul 2024 14:06:15 -0400 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 1sPQqJ-0001KL-M2; Thu, 04 Jul 2024 14:06:03 -0400 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=EgdFNZg9HZHzoJW9kqfhIecH/4a26j1pE6Q9AGEV3IE=; b=lBtsOFWEbxJy tdrbm3h/iKp0arkNgt3d/Dy5rQyfRmjZkhBDbBaXofpXSbv2oEiEdkpYOKXTWwyXq3CFdd9BbLkyg n389QhAIfR7+axJFb3G86nmpOWJS4AdEwbQMrWnztNSDgBJ7zNCClZXCN7yTpLmBuN0SFFTUp4G73 HdkWz9GO18pgVSUyKsz0gMmTnVihsPAM0mW46d/cb1+YpDPL5AzrAVB8+MDe8shjSgBvnqQrQgYZo ZHq8OaVTQUDngiN/sba7vYnMOnZI50MDp3CCbpFs0iM4AzTV32wlnq/cEHGQqGfH9zjhkIyVntzBS erxl4NPYrASKTtrz/mtR3g==; Date: Thu, 04 Jul 2024 21:06:00 +0300 Message-Id: <865xtl822f.fsf@gnu.org> From: Eli Zaretskii To: JD Smith In-Reply-To: <8A7EBBD1-45FF-45E2-900A-56408341E978@gmail.com> (message from JD Smith on Thu, 4 Jul 2024 13:16:32 -0400) Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> <1FFF1E0D-A0E0-4EB9-AC97-AEB0BFADFBBC@gmail.com> <86cynt87y3.fsf@gnu.org> <8A7EBBD1-45FF-45E2-900A-56408341E978@gmail.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 71572 Cc: adam@alphapapa.net, 71572@debbugs.gnu.org, jonas@bernoul.li, eggert@cs.ucla.edu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: JD Smith > Date: Thu, 4 Jul 2024 13:16:32 -0400 > Cc: Paul Eggert , > 71572@debbugs.gnu.org, > Adam Porter , > jonas@bernoul.li > > > Still no documentation... > > It seems sensible to finalize the design before documenting. Where do you think the documentation should go? "Time Calculations", I'd say. It should also be mentioned in NEWS. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 06 15:30:25 2024 Received: (at 71572) by debbugs.gnu.org; 6 Jul 2024 19:30:25 +0000 Received: from localhost ([127.0.0.1]:46765 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sQB73-0001vz-1o for submit@debbugs.gnu.org; Sat, 06 Jul 2024 15:30:25 -0400 Received: from mail-qt1-f181.google.com ([209.85.160.181]:53569) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sQB70-0001vh-ER for 71572@debbugs.gnu.org; Sat, 06 Jul 2024 15:30:23 -0400 Received: by mail-qt1-f181.google.com with SMTP id d75a77b69052e-444fdb6c1cfso16325961cf.3 for <71572@debbugs.gnu.org>; Sat, 06 Jul 2024 12:30:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720294153; x=1720898953; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=DKkfZNnrjh+Vdv0ndkuy+nMvhR0xzGYuE6zCY9bPzXQ=; b=mQhsPRQaOW12neAawkG2vPS1qwrTdAbzuBHl8hhHRvZp0agrErmtiNEClqEq892PrU 3NkFzofuCIbW3EV6Pc9UyvGx/ozPH48+Ober3TUaHuZNUikl8LYXGf8cUGWjiS8gGU2p sPLB8iY4yL4beqrTy9Sw7fhrQsINx0L2LFbETBjGbBYl0a7O9ertzkr32z9akgywRwdT CKoo0hx5+yu28cACBn0llhHh8qjS0TE0TRpmTAA0IzTJXERk907VFEB/ABx5pjawp6Lm lfRcgYzITweKloHQiSTSsdb/AEgDQGg51OiMIur/TANuHJcBmTlLdz/cMmzsP+Dj1soM sKbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720294153; x=1720898953; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DKkfZNnrjh+Vdv0ndkuy+nMvhR0xzGYuE6zCY9bPzXQ=; b=m6EuYlKp/WwDlEM/LyuS81q9/rr/nVltVeMdS6tThwl08x+iqhe4uUUdGnG149Xa8g KYl0P01L0rHBoL5Vbx5GvTzJA0mzOU8a++spfUtX/VypFpmcYttmclZ4ESgF90RDCGQc nxXMMh3JF0YbxSc/5DkeF+T2ElD7iDv+M1FTSA9O/3tyv6GxUsvN0LIMVNnWh5iw850J 5A3tTl5BZemriE5347LIcg4E5r8ygF407ZRqgPn4SGyX5+KpNQY2jYm7RtC/puBKCzgC NsN65ONeahYG+jnQTpsklSJPC5aHt82xabgTmByoYlk2g93O5vkAySliwkQ2TQxEg7N2 H6wQ== X-Forwarded-Encrypted: i=1; AJvYcCVDnSIM8LYdyehsmbs3SkJWNox3ERHUXLr2bsuzPeuo1/isedHmTcKGwH2v44w8iA0KXXIJcNRWaP/LJfVro5FHARjWdFM= X-Gm-Message-State: AOJu0YyholY5Ozp1oeWnc49WNVhKN7WQ3a8vn/M9TDjokkPNvcKpK0Va MhNOarWqK/VUsYhVOa8bCSU7x+FF4IfOampBpj5SSVOgXr76miGo X-Google-Smtp-Source: AGHT+IH8VTet0zk6uPM/V0/0Yz2VIXSYTvYyZgv+WgoNpHTGoRKLTJhzmq55bwv83/zHxyvUPNoEFw== X-Received: by 2002:a05:622a:1815:b0:447:e532:b370 with SMTP id d75a77b69052e-447e532badbmr18692291cf.10.1720294153040; Sat, 06 Jul 2024 12:29:13 -0700 (PDT) Received: from smtpclient.apple (cm-24-53-187-34.buckeyecom.net. [24.53.187.34]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-446514984b6sm80609521cf.68.2024.07.06.12.29.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 06 Jul 2024 12:29:12 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate From: JD Smith In-Reply-To: <3530cd89-b5a2-4b25-95bf-1896c8ee4aef@cs.ucla.edu> Date: Sat, 6 Jul 2024 15:29:01 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> <3530cd89-b5a2-4b25-95bf-1896c8ee4aef@cs.ucla.edu> To: Paul Eggert X-Mailer: Apple Mail (2.3774.600.62) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 71572 Cc: Adam Porter , 71572@debbugs.gnu.org, Eli Zaretskii , jonas@bernoul.li X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) > On Jul 4, 2024, at 3:09=E2=80=AFAM, Paul Eggert = wrote: >=20 > On 7/4/24 06:29, Eli Zaretskii wrote: >=20 >> . seconds-to-string lacks the "1 hour 11 min" output format >=20 > That format could be confusing with negative delays, e.g., "-1 hour 11 = min". Does anyone share this concern for negative delays? I wouldn't have = trouble interpreting that (and negative delays are likely the rare = case). > I'm not sold on the "half" argument; seems like a cuteness rather than = a feature that's all that useful (among other things, it assumes Unicode = or something like it). Is this an actual problem, i.e. do we universally avoid unicode in core = files? We could drop the HALF, but it's to me quite useful when = rounding to just a few weeks or months. > What's really going on here is that there's an optional argument = specifying style and I imagine that style preferences will differ = (Mastodon style, etc.). There are 1000 different ways to come at this; we currently offer 17 = "styles": 16 "readable" plus the original seconds-to-string style. > Is there an ISO or similar standard for this sort of thing? I've never seen one if so. Any other thoughts? From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 06 17:09:25 2024 Received: (at 71572) by debbugs.gnu.org; 6 Jul 2024 21:09:26 +0000 Received: from localhost ([127.0.0.1]:46863 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sQCer-0004Qj-Kh for submit@debbugs.gnu.org; Sat, 06 Jul 2024 17:09:25 -0400 Received: from mail.cs.ucla.edu ([131.179.128.66]:39580) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sQCep-0004QY-Lq for 71572@debbugs.gnu.org; Sat, 06 Jul 2024 17:09:24 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 752B13C00E40B; Sat, 6 Jul 2024 14:09:14 -0700 (PDT) Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10032) with ESMTP id QhaGH0pd-YcC; Sat, 6 Jul 2024 14:09:14 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 3996A3C00E413; Sat, 6 Jul 2024 14:09:14 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.cs.ucla.edu 3996A3C00E413 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu; s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C; t=1720300154; bh=3UGoILJWuGg4QInNSgg2Cxsks7AYYMapm8mXx0xXb1E=; h=Message-ID:Date:MIME-Version:To:From; b=k2x7dw0HBuXkPMw2yZd09x6KyryT1rwhkPIdFTDLDAciW4u4wV8vx6elXoQVQ9Fzc wtYdvspLOmeEiEVzdiEVSz7ACYOyY5pevRd4r8IdXe7+6p4N5ivi1vSx5S3gg4z9Xk bcdb+70uUAz+i8NYvPRsdR69TbKCblXu2cpT81XlO53jWUUZXuGRkE8lOfRLNo+dct Aib3uO+yMr9wsujRAlH6oUDucQ7clYqnQQjn6GelSycnjQ4+GNtyAFSPLHvwgv6ADK aY6xgJVHQ98HgdB08rjBhW41/yqzS66uNS2LNubSQO11J5KzdISDZ5RdXFB/0bjhIh qmdGEuGGp/HbA== X-Virus-Scanned: amavis at mail.cs.ucla.edu Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10026) with ESMTP id XMDiSAarjVIe; Sat, 6 Jul 2024 14:09:14 -0700 (PDT) Received: from [192.168.0.105] (host-85-26-35-49.dynamic.voo.be [85.26.35.49]) by mail.cs.ucla.edu (Postfix) with ESMTPSA id E33C73C00E40B; Sat, 6 Jul 2024 14:09:12 -0700 (PDT) Message-ID: Date: Sat, 6 Jul 2024 23:09:11 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate To: JD Smith References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> <3530cd89-b5a2-4b25-95bf-1896c8ee4aef@cs.ucla.edu> Content-Language: en-US From: Paul Eggert In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 71572 Cc: Adam Porter , 71572@debbugs.gnu.org, Eli Zaretskii , jonas@bernoul.li X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 7/6/24 21:29, JD Smith wrote: > do we universally avoid unicode in core files? Not in comments, but even today it's wise to be cautious about=20 generating user-visible Unicode characters like "=C2=BD" when there's a=20 simple ASCII substitute like ".5". Plus, why stop with =C2=BD? Why not al= so=20 do =C2=BC and =C2=BE? It might be better to have an optional precision argument, defaulting to=20 0, specifying the number of digits of precision after the decimal point.=20 Or something like that. From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 11 17:02:28 2024 Received: (at 71572) by debbugs.gnu.org; 11 Jul 2024 21:02:28 +0000 Received: from localhost ([127.0.0.1]:52665 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sS0vr-0003Gb-AE for submit@debbugs.gnu.org; Thu, 11 Jul 2024 17:02:28 -0400 Received: from mail-qk1-f175.google.com ([209.85.222.175]:45405) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sS0vo-0003GJ-9v for 71572@debbugs.gnu.org; Thu, 11 Jul 2024 17:02:26 -0400 Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-79f1be45ca8so77872585a.3 for <71572@debbugs.gnu.org>; Thu, 11 Jul 2024 14:02:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720731678; x=1721336478; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=KgmHAgOnDm7ysNGnxm5GAy0Jz8V+cO6Eemesz8gUH0w=; b=jyVZkVDtMjLGsWPy/BztgPZODpvCjGWBx0XR/WESbSoqAEtwidHEPcmistXad8v+HO bbDZAEY9hwBxWrcqOzDUGVFruJyiKoYR73z+voAvlE+MmbiI9D8d7fXhnpacOJSFCVQz th0SnaBNGVqPZE8HR8wL+5DsD1sNBYaI2gvvbsdmAlNfns5d6ORwjJl2jRK5Y3MHiQWr FY0km0zPb+ARr8vnPm80d377lvji5vDwUcV0judTyn+eaL5KJmz8iOjImGOGyZP2TKlp ZOge1obvSh+LWgzDJBZng9gghR26L5DE0pOtkXJUTdOmYY0QuSLKMFF1GM+wj7vwpE1S mRxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720731678; x=1721336478; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KgmHAgOnDm7ysNGnxm5GAy0Jz8V+cO6Eemesz8gUH0w=; b=iccNdeBGRR4WbPs9JohCjMZ6jJKqz/5EohDOVdX7UiOXhGoGW8PHk8y+1eCQuTYVN8 ZBNho4rZJNll5l00obqYc8uhJ03n729uH2y8+OjePbmgGzMiD5ZBm937b+X1YCMBDckN KHz408myyQ4s/bMm479+AhD3+u1KzbbkzE+3LGpKysa3ve4S/CrNx/KYm33VXJE7MCV6 l0u13atUZB1f8MknrysGJ3CSnHurMyrQiW2DUzAynVpTgpEuflcdbJIUGIEUIStEM46v sOga9YM+OJb9YZwSHplP5k3AJlDffI6U6CnwzT6TEdCwmdwA0uEDdl3x6s3wD//cPLnO /u1A== X-Gm-Message-State: AOJu0YzSnMZF361OuTymbl29IVwYPTqeMikDFOWrkaNMoMk0WqJr+Idk FHZhzK5QJjojb8TWsSWbXGbMcYknTC3UXyz4Awof/TUd6sQMISSCtXkbMg== X-Google-Smtp-Source: AGHT+IFqlmftUTut1d4OEy1puYmBlxfpET79eFTNHLvEIfrq2HGHmU3J2UMSDGOFmJzh/1IYSpwsdg== X-Received: by 2002:a05:620a:233:b0:79f:1cf:551e with SMTP id af79cd13be357-79f19a51e10mr994387585a.5.1720731678018; Thu, 11 Jul 2024 14:01:18 -0700 (PDT) Received: from smtpclient.apple ([131.183.131.33]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79f1902966csm327036885a.55.2024.07.11.14.01.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jul 2024 14:01:17 -0700 (PDT) From: JD Smith Message-Id: <8CC4B1BB-B56A-4C3E-8B51-0E2D5B65C296@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_81DD6890-84BD-4B48-ACF9-160C3B7CA8C1" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate Date: Thu, 11 Jul 2024 17:01:05 -0400 In-Reply-To: To: 71572@debbugs.gnu.org References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> <3530cd89-b5a2-4b25-95bf-1896c8ee4aef@cs.ucla.edu> X-Mailer: Apple Mail (2.3774.600.62) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 71572 Cc: Adam Porter , Eli Zaretskii , jonas@bernoul.li, Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Apple-Mail=_81DD6890-84BD-4B48-ACF9-160C3B7CA8C1 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jul 6, 2024, at 5:09=E2=80=AFPM, Paul Eggert = wrote: >=20 > On 7/6/24 21:29, JD Smith wrote: >> do we universally avoid unicode in core files? >=20 > Not in comments, but even today it's wise to be cautious about = generating user-visible Unicode characters like "=C2=BD" when there's a = simple ASCII substitute like ".5". Plus, why stop with =C2=BD? Why not = also do =C2=BC and =C2=BE? >=20 > It might be better to have an optional precision argument, defaulting = to 0, specifying the number of digits of precision after the decimal = point. Or something like that. Thanks for the feedback. Attached find an updated patch: - HALF is dropped. - PRECISION can now be specified as a whole-number of digits or a float = <1.0 (e.g. 0.5) - NEWS and doc entries. Users who want =C2=BD can always use precision=3D0.5 and edit the string = after the fact. Another attached file includes commands to produce and display a simple = benchmark, as well as the example output (below). =20 I see about a 10x performance difference between the standard = seconds-to-string and the "bells and whistles" readable version. It's = still <35=C2=B5s per delay for me, so formatting thousands of strings at = once should be no problem. Happy to take performance improvement ideas. Current example: Delay (s) s2s s2s-r s2s-ra s2s-ra1 s2s-rah = s2s-e s2s-ea s2s-ea1 s2s-ea3 s2s-eah 0.000 0s 0 seconds 0s 0s 0s = 0 seconds 0s 0s 0s 0s 0.450 450.00ms 0 seconds 0s 0.4s 0.5s = 0 seconds 0s 0.4s 0.450s 0.5s 1.035 1.03s 1 second 1s 1s 1s = 1 second 1s 1s 1.035s 1s 2.380 2.38s 2 seconds 2s 2.4s 2.5s = 2 seconds 2s 2.4s 2.380s 2.5s 5.475 5.48s 5 seconds 5s 5.5s 5.5s = 5 seconds 5s 5.5s 5.475s 5.5s 12.593 12.59s 13 seconds 13s 12.6s 12.5s = 13 seconds 13s 12.6s 12.593s 12.5s 28.964 28.96s 29 seconds 29s 29s 29s = 29 seconds 29s 29s 28.964s 29s 66.616 66.62s 1 minute 1m 1.1m 1m 1 = minute 7 seconds 1m 7s 1m 6.6s 1m 6.616s 1m 6.5s 153.217 2.55m 3 minutes 3m 2.6m 2.5m 2 = minutes 33 seconds 2m 33s 2m 33.2s 2m 33.217s 2m 33s 352.399 5.87m 6 minutes 6m 5.9m 6m 5 = minutes 52 seconds 5m 52s 5m 52.4s 5m 52.399s 5m 52.5s 810.519 13.51m 14 minutes 14m 13.5m 13.5m 13 = minutes 31 seconds 13m 31s 13m 30.5s 13m 30.519s 13m 30.5s 1864.193 31.07m 31 minutes 31m 31.1m 31m 31 = minutes 4 seconds 31m 4s 31m 4.2s 31m 4.193s 31m 4s 4287.644 71.46m 1 hour 1h 1.2h 1h 1 = hour 11 minutes 1h 11m 1h 11.5m 1h 11.461m 1h 11.5m 9861.581 2.74h 3 hours 3h 2.7h 2.5h 2 = hours 44 minutes 2h 44m 2h 44.4m 2h 44.360m 2h 44.5m 22681.636 6.30h 6 hours 6h 6.3h 6.5h 6 = hours 18 minutes 6h 18m 6h 18m 6h 18.027m 6h 18m 52167.763 14.49h 14 hours 14h 14.5h 14.5h 14 = hours 29 minutes 14h 29m 14h 29.5m 14h 29.463m 14h 29.5m 119985.856 1.39d 1 day 1d 1.4d 1.5d = 1 day 9 hours 1d 9h 1d 9.3h 1d 9.329h 1d 9.5h 275967.469 3.19d 3 days 3d 3.2d 3d = 3 days 5 hours 3d 5h 3d 4.7h 3d 4.658h 3d 4.5h 634725.178 7.35d 1 week 1w 1w 1w = 1 week 1w 1w 0.3d 1w 0.346d 1w 0.5d 1459867.909 16.90d 2 weeks 2w 2.4w 2.5w = 2 weeks 3 days 2w 3d 2w 2.9d 2w 2.897d 2w 3d 3357696.192 38.86d 1 month 1M 1.3M 1.5M = 1 month 1 week 1M 1w 1M 1.2w 1M 1.204w 1M 1w 7722701.241 89.38d 3 months 3M 2.9M 3M 2 = months 4 weeks 2M 4w 2M 4.1w 2M 4.073w 2M 4w 17762212.854 205.58d 7 months 7M 6.8M 7M 6 = months 3 weeks 6M 3w 6M 3.3w 6M 3.280w 6M 3.5w 40853089.565 1.29y 1 year 1Y 1.3Y 1.5Y 1 = year 4 months 1Y 4M 1Y 3.5M 1Y 3.535M 1Y 3.5M 93962105.999 2.98y 3 years 3Y 3Y 3Y 2 = years 12 months 2Y 12M 2Y 11.7M 2Y 11.730M 2Y 11.5M 216112843.798 6.85y 7 years 7Y 6.8Y 7Y 6 = years 10 months 6Y 10M 6Y 10.2M 6Y 10.180M 6Y 10M 497059540.736 15.75y 16 years 16Y 15.8Y 16Y 15 = years 9 months 15Y 9M 15Y 9M 15Y 9.014M 15Y 9M 1143236943.694 36.23y 36 years 36Y 36.2Y 36Y 36 = years 3 months 36Y 3M 36Y 2.7M 36Y 2.733M 36Y 2.5M =EF=BF=BC=EF=BF=BC --Apple-Mail=_81DD6890-84BD-4B48-ACF9-160C3B7CA8C1 Content-Type: multipart/mixed; boundary="Apple-Mail=_D8586D9C-C13F-4E19-A681-AEC92B23B7C7" --Apple-Mail=_D8586D9C-C13F-4E19-A681-AEC92B23B7C7 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Jul 6, 2024, at 5:09=E2=80=AFPM, Paul Eggert = <eggert@cs.ucla.edu> wrote:

On 7/6/24 21:29, JD Smith = wrote:
do we universally avoid unicode in = core files?

Not in comments, but even today it's = wise to be cautious about generating user-visible Unicode characters = like "=C2=BD" when there's a simple ASCII substitute like ".5". Plus, = why stop with =C2=BD? Why not also do =C2=BC and =C2=BE?

It might = be better to have an optional precision argument, defaulting to 0, = specifying the number of digits of precision after the decimal point. Or = something like that.

Thanks = for the feedback.  Attached find an updated = patch:

- HALF is dropped.
- PRECISION = can now be specified as a whole-number of digits or a float <1.0 = (e.g. 0.5)
- NEWS and doc = entries.

Users who want =C2=BD can always use = precision=3D0.5 and edit the string after the = fact.

Another attached file includes commands = to produce and display a simple benchmark, as well as the example output = (below).  

I see about a 10x performance = difference between the standard seconds-to-string and the "bells and = whistles" readable version.  It's still <35=C2=B5s per delay for = me, so formatting thousands of strings at once should be no problem. =  Happy to take performance improvement = ideas.

Current example:

     Delay (s)        s2s =       s2s-r  s2s-ra  s2s-ra1  s2s-rah =                  s2s-e =   s2s-ea    s2s-ea1      s2s-ea3   =  s2s-eah
    =      0.000         0s   0 = seconds      0s       0s     =   0s              0 seconds =       0s         0s     =       0s         = 0s
      =    0.450   450.00ms   0 seconds     =  0s     0.4s     0.5s       =        0 seconds       0s   =     0.4s       0.450s       = 0.5s
      =    1.035      1.03s    1 second =      1s       1s       1s =               1 second     =   1s         1s       1.035s =         1s
         2.380      2.38s =   2 seconds      2s     2.4s     = 2.5s              2 seconds   =     2s       2.4s       2.380s =       2.5s
         5.475      5.48s =   5 seconds      5s     5.5s     = 5.5s              5 seconds   =     5s       5.5s       5.475s =       5.5s
        12.593     12.59s  13 = seconds     13s    12.6s    12.5s   =           13 seconds      13s =      12.6s      12.593s     =  12.5s
    =     28.964     28.96s  29 seconds     = 29s      29s      29s       =       29 seconds      29s     =    29s      28.964s       =  29s
    =     66.616     66.62s    1 minute   =    1m     1.1m       1m     = 1 minute 7 seconds    1m 7s    1m 6.6s   =  1m 6.616s    1m 6.5s
       153.217      2.55m =   3 minutes      3m     2.6m     = 2.5m   2 minutes 33 seconds   2m 33s   2m 33.2s   2m = 33.217s     2m 33s
       352.399      5.87m =   6 minutes      6m     5.9m     =   6m   5 minutes 52 seconds   5m 52s   5m 52.4s =   5m 52.399s   5m 52.5s
       810.519     13.51m  14 = minutes     14m    13.5m    13.5m  13 = minutes 31 seconds  13m 31s  13m 30.5s  13m 30.519s =  13m 30.5s
  =     1864.193     31.07m  31 minutes   =   31m    31.1m      31m   31 minutes = 4 seconds   31m 4s   31m 4.2s   31m 4.193s     = 31m 4s
      = 4287.644     71.46m      1 hour     =  1h     1.2h       1h     =  1 hour 11 minutes   1h 11m   1h 11.5m   1h 11.461m =   1h 11.5m
  =     9861.581      2.74h     3 hours =      3h     2.7h     2.5h   =   2 hours 44 minutes   2h 44m   2h 44.4m   2h = 44.360m   2h 44.5m
     22681.636      6.30h   =   6 hours      6h     6.3h     = 6.5h     6 hours 18 minutes   6h 18m     6h 18m =   6h 18.027m     6h 18m
     52167.763     14.49h =    14 hours     14h    14.5h   =  14.5h    14 hours 29 minutes  14h 29m  14h = 29.5m  14h 29.463m  14h 29.5m
    119985.856      1.39d =       1 day      1d     1.4d =     1.5d          1 day 9 hours =    1d 9h    1d 9.3h    1d 9.329h   =  1d 9.5h
    = 275967.469      3.19d      3 days   =    3d     3.2d       3d     =     3 days 5 hours    3d 5h    3d 4.7h =    3d 4.658h    3d 4.5h
    634725.178      7.35d =      1 week      1w       = 1w       1w             =     1 week       1w    1w 0.3d   =  1w 0.346d    1w 0.5d
   1459867.909     16.90d     2 = weeks      2w     2.4w     2.5w =         2 weeks 3 days    2w 3d   =  2w 2.9d    2w 2.897d      2w = 3d
   3357696.192 =     38.86d     1 month      1M   =   1.3M     1.5M         1 month 1 = week    1M 1w    1M 1.2w    1M 1.204w =      1M 1w
   7722701.241     89.38d    3 = months      3M     2.9M       3M =       2 months 4 weeks    2M 4w    2M = 4.1w    2M 4.073w      2M = 4w
  17762212.854 =    205.58d    7 months      7M   =   6.8M       7M       6 months 3 = weeks    6M 3w    6M 3.3w    6M 3.280w =    6M 3.5w
  = 40853089.565      1.29y      1 year   =    1Y     1.3Y     1.5Y     =    1 year 4 months    1Y 4M    1Y 3.5M =    1Y 3.535M    1Y 3.5M
  93962105.999      2.98y =     3 years      3Y       3Y =       3Y      2 years 12 months   2Y = 12M   2Y 11.7M   2Y 11.730M   2Y = 11.5M
 216112843.798 =      6.85y     7 years      7Y =     6.8Y       7Y      6 years = 10 months   6Y 10M   6Y 10.2M   6Y 10.180M     = 6Y 10M
 497059540.736 =     15.75y    16 years     16Y   =  15.8Y      16Y      15 years 9 = months   15Y 9M     15Y 9M   15Y 9.014M   =   15Y 9M
1143236943.694 =     36.23y    36 years     36Y   =  36.2Y      36Y      36 years 3 = months   36Y 3M   36Y 2.7M   36Y 2.733M   36Y = 2.5M

= --Apple-Mail=_D8586D9C-C13F-4E19-A681-AEC92B23B7C7 Content-Disposition: attachment; filename=s2s_test.el Content-Type: application/octet-stream; x-unix-mode=0644; name="s2s_test.el" Content-Transfer-Encoding: quoted-printable (require=20'cl-lib)=0A=0A(defun=20s2s/example=20()=0A=20=20(interactive)=0A= =20=20(with-temp-buffer-window=20"s2s/example"=20nil=20nil=0A=20=20=20=20= (princ=0A=20=20=20=20=20(concat=0A=20=20=20=20=20=20(format=20"%14s=20= %10s=20=20%10s=20=20%6s=20=20%7s=20=20%7s=20=20%21s=20=20%7s=20=20%9s=20=20= %11s=20=20%9s\n"=0A=09=20=20=20=20=20=20"Delay=20(s)"=20"s2s"=20"s2s-r"=20= "s2s-ra"=20"s2s-ra1"=20"s2s-rah"=20"s2s-e"=20"s2s-ea"=20"s2s-ea1"=0A=09=20= =20=20=20=20=20"s2s-ea3"=20"s2s-eah")=0A=20=20=20=20=20=20(cl-loop=20for=20= s=20=3D=200.0=20then=20(if=20(zerop=20s)=200.45=20(*=20s=202.3))=0A=09=20= =20=20=20=20=20=20while=20(<=20s=20(*=20365.25=2024=203600=2040))=0A=09=20= =20=20=20=20=20=20concat=20(format=20"%14.3f=20%10s=20=20%10s=20=20%6s=20= =20%7s=20=20%7s=20=20%21s=20=20%7s=20=20%9s=20=20%11s=20=20%9s\n"=20s=0A=09= =09=09=20=20=20=20=20=20(seconds-to-string=20s)=0A=09=09=09=20=20=20=20=20= =20(seconds-to-string=20s=20'readable)=0A=09=09=09=20=20=20=20=20=20= (seconds-to-string=20s=20'readable=20'abbrev)=0A=09=09=09=20=20=20=20=20=20= (seconds-to-string=20s=20'readable=20'abbrev=201)=0A=09=09=09=20=20=20=20= =20=20(seconds-to-string=20s=20'readable=20'abbrev=200.5)=0A=09=09=09=20=20= =20=20=20=20(seconds-to-string=20s=20'expanded)=0A=09=09=09=20=20=20=20=20= =20(seconds-to-string=20s=20'expanded=20'abbrev)=0A=09=09=09=20=20=20=20=20= =20(seconds-to-string=20s=20'expanded=20'abbrev=201)=0A=09=09=09=20=20=20= =20=20=20(seconds-to-string=20s=20'expanded=20'abbrev=203)=0A=09=09=09=20= =20=20=20=20=20(seconds-to-string=20s=20'expanded=20'abbrev=200.5)))))))=0A= =0A(defun=20s2s/benchmark=20()=0A=20=20(interactive)=0A=20=20(let*=20= ((ndelays=20100000)=0A=09=20(delays=20(cl-loop=20for=20i=20from=201=20to=20= ndelays=0A=09=09=09=20=20with=20max=20=3D=20(*=20365.25=2024=203600=20= 40)=0A=09=09=09=20=20collect=20(cl-random=20max)))=0A=09=20(bsmpl=20= (benchmark-run=20nil=0A=09=09=20=20(cl-loop=20for=20d=20in=20delays=0A=09= =09=09=20=20=20do=20(seconds-to-string=20d))))=0A=09=20(brdbl=20= (benchmark-run=20nil=0A=09=09=20=20(cl-loop=20for=20d=20in=20delays=0A=09= =09=09=20=20=20do=20(seconds-to-string=20d=20t=20t=200.1)))))=0A=20=20=20= =20(with-temp-buffer-window=20"s2s/benchmarks"=20nil=20nil=0A=20=20=20=20= =20=20(princ=20"seconds-to-string=20benchmarks\n")=0A=20=20=20=20=20=20= (princ=20(format=20"=20=20default=20timing:=20%0.2f=C2=B5s\n\t%S\n"=0A=09= =09=20=20=20=20=20(/=20(car=20bsmpl)=20ndelays=201e-6)=20bsmpl))=0A=20=20= =20=20=20=20(princ=20(format=20"=20readable=20timing:=20= %0.2f=C2=B5s\n\t%S\n\n"=0A=09=09=20=20=20=20=20(/=20(car=20brdbl)=20= ndelays=201e-6)=20brdbl))=0A=20=20=20=20=20=20(princ=20(format=20= "readable/default:=20%0.2f\n"=20(/=20(car=20brdbl)=20(car=20bsmpl)))))))=0A= --Apple-Mail=_D8586D9C-C13F-4E19-A681-AEC92B23B7C7 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii
--Apple-Mail=_D8586D9C-C13F-4E19-A681-AEC92B23B7C7 Content-Disposition: attachment; filename=0001-seconds-to-string-new-optional-arguments-for-readabl.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-seconds-to-string-new-optional-arguments-for-readabl.patch" Content-Transfer-Encoding: quoted-printable =46rom=204767735197fba78672e076737a033921637db1a2=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20JD=20Smith=20= <93749+jdtsmith@users.noreply.github.com>=0ADate:=20Thu,=2011=20Jul=20= 2024=2016:24:17=20-0400=0ASubject:=20[PATCH]=20seconds-to-string:=20new=20= optional=20arguments=20for=20readable=0A=20strings=0A=0A---=0A=20= doc/lispref/os.texi=20=20=20=20=20=20=20=20|=20=206=20+++=0A=20etc/NEWS=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=20=207=20++++=0A=20= lisp/calendar/time-date.el=20|=2075=20= ++++++++++++++++++++++++++++++++++++--=0A=203=20files=20changed,=2084=20= insertions(+),=204=20deletions(-)=0A=0Adiff=20--git=20= a/doc/lispref/os.texi=20b/doc/lispref/os.texi=0Aindex=20= 3ba3da459bf..1e26c83de6a=20100644=0A---=20a/doc/lispref/os.texi=0A+++=20= b/doc/lispref/os.texi=0A@@=20-2155,6=20+2155,12=20@@=20Time=20= Calculations=0A=20structure.=20=20For=20instance,=20the=20120th=20day=20= in=202004=20is=20April=2029th.=0A=20@end=20defun=0A=20=0A+@defun=20= seconds-to-string=20delay=20&optional=20readable=20abbrev=20precision=0A= +Return=20a=20string=20describing=20a=20given=20@var{delay}=20(in=20= seconds).=20=20Optional=0A+arguments=20can=20be=20used=20to=20configure=20= a=20human=20readable=20delay=20using=20various=0A+formats.=20=20For=20= example,=20a=20delay=20of=209861.5=20seconds=20with=20@var{readable}=20= set=0A+to=20the=20symbol=20@code{expanded}=20returns=20"2=20hours=2044=20= minutes".=0A+=0A=20@node=20Timers=0A=20@section=20Timers=20for=20Delayed=20= Execution=0A=20@cindex=20timers=0Adiff=20--git=20a/etc/NEWS=20b/etc/NEWS=0A= index=20f10f9ae4d65..38ab21288a3=20100644=0A---=20a/etc/NEWS=0A+++=20= b/etc/NEWS=0A@@=20-30,6=20+30,13=20@@=20applies,=20and=20please=20also=20= update=20docstrings=20as=20needed.=0A=20=0C=0A=20*=20Changes=20in=20= Emacs=2031.1=0A=20=0A+**=20Time=20&=20Date=0A+=0A++++=0A+***=20= 'seconds-to-string'=20includes=20new=20arguments=20to=20produce=20= human-readable=0A+delay=20strings=20in=20a=20variety=20of=20formats,=20= for=20example=20"6=20months=203=20weeks"=20or=0A+"5m=2052.5s".=0A+=0A=20=0C= =0A=20*=20Editing=20Changes=20in=20Emacs=2031.1=0A=20=0Adiff=20--git=20= a/lisp/calendar/time-date.el=20b/lisp/calendar/time-date.el=0Aindex=20= eca80f1e8b6..f80aa2f980d=20100644=0A---=20a/lisp/calendar/time-date.el=0A= +++=20b/lisp/calendar/time-date.el=0A@@=20-409,11=20+409,78=20@@=20= seconds-to-string=0A=20=20=20=20=20=20=20=20=20(list=20(*=203600=2024=20= 400)=20"d"=20(*=203600.0=2024.0))=0A=20=20=20=20=20=20=20=20=20(list=20= nil=20"y"=20(*=20365.25=2024=203600)))=0A=20=20=20"Formatting=20used=20= by=20the=20function=20`seconds-to-string'.")=0A+=0A+(defvar=20= seconds-to-string-readable=0A+=20=20`(("Y"=20"year"=20=20=20"years"=20=20= =20,(round=20(*=2060=2060=2024=20365.2425)))=0A+=20=20=20=20("M"=20= "month"=20=20"months"=20=20,(round=20(*=2060=2060=2024=2030.436875)))=0A= +=20=20=20=20("w"=20"week"=20=20=20"weeks"=20=20=20,(*=2060=2060=2024=20= 7))=0A+=20=20=20=20("d"=20"day"=20=20=20=20"days"=20=20=20=20,(*=2060=20= 60=2024))=0A+=20=20=20=20("h"=20"hour"=20=20=20"hours"=20=20=20,(*=2060=20= 60))=0A+=20=20=20=20("m"=20"minute"=20"minutes"=2060)=0A+=20=20=20=20= ("s"=20"second"=20"seconds"=201))=0A+=20=20"Formatting=20used=20by=20the=20= function=20`seconds-to-string'=20with=20READABLE=20set.")=0A+=0A=20= ;;;###autoload=0A-(defun=20seconds-to-string=20(delay)=0A-=20=20;;=20= FIXME:=20There's=20a=20similar=20(tho=20fancier)=20function=20in=20= mastodon.el!=0A-=20=20"Convert=20the=20time=20interval=20in=20seconds=20= to=20a=20short=20string."=0A-=20=20(cond=20((>=200=20delay)=20(concat=20= "-"=20(seconds-to-string=20(-=20delay))))=0A+(defun=20seconds-to-string=20= (delay=20&optional=20readable=20abbrev=20precision)=0A+=20=20"Convert=20= time=20interval=20DELAY=20(in=20seconds)=20to=20a=20short=20string.=0A= +By=20default,=20the=20returned=20string=20has=20two=20decimal=20= precision=20in=20the=0A+smallest=20unit=20that=20is=20larger=20than=20= DELAY=20from=20the=20variable=0A+`seconds-to-string'.=20=20If=20READABLE=20= is=20non-nil,=20convert=20DELAY=20into=0A+a=20readable=20string,=20using=20= the=20information=20in=20the=20variable=0A+`seconds-to-string-readable'.=20= =20If=20it=20is=20the=20symbol=20`expanded',=0A+use=20two=20units=20to=20= describe=20DELAY,=20if=20appropriate.=20=20E.g.=20\"1=20hour=0A+32=20= minutes\".=20=20If=20ABBREV=20is=20non-nil,=20abbreviate=20the=20= readable=0A+units.=20=20If=20PRECISION=20is=20a=20whole=20number,=20= round=20the=20value=0A+associated=20with=20the=20smallest=20displayed=20= unit=20to=20that=20many=20digits=0A+after=20the=20decimal.=20=20If=20it=20= a=20non-negative=20float=20less=20than=201.0,=0A+round=20to=20that=20= value."=0A+=20=20(cond=20((<=20delay=200)=0A+=09=20(concat=20"-"=20= (seconds-to-string=20(-=20delay)=20readable=20precision)))=0A+=20=20=20=20= =20=20=20=20(readable=0A+=20=20=20=20=20=20=20=20=20(let*=20((stsa=20= seconds-to-string-readable)=0A+=09=09(expanded=20(eq=20readable=20= 'expanded))=0A+=09=09digits=0A+=09=09(round-to=20(cond=20((wholenump=20= precision)=0A+=09=09=09=09=20(setq=20digits=20precision)=0A+=09=09=09=09=20= (expt=2010=20(-=20precision)))=0A+=09=09=09=09((and=20(floatp=20= precision)=20(<=20precision=201.))=0A+=09=09=09=09=20(setq=20digits=20(-=20= (floor=20(log=20precision=2010))))=0A+=09=09=09=09=20precision)=0A+=09=09= =09=09(t=20(setq=20digits=200)=201)))=0A+=09=09(dformat=20(if=20(>=20= digits=200)=20(format=20"%%0.%df"=20digits)))=0A+=09=09(padding=20(if=20= abbrev=20""=20"=20"))=0A+=09=09here=20cnt=20cnt-pre=20here-pre=20= cnt-val)=0A+=09=20=20=20(if=20(=3D=20(round=20delay=20round-to)=200)=0A+=09= =20=20=20=20=20=20=20(format=20"0%s"=20(if=20abbrev=20"s"=20"=20= seconds"))=0A+=09=20=20=20=20=20(while=20(and=20(setq=20here=20(pop=20= stsa))=20stsa=0A+=09=09=09=20(<=20(/=20delay=20(nth=203=20here))=201)))=0A= +=09=20=20=20=20=20(or=20(and=0A+=09=09=20=20expanded=20stsa=20=09;=20= smaller=20unit=20remains=0A+=09=09=20=20(progn=0A+=09=09=20=20=20=20= (setq=0A+=09=09=20=20=20=20=20here-pre=20here=20here=20(car=20stsa)=0A+=09= =09=20=20=20=20=20cnt-pre=20(floor=20(/=20(float=20delay)=20(nth=203=20= here-pre)))=0A+=09=09=20=20=20=20=20cnt=20(round=0A+=09=09=09=20=20(/=20= (-=20(float=20delay)=20(*=20cnt-pre=20(nth=203=20here-pre)))=0A+=09=09=09= =20=20=20=20=20(nth=203=20here))=0A+=09=09=09=20=20round-to))=0A+=09=09=20= =20=20=20(if=20(>=20cnt=200)=20t=20(setq=20cnt=20cnt-pre=20here=20= here-pre=20here-pre=20nil))))=0A+=09=09=20(setq=20cnt=20(round=20(/=20= (float=20delay)=20(nth=203=20here))=20round-to)))=0A+=09=20=20=20=20=20= (setq=20cnt-val=20(*=20cnt=20round-to))=0A+=09=20=20=20=20=20(cl-labels=0A= +=09=09=20((unit=20(val=20here)=0A+=09=09=20=20=20=20(cond=20(abbrev=20= (car=20here))=0A+=09=09=09=20=20((<=3D=20(floor=20val)=201)=20(nth=201=20= here))=0A+=09=09=09=20=20(t=20(nth=202=20here)))))=0A+=09=20=20=20=20=20=20= =20(concat=0A+=09=09(when=20here-pre=0A+=09=09=20=20(concat=20= (number-to-string=20cnt-pre)=20padding=0A+=09=09=09=20=20(unit=20(*=20= cnt-pre=20round-to)=20here-pre)=20"=20"))=0A+=09=09(if=20(and=20(>=20= digits=200)=0A+=09=09=09=20(>=20(-=20cnt-val=20(floor=20cnt-val))=200.))=0A= +=09=09=20=20=20=20(format=20dformat=20cnt-val)=0A+=09=09=20=20= (number-to-string=20(floor=20cnt-val)))=0A+=09=09padding=20(unit=20= cnt-val=20here))))))=0A=20=20=20=20=20=20=20=20=20((=3D=200=20delay)=20= "0s")=0A=20=20=20=20=20=20=20=20=20(t=20(let=20((sts=20= seconds-to-string)=20here)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (while=20(and=20(car=20(setq=20here=20(pop=20sts)))=0A--=20=0A2.43.0=0A=0A= --Apple-Mail=_D8586D9C-C13F-4E19-A681-AEC92B23B7C7 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii


--Apple-Mail=_D8586D9C-C13F-4E19-A681-AEC92B23B7C7-- --Apple-Mail=_81DD6890-84BD-4B48-ACF9-160C3B7CA8C1-- From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 30 14:00:13 2024 Received: (at 71572) by debbugs.gnu.org; 30 Nov 2024 19:00:13 +0000 Received: from localhost ([127.0.0.1]:49076 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tHShQ-0002nz-Ow for submit@debbugs.gnu.org; Sat, 30 Nov 2024 14:00:13 -0500 Received: from mail-il1-f172.google.com ([209.85.166.172]:48459) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tHShO-0002hq-He for 71572@debbugs.gnu.org; Sat, 30 Nov 2024 14:00:11 -0500 Received: by mail-il1-f172.google.com with SMTP id e9e14a558f8ab-3a78c242d50so10374945ab.1 for <71572@debbugs.gnu.org>; Sat, 30 Nov 2024 11:00:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732993144; x=1733597944; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=Zup4CtLLac8guPL1CNFIhnRg7f7OQcUg0RXx8Wiq8Lo=; b=aQpHNKD59b/tpJ7ULJRo7rE1Sqlzi0dhjWQTwWT37Z2ojh41VvKvUMRzfQQipW4rtI bUK0FGP2tgDJjesM99j3sPxuTro21VEKUoQkigJPi0SQfDgjBprrW5wLpCEQyfQo4Uc4 gmViDwx9QdPiAoJKoJM7vCSf/opo4kc+++tuF6R7OyY8NoQ83oakQGnbI0E2Mx1ByJw3 7alrCtgyvl3xbB0TilMftGOfM5tmWCUVjKcexKEjw3LYHl5fKjuBmpoeSLw3IHEO0Nly AL1mG3UPpFd32gxdWvIu8ewN2nfZUqsXn4JE6Q/tteY09fn5v2TsdsTr3z5ghX2WA5kC tOfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732993144; x=1733597944; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Zup4CtLLac8guPL1CNFIhnRg7f7OQcUg0RXx8Wiq8Lo=; b=nDGz/PtM7yRYo1Y/zAYYHUlUsuequSDJkdIvnJ/BL4NoY2OAiUzcL2RaRSa1oC9bj1 ioWH//SsiDYTowpVzu3GoW0VawqQ+SFiGSf1IqdKP2ZGE6PKB1vHpqG+WdkypYrx8oYL G8hadYypmGHsA4LIlkJeBqyNC4V3gDBA/In0aPvOxJQkCHODTqMiL9r8aYT6TKb61sTA 6k5/few1uc1x0njfsW8wZ1ikicieYon9jBM/7uape+q/tE0k5tC/Co9tfZbtok92OOUU gqDMsEUSgbnMrkj0CHudXzBxMoK6IKN58m31Tft4JaZWn1pvi8Y0rjzGMuO2Mch5PHRb qBLw== X-Gm-Message-State: AOJu0Yzki/TyyCRXN1GwCfjzxe+ZZbKc9dJNnjvcCrQXJeCMGV5eW+p8 kvPAv6GnNAsvlDhZfh8Nfd1MibK/35noRsPafkPqTuEH7NKeiqbVyRuLGw== X-Gm-Gg: ASbGncsBozaNDmN4m69kWv34z05p0q3f8bOyWZdgcW8KIEfFjrtIIZiLXsdKvjDyuc8 qI9BUQB+CkyBvOExqM/Ny0n4lB+CURwtS6l11o2jCh/nJjYhqgoPdZuFq7Vh0vI6nDlFhN55U+8 LzdjJB1E1X26Au14E+XLrCuHPhbr6uiahiILDpOgh31utATue7cP5rMZSzyFJK1xvRHK8lnKFDA CR7tW2Rw3t9Gkau3X17VR8Ngoa99FxWbPcSuaUX5tYd9maRiWv73TZbmyWORJtaMPFcQqVgkBat edBsfZaaaIqHnS9H0jmCXA== X-Google-Smtp-Source: AGHT+IG6cM9u8tcTNYJsPNMdpziKfQdoWVJnFZYyBRyIc61/ke2WicMMNNsIeStqPqDKYdbHWH6rlg== X-Received: by 2002:a05:6e02:2144:b0:3a7:7124:bd2c with SMTP id e9e14a558f8ab-3a7c55d9bddmr191814635ab.19.1732993144446; Sat, 30 Nov 2024 10:59:04 -0800 (PST) Received: from smtpclient.apple (cm-24-53-185-196.buckeyecom.net. [24.53.185.196]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a7dfa49fbbsm7090265ab.21.2024.11.30.10.59.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Nov 2024 10:59:03 -0800 (PST) From: JD Smith Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_F139D8F7-18E6-4A7B-9A53-E9A903252D7F" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate Date: Sat, 30 Nov 2024 13:58:52 -0500 In-Reply-To: <8CC4B1BB-B56A-4C3E-8B51-0E2D5B65C296@gmail.com> To: 71572@debbugs.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> X-Mailer: Apple Mail (2.3774.600.62) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 71572 Cc: Adam Porter , Eli Zaretskii , jonas@bernoul.li, Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Apple-Mail=_F139D8F7-18E6-4A7B-9A53-E9A903252D7F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 I was recently reminded of the need for a more capable = seconds-to-string. =20 Anyone have any additional comments on this proposed patch? If not, I'd = suggest someone with access merges. JD > On Jul 11, 2024, at 5:01=E2=80=AFPM, JD Smith = wrote: >=20 >=20 >=20 >> On Jul 6, 2024, at 5:09=E2=80=AFPM, Paul Eggert = wrote: >>=20 >> On 7/6/24 21:29, JD Smith wrote: >>> do we universally avoid unicode in core files? >>=20 >> Not in comments, but even today it's wise to be cautious about = generating user-visible Unicode characters like "=C2=BD" when there's a = simple ASCII substitute like ".5". Plus, why stop with =C2=BD? Why not = also do =C2=BC and =C2=BE? >>=20 >> It might be better to have an optional precision argument, defaulting = to 0, specifying the number of digits of precision after the decimal = point. Or something like that. >=20 > Thanks for the feedback. Attached find an updated patch: >=20 > - HALF is dropped. > - PRECISION can now be specified as a whole-number of digits or a = float <1.0 (e.g. 0.5) > - NEWS and doc entries. >=20 > Users who want =C2=BD can always use precision=3D0.5 and edit the = string after the fact. >=20 > Another attached file includes commands to produce and display a = simple benchmark, as well as the example output (below). =20 >=20 > I see about a 10x performance difference between the standard = seconds-to-string and the "bells and whistles" readable version. It's = still <35=C2=B5s per delay for me, so formatting thousands of strings at = once should be no problem. Happy to take performance improvement ideas. >=20 > Current example: >=20 > Delay (s) s2s s2s-r s2s-ra s2s-ra1 s2s-rah = s2s-e s2s-ea s2s-ea1 s2s-ea3 s2s-eah > 0.000 0s 0 seconds 0s 0s 0s = 0 seconds 0s 0s 0s 0s > 0.450 450.00ms 0 seconds 0s 0.4s 0.5s = 0 seconds 0s 0.4s 0.450s 0.5s > 1.035 1.03s 1 second 1s 1s 1s = 1 second 1s 1s 1.035s 1s > 2.380 2.38s 2 seconds 2s 2.4s 2.5s = 2 seconds 2s 2.4s 2.380s 2.5s > 5.475 5.48s 5 seconds 5s 5.5s 5.5s = 5 seconds 5s 5.5s 5.475s 5.5s > 12.593 12.59s 13 seconds 13s 12.6s 12.5s = 13 seconds 13s 12.6s 12.593s 12.5s > 28.964 28.96s 29 seconds 29s 29s 29s = 29 seconds 29s 29s 28.964s 29s > 66.616 66.62s 1 minute 1m 1.1m 1m 1 = minute 7 seconds 1m 7s 1m 6.6s 1m 6.616s 1m 6.5s > 153.217 2.55m 3 minutes 3m 2.6m 2.5m 2 = minutes 33 seconds 2m 33s 2m 33.2s 2m 33.217s 2m 33s > 352.399 5.87m 6 minutes 6m 5.9m 6m 5 = minutes 52 seconds 5m 52s 5m 52.4s 5m 52.399s 5m 52.5s > 810.519 13.51m 14 minutes 14m 13.5m 13.5m 13 = minutes 31 seconds 13m 31s 13m 30.5s 13m 30.519s 13m 30.5s > 1864.193 31.07m 31 minutes 31m 31.1m 31m 31 = minutes 4 seconds 31m 4s 31m 4.2s 31m 4.193s 31m 4s > 4287.644 71.46m 1 hour 1h 1.2h 1h 1 = hour 11 minutes 1h 11m 1h 11.5m 1h 11.461m 1h 11.5m > 9861.581 2.74h 3 hours 3h 2.7h 2.5h 2 = hours 44 minutes 2h 44m 2h 44.4m 2h 44.360m 2h 44.5m > 22681.636 6.30h 6 hours 6h 6.3h 6.5h 6 = hours 18 minutes 6h 18m 6h 18m 6h 18.027m 6h 18m > 52167.763 14.49h 14 hours 14h 14.5h 14.5h 14 = hours 29 minutes 14h 29m 14h 29.5m 14h 29.463m 14h 29.5m > 119985.856 1.39d 1 day 1d 1.4d 1.5d = 1 day 9 hours 1d 9h 1d 9.3h 1d 9.329h 1d 9.5h > 275967.469 3.19d 3 days 3d 3.2d 3d = 3 days 5 hours 3d 5h 3d 4.7h 3d 4.658h 3d 4.5h > 634725.178 7.35d 1 week 1w 1w 1w = 1 week 1w 1w 0.3d 1w 0.346d 1w 0.5d > 1459867.909 16.90d 2 weeks 2w 2.4w 2.5w = 2 weeks 3 days 2w 3d 2w 2.9d 2w 2.897d 2w 3d > 3357696.192 38.86d 1 month 1M 1.3M 1.5M = 1 month 1 week 1M 1w 1M 1.2w 1M 1.204w 1M 1w > 7722701.241 89.38d 3 months 3M 2.9M 3M = 2 months 4 weeks 2M 4w 2M 4.1w 2M 4.073w 2M 4w > 17762212.854 205.58d 7 months 7M 6.8M 7M = 6 months 3 weeks 6M 3w 6M 3.3w 6M 3.280w 6M 3.5w > 40853089.565 1.29y 1 year 1Y 1.3Y 1.5Y = 1 year 4 months 1Y 4M 1Y 3.5M 1Y 3.535M 1Y 3.5M > 93962105.999 2.98y 3 years 3Y 3Y 3Y 2 = years 12 months 2Y 12M 2Y 11.7M 2Y 11.730M 2Y 11.5M > 216112843.798 6.85y 7 years 7Y 6.8Y 7Y 6 = years 10 months 6Y 10M 6Y 10.2M 6Y 10.180M 6Y 10M > 497059540.736 15.75y 16 years 16Y 15.8Y 16Y = 15 years 9 months 15Y 9M 15Y 9M 15Y 9.014M 15Y 9M > 1143236943.694 36.23y 36 years 36Y 36.2Y 36Y = 36 years 3 months 36Y 3M 36Y 2.7M 36Y 2.733M 36Y 2.5M >=20 > > <0001-seconds-to-string-new-optional-arguments-for-readabl.patch> >=20 >=20 --Apple-Mail=_F139D8F7-18E6-4A7B-9A53-E9A903252D7F Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 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.

JD

On Jul 11, 2024, at 5:01=E2=80=AFPM, JD Smith = <jdtsmith@gmail.com> wrote:



On Jul 6, 2024, at 5:09=E2=80=AFPM, Paul Eggert = <eggert@cs.ucla.edu> wrote:

On 7/6/24 21:29, JD Smith = wrote:
do we universally avoid unicode in = core files?

Not in comments, but even today it's = wise to be cautious about generating user-visible Unicode characters = like "=C2=BD" when there's a simple ASCII substitute like ".5". Plus, = why stop with =C2=BD? Why not also do =C2=BC and =C2=BE?

It might = be better to have an optional precision argument, defaulting to 0, = specifying the number of digits of precision after the decimal point. Or = something like that.

Thanks = for the feedback.  Attached find an updated = patch:

- HALF is dropped.
- PRECISION = can now be specified as a whole-number of digits or a float <1.0 = (e.g. 0.5)
- NEWS and doc = entries.

Users who want =C2=BD can always use = precision=3D0.5 and edit the string after the = fact.

Another attached file includes commands = to produce and display a simple benchmark, as well as the example output = (below).  

I see about a 10x performance = difference between the standard seconds-to-string and the "bells and = whistles" readable version.  It's still <35=C2=B5s per delay for = me, so formatting thousands of strings at once should be no problem. =  Happy to take performance improvement = ideas.

Current example:

     Delay (s)        s2s =       s2s-r  s2s-ra  s2s-ra1  s2s-rah =                  s2s-e =   s2s-ea    s2s-ea1      s2s-ea3   =  s2s-eah
    =      0.000         0s   0 = seconds      0s       0s     =   0s              0 seconds =       0s         0s     =       0s         = 0s
      =    0.450   450.00ms   0 seconds     =  0s     0.4s     0.5s       =        0 seconds       0s   =     0.4s       0.450s       = 0.5s
      =    1.035      1.03s    1 second =      1s       1s       1s =               1 second     =   1s         1s       1.035s =         1s
         2.380      2.38s =   2 seconds      2s     2.4s     = 2.5s              2 seconds   =     2s       2.4s       2.380s =       2.5s
         5.475      5.48s =   5 seconds      5s     5.5s     = 5.5s              5 seconds   =     5s       5.5s       5.475s =       5.5s
        12.593     12.59s  13 = seconds     13s    12.6s    12.5s   =           13 seconds      13s =      12.6s      12.593s     =  12.5s
    =     28.964     28.96s  29 seconds     = 29s      29s      29s       =       29 seconds      29s     =    29s      28.964s       =  29s
    =     66.616     66.62s    1 minute   =    1m     1.1m       1m     = 1 minute 7 seconds    1m 7s    1m 6.6s   =  1m 6.616s    1m 6.5s
       153.217      2.55m =   3 minutes      3m     2.6m     = 2.5m   2 minutes 33 seconds   2m 33s   2m 33.2s   2m = 33.217s     2m 33s
       352.399      5.87m =   6 minutes      6m     5.9m     =   6m   5 minutes 52 seconds   5m 52s   5m 52.4s =   5m 52.399s   5m 52.5s
       810.519     13.51m  14 = minutes     14m    13.5m    13.5m  13 = minutes 31 seconds  13m 31s  13m 30.5s  13m 30.519s =  13m 30.5s
  =     1864.193     31.07m  31 minutes   =   31m    31.1m      31m   31 minutes = 4 seconds   31m 4s   31m 4.2s   31m 4.193s     = 31m 4s
      = 4287.644     71.46m      1 hour     =  1h     1.2h       1h     =  1 hour 11 minutes   1h 11m   1h 11.5m   1h 11.461m =   1h 11.5m
  =     9861.581      2.74h     3 hours =      3h     2.7h     2.5h   =   2 hours 44 minutes   2h 44m   2h 44.4m   2h = 44.360m   2h 44.5m
     22681.636      6.30h   =   6 hours      6h     6.3h     = 6.5h     6 hours 18 minutes   6h 18m     6h 18m =   6h 18.027m     6h 18m
     52167.763     14.49h =    14 hours     14h    14.5h   =  14.5h    14 hours 29 minutes  14h 29m  14h = 29.5m  14h 29.463m  14h 29.5m
    119985.856      1.39d =       1 day      1d     1.4d =     1.5d          1 day 9 hours =    1d 9h    1d 9.3h    1d 9.329h   =  1d 9.5h
    = 275967.469      3.19d      3 days   =    3d     3.2d       3d     =     3 days 5 hours    3d 5h    3d 4.7h =    3d 4.658h    3d 4.5h
    634725.178      7.35d =      1 week      1w       = 1w       1w             =     1 week       1w    1w 0.3d   =  1w 0.346d    1w 0.5d
   1459867.909     16.90d     2 = weeks      2w     2.4w     2.5w =         2 weeks 3 days    2w 3d   =  2w 2.9d    2w 2.897d      2w = 3d
   3357696.192 =     38.86d     1 month      1M   =   1.3M     1.5M         1 month 1 = week    1M 1w    1M 1.2w    1M 1.204w =      1M 1w
   7722701.241     89.38d    3 = months      3M     2.9M       3M =       2 months 4 weeks    2M 4w    2M = 4.1w    2M 4.073w      2M = 4w
  17762212.854 =    205.58d    7 months      7M   =   6.8M       7M       6 months 3 = weeks    6M 3w    6M 3.3w    6M 3.280w =    6M 3.5w
  = 40853089.565      1.29y      1 year   =    1Y     1.3Y     1.5Y     =    1 year 4 months    1Y 4M    1Y 3.5M =    1Y 3.535M    1Y 3.5M
  93962105.999      2.98y =     3 years      3Y       3Y =       3Y      2 years 12 months   2Y = 12M   2Y 11.7M   2Y 11.730M   2Y = 11.5M
 216112843.798 =      6.85y     7 years      7Y =     6.8Y       7Y      6 years = 10 months   6Y 10M   6Y 10.2M   6Y 10.180M     = 6Y 10M
 497059540.736 =     15.75y    16 years     16Y   =  15.8Y      16Y      15 years 9 = months   15Y 9M     15Y 9M   15Y 9.014M   =   15Y 9M
1143236943.694 =     36.23y    36 years     36Y   =  36.2Y      36Y      36 years 3 = months   36Y 3M   36Y 2.7M   36Y 2.733M   36Y = 2.5M

<s2s_test.el>=
<0001-seconds-to-string= -new-optional-arguments-for-readabl.patch>



= --Apple-Mail=_F139D8F7-18E6-4A7B-9A53-E9A903252D7F-- From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 07 08:02:33 2024 Received: (at 71572) by debbugs.gnu.org; 7 Dec 2024 13:02:34 +0000 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 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 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==; Date: Sat, 07 Dec 2024 15:02:15 +0200 Message-Id: <86jzcbir3c.fsf@gnu.org> From: Eli Zaretskii To: JD Smith In-Reply-To: (message from JD Smith on Sat, 30 Nov 2024 13:58:52 -0500) Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> <3530cd89-b5a2-4b25-95bf-1896c8ee4aef@cs.ucla.edu> <8CC4B1BB-B56A-4C3E-8B51-0E2D5B65C296@gmail.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 71572 Cc: adam@alphapapa.net, 71572@debbugs.gnu.org, jonas@bernoul.li, eggert@cs.ucla.edu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > 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. From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 07 12:53:18 2024 Received: (at 71572) by debbugs.gnu.org; 7 Dec 2024 17:53:18 +0000 Received: from localhost ([127.0.0.1]:48424 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJyzW-000254-0x for submit@debbugs.gnu.org; Sat, 07 Dec 2024 12:53:18 -0500 Received: from mail-il1-f179.google.com ([209.85.166.179]:47482) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tJyzS-00024t-F3 for 71572@debbugs.gnu.org; Sat, 07 Dec 2024 12:53:16 -0500 Received: by mail-il1-f179.google.com with SMTP id e9e14a558f8ab-3a816cc9483so11568255ab.3 for <71572@debbugs.gnu.org>; Sat, 07 Dec 2024 09:53:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733593934; x=1734198734; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=9OKXykMuNW3FsRwAJljdhhoTXghqbmXZiyIKzq54xEc=; b=dg3l8oJHNjWU5vuuX+l98+W0Yh+OvIZnMM+IiJi9Pf3op97L1HwiqG3oU7q1PzHmAS jNApCO+QJ0nufcYFzX7sOYt9k4t89PLNIyj3XMCYP5rT5jgwR9vVgf2jVvHSNRQCJ6dn f1k2jSKhOkb8X4yw6pdcAnb1A/SFxA69iz2LpEEkllSj4rwghZmbozhiVuqq74qA1rOK IkG25Z4l7P8MpucFcz3Py3z6GyBev5XWybLNcMzKWFI7icSbnLhZUIzKvt+ItuRFyE8m XyMHHsqm9gOQ5EYDHoKdX74arMYEJKSy2w4HTBGuFcGtsHYP/F9wWctbjzlNTqHIfRq1 LL0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733593934; x=1734198734; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9OKXykMuNW3FsRwAJljdhhoTXghqbmXZiyIKzq54xEc=; b=YgDy/bssxUqveMe993gX408JjMAAnelOet7npgs1zoDduo9lXvZO3PuK8BGcJn5sJT zE1z9aqOR+NGtwvBp+8xNxUdulsxe8aNa+NhoK38TmQ+TOoVKzrqehEGjKZiXYv0KYFn ngqk/ulyeQbptfivk/Zmw34yad8MRRCkl9u+LHUwq9LQEwcvzkURpftIU0GRN3eMKrpY f76DXn6GXMyjbg+7gjzx+yXdkKfZ3WCEGjDVd527dc2QKUurwjSMmGMA1e8rGTp8zN8c NlQdpvDv0EPZ+J1HVmEVzvt9Cbsss8GOAIv4oWiQJ0taRce2x4WY2CbKcgVlbuPpS5WA tQVQ== X-Gm-Message-State: AOJu0YzGurzdfcKqlhZpqePI/46EhRImEYhA7U9JOo31CSI+Wsv68B3Z 4KW5FFjkb72s6NaEaMvRtIUbhExn5+EJRbEftn1+PI++9PTNDrn1w7HCzA== X-Gm-Gg: ASbGncslzC+VIuAMEgRGVlGjKFRFgzhzV4b7SbTLZWf4mQaFaE4iRsKcxwgbjlJ8Fxn anc2atam7fEQe7jiGhaClf6eNud0PLNMBpNHP8+NWn6inVlZNUhD7TrDk0UGxRTsCLsa4Lk9w81 PDI9ea9H+BlMrntT51DXpStTdji/W4iFBMqQCH/o2LwZTKjHujRW1Zxx+0LYFbDtMenREsaLAoX jjndvMFXpw9XdC5AWjxDx5+AXx1V3FoUYBk8HLPTpdYI2NNyBz53GGXNa8VaBdRxg== X-Google-Smtp-Source: AGHT+IGP/L8fZivdBEix+8TW34neJUrHuKc/ibhfO9368cUF15FTE7r42vY6cTE9eoXmhM912sVWWw== X-Received: by 2002:a05:6e02:190a:b0:3a7:7ee3:108d with SMTP id e9e14a558f8ab-3a811e4a952mr84644705ab.23.1733593933750; Sat, 07 Dec 2024 09:52:13 -0800 (PST) Received: from smtpclient.apple ([12.1.245.2]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a817b273e3sm8655945ab.62.2024.12.07.09.52.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Dec 2024 09:52:12 -0800 (PST) From: JD Smith Message-Id: Content-Type: multipart/mixed; boundary="Apple-Mail=_E2DDFD1A-DDF1-4FCA-B0A4-9BD9B03E4C0E" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate Date: Sat, 7 Dec 2024 12:52:01 -0500 In-Reply-To: <86jzcbir3c.fsf@gnu.org> To: Eli Zaretskii References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> <3530cd89-b5a2-4b25-95bf-1896c8ee4aef@cs.ucla.edu> <8CC4B1BB-B56A-4C3E-8B51-0E2D5B65C296@gmail.com> <86jzcbir3c.fsf@gnu.org> X-Mailer: Apple Mail (2.3774.600.62) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 71572 Cc: Adam Porter , 71572@debbugs.gnu.org, Jonas Bernoulli , Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Apple-Mail=_E2DDFD1A-DDF1-4FCA-B0A4-9BD9B03E4C0E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Dec 7, 2024, at 8:02=E2=80=AFAM, Eli Zaretskii = wrote: >=20 >> From: JD Smith >> Date: Sat, 30 Nov 2024 13:58:52 -0500 >> Cc: Eli Zaretskii , >> Adam Porter , >> jonas@bernoul.li, >> Paul Eggert >>=20 >> I was recently reminded of the need for a more capable = seconds-to-string. =20 >>=20 >> Anyone have any additional comments on this proposed patch? If not, = I'd suggest someone with access >> merges. >=20 > A few minor nits below, and then we can install: Thanks. Updated patch below. --Apple-Mail=_E2DDFD1A-DDF1-4FCA-B0A4-9BD9B03E4C0E Content-Disposition: attachment; filename=0001-seconds-to-string-new-optional-arguments-for-readabl.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-seconds-to-string-new-optional-arguments-for-readabl.patch" Content-Transfer-Encoding: quoted-printable =46rom=2099f52d767e67d5ce929a2696749b3db635bd302d=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20JD=20Smith=20= <93749+jdtsmith@users.noreply.github.com>=0ADate:=20Thu,=2011=20Jul=20= 2024=2016:24:17=20-0400=0ASubject:=20[PATCH]=20seconds-to-string:=20new=20= optional=20arguments=20for=20readable=0A=20strings=0A=0A---=0A=20= doc/lispref/os.texi=20=20=20=20=20=20=20=20|=20=206=20+++=0A=20etc/NEWS=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=20=207=20++++=0A=20= lisp/calendar/time-date.el=20|=2081=20= ++++++++++++++++++++++++++++++++++++--=0A=203=20files=20changed,=2090=20= insertions(+),=204=20deletions(-)=0A=0Adiff=20--git=20= a/doc/lispref/os.texi=20b/doc/lispref/os.texi=0Aindex=20= 3ba3da459bf..ac9d5acdf3d=20100644=0A---=20a/doc/lispref/os.texi=0A+++=20= b/doc/lispref/os.texi=0A@@=20-2155,6=20+2155,12=20@@=20Time=20= Calculations=0A=20structure.=20=20For=20instance,=20the=20120th=20day=20= in=202004=20is=20April=2029th.=0A=20@end=20defun=0A=20=0A+@defun=20= seconds-to-string=20delay=20&optional=20readable=20abbrev=20precision=0A= +Return=20a=20string=20describing=20a=20given=20@var{delay}=20(in=20= seconds).=20=20Optional=0A+arguments=20can=20be=20used=20to=20configure=20= a=20human=20readable=20delay=20using=20various=0A+formats.=20=20For=20= example,=20a=20delay=20of=209861.5=20seconds=20with=20@var{readable}=20= set=0A+to=20the=20symbol=20@code{expanded}=20returns=20@samp{2=20hours=20= 44=20minutes}.=0A+=0A=20@node=20Timers=0A=20@section=20Timers=20for=20= Delayed=20Execution=0A=20@cindex=20timers=0Adiff=20--git=20a/etc/NEWS=20= b/etc/NEWS=0Aindex=20f10f9ae4d65..1fd2a9404bb=20100644=0A---=20= a/etc/NEWS=0A+++=20b/etc/NEWS=0A@@=20-30,6=20+30,13=20@@=20applies,=20= and=20please=20also=20update=20docstrings=20as=20needed.=0A=20=0C=0A=20*=20= Changes=20in=20Emacs=2031.1=0A=20=0A+**=20Time=20&=20Date=0A+=0A++++=0A= +***=20'seconds-to-string'=20includes=20new=20formatting=20options.=0A= +Options=20are=20provided=20to=20produce=20human-readable=20delay=20= strings=20in=20a=0A+variety=20of=20formats,=20for=20example=20"6=20= months=203=20weeks"=20or=20"5m=2052.5s".=0A+=0A=20=0C=0A=20*=20Editing=20= Changes=20in=20Emacs=2031.1=0A=20=0Adiff=20--git=20= a/lisp/calendar/time-date.el=20b/lisp/calendar/time-date.el=0Aindex=20= eca80f1e8b6..60573f814ac=20100644=0A---=20a/lisp/calendar/time-date.el=0A= +++=20b/lisp/calendar/time-date.el=0A@@=20-409,11=20+409,84=20@@=20= seconds-to-string=0A=20=20=20=20=20=20=20=20=20(list=20(*=203600=2024=20= 400)=20"d"=20(*=203600.0=2024.0))=0A=20=20=20=20=20=20=20=20=20(list=20= nil=20"y"=20(*=20365.25=2024=203600)))=0A=20=20=20"Formatting=20used=20= by=20the=20function=20`seconds-to-string'.")=0A+=0A+(defvar=20= seconds-to-string-readable=0A+=20=20`(("Y"=20"year"=20=20=20"years"=20=20= =20,(round=20(*=2060=2060=2024=20365.2425)))=0A+=20=20=20=20("M"=20= "month"=20=20"months"=20=20,(round=20(*=2060=2060=2024=2030.436875)))=0A= +=20=20=20=20("w"=20"week"=20=20=20"weeks"=20=20=20,(*=2060=2060=2024=20= 7))=0A+=20=20=20=20("d"=20"day"=20=20=20=20"days"=20=20=20=20,(*=2060=20= 60=2024))=0A+=20=20=20=20("h"=20"hour"=20=20=20"hours"=20=20=20,(*=2060=20= 60))=0A+=20=20=20=20("m"=20"minute"=20"minutes"=2060)=0A+=20=20=20=20= ("s"=20"second"=20"seconds"=201))=0A+=20=20"Formatting=20used=20by=20the=20= function=20`seconds-to-string'=20with=20READABLE=20set.=0A+The=20format=20= is=20an=20alist,=20with=20string=20keys=20ABBREV-UNIT,=20and=20elements=20= like:=0A+=0A+=20=20(ABBREV-UNIT=20UNIT=20UNIT-PLURAL=20SECS)=0A+=0A= +where=20UNIT=20is=20a=20unit=20of=20time,=20ABBREV-UNIT=20is=20the=20= abreviated=20form=20of=0A+UNIT,=20UNIT-PLURAL=20is=20the=20plural=20form=20= of=20UNIT,=20and=20SECS=20is=20the=20number=20of=0A+seconds=20per=20= UNIT.")=0A+=0A=20;;;###autoload=0A-(defun=20seconds-to-string=20(delay)=0A= -=20=20;;=20FIXME:=20There's=20a=20similar=20(tho=20fancier)=20function=20= in=20mastodon.el!=0A-=20=20"Convert=20the=20time=20interval=20in=20= seconds=20to=20a=20short=20string."=0A-=20=20(cond=20((>=200=20delay)=20= (concat=20"-"=20(seconds-to-string=20(-=20delay))))=0A+(defun=20= seconds-to-string=20(delay=20&optional=20readable=20abbrev=20precision)=0A= +=20=20"Convert=20time=20interval=20DELAY=20(in=20seconds)=20to=20a=20= string.=0A+By=20default,=20the=20returned=20string=20is=20formatted=20as=20= a=20float=20in=20the=20smallest=0A+unit=20from=20the=20variable=20= `seconds-to-string'=20that=20is=20longer=20than=20DELAY,=0A+and=20a=20= precision=20of=20two.=20=20If=20READABLE=20is=20non-nil,=20convert=20= DELAY=20into=20a=0A+readable=20string,=20using=20the=20information=20= provided=20in=20the=20variable=0A+`seconds-to-string-readable'.=20=20If=20= it=20is=20the=20symbol=20`expanded',=20use=20two=0A+units=20to=20= describe=20DELAY,=20if=20appropriate.=20=20E.g.=20\"1=20hour=2032=20= minutes\".=0A+If=20ABBREV=20is=20non-nil,=20abbreviate=20the=20readable=20= units.=20=20If=20PRECISION=20is=20a=0A+whole=20number,=20round=20the=20= value=20associated=20with=20the=20smallest=20displayed=0A+unit=20to=20= that=20many=20digits=20after=20the=20decimal.=20=20If=20it=20a=20= non-negative=20float=0A+less=20than=201.0,=20round=20to=20that=20value."=0A= +=20=20(cond=20((<=20delay=200)=0A+=09=20(concat=20"-"=20= (seconds-to-string=20(-=20delay)=20readable=20precision)))=0A+=20=20=20=20= =20=20=20=20(readable=0A+=20=20=20=20=20=20=20=20=20(let*=20((stsa=20= seconds-to-string-readable)=0A+=09=09(expanded=20(eq=20readable=20= 'expanded))=0A+=09=09digits=0A+=09=09(round-to=20(cond=20((wholenump=20= precision)=0A+=09=09=09=09=20(setq=20digits=20precision)=0A+=09=09=09=09=20= (expt=2010=20(-=20precision)))=0A+=09=09=09=09((and=20(floatp=20= precision)=20(<=20precision=201.))=0A+=09=09=09=09=20(setq=20digits=20(-=20= (floor=20(log=20precision=2010))))=0A+=09=09=09=09=20precision)=0A+=09=09= =09=09(t=20(setq=20digits=200)=201)))=0A+=09=09(dformat=20(if=20(>=20= digits=200)=20(format=20"%%0.%df"=20digits)))=0A+=09=09(padding=20(if=20= abbrev=20""=20"=20"))=0A+=09=09here=20cnt=20cnt-pre=20here-pre=20= cnt-val)=0A+=09=20=20=20(if=20(=3D=20(round=20delay=20round-to)=200)=0A+=09= =20=20=20=20=20=20=20(format=20"0%s"=20(if=20abbrev=20"s"=20"=20= seconds"))=0A+=09=20=20=20=20=20(while=20(and=20(setq=20here=20(pop=20= stsa))=20stsa=0A+=09=09=09=20(<=20(/=20delay=20(nth=203=20here))=201)))=0A= +=09=20=20=20=20=20(or=20(and=0A+=09=09=20=20expanded=20stsa=20=09;=20= smaller=20unit=20remains=0A+=09=09=20=20(progn=0A+=09=09=20=20=20=20= (setq=0A+=09=09=20=20=20=20=20here-pre=20here=20here=20(car=20stsa)=0A+=09= =09=20=20=20=20=20cnt-pre=20(floor=20(/=20(float=20delay)=20(nth=203=20= here-pre)))=0A+=09=09=20=20=20=20=20cnt=20(round=0A+=09=09=09=20=20(/=20= (-=20(float=20delay)=20(*=20cnt-pre=20(nth=203=20here-pre)))=0A+=09=09=09= =20=20=20=20=20(nth=203=20here))=0A+=09=09=09=20=20round-to))=0A+=09=09=20= =20=20=20(if=20(>=20cnt=200)=20t=20(setq=20cnt=20cnt-pre=20here=20= here-pre=20here-pre=20nil))))=0A+=09=09=20(setq=20cnt=20(round=20(/=20= (float=20delay)=20(nth=203=20here))=20round-to)))=0A+=09=20=20=20=20=20= (setq=20cnt-val=20(*=20cnt=20round-to))=0A+=09=20=20=20=20=20(cl-labels=0A= +=09=09=20((unit=20(val=20here)=0A+=09=09=20=20=20=20(cond=20(abbrev=20= (car=20here))=0A+=09=09=09=20=20((<=3D=20(floor=20val)=201)=20(nth=201=20= here))=0A+=09=09=09=20=20(t=20(nth=202=20here)))))=0A+=09=20=20=20=20=20=20= =20(concat=0A+=09=09(when=20here-pre=0A+=09=09=20=20(concat=20= (number-to-string=20cnt-pre)=20padding=0A+=09=09=09=20=20(unit=20(*=20= cnt-pre=20round-to)=20here-pre)=20"=20"))=0A+=09=09(if=20(and=20(>=20= digits=200)=0A+=09=09=09=20(>=20(-=20cnt-val=20(floor=20cnt-val))=200.))=0A= +=09=09=20=20=20=20(format=20dformat=20cnt-val)=0A+=09=09=20=20= (number-to-string=20(floor=20cnt-val)))=0A+=09=09padding=20(unit=20= cnt-val=20here))))))=0A=20=20=20=20=20=20=20=20=20((=3D=200=20delay)=20= "0s")=0A=20=20=20=20=20=20=20=20=20(t=20(let=20((sts=20= seconds-to-string)=20here)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (while=20(and=20(car=20(setq=20here=20(pop=20sts)))=0A--=20=0A2.45.2=0A=0A= --Apple-Mail=_E2DDFD1A-DDF1-4FCA-B0A4-9BD9B03E4C0E-- From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 07 14:18:09 2024 Received: (at 71572) by debbugs.gnu.org; 7 Dec 2024 19:18:09 +0000 Received: from localhost ([127.0.0.1]:48551 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tK0Jd-0006Dj-1l for submit@debbugs.gnu.org; Sat, 07 Dec 2024 14:18:09 -0500 Received: from fhigh-b4-smtp.messagingengine.com ([202.12.124.155]:44453) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tK0Ja-0006DD-1t for 71572@debbugs.gnu.org; Sat, 07 Dec 2024 14:18:07 -0500 Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfhigh.stl.internal (Postfix) with ESMTP id 19A5C2540171; Sat, 7 Dec 2024 14:18:00 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Sat, 07 Dec 2024 14:18:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pub.pink; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1733599079; x=1733685479; bh=GZwYRol97grL0PQDPhskpIcdlGKP1Z4QTNfMm6IoB2o=; b= K6InDlUntjOQswlVnT4JObsSk+/glFohDjXixEVPfWoV8XfbEm2bZZ6aK463ZOpI xrLwHBqjMQaJdBnY5SpozM0xxS3oG2JJL90jPKtch0kGYds3i9PQbueeGGhriNVs vJAr0gibrbWlzNJKscPsweae+j8bEWQOrpmLZn267gSOceoi3DfD6kwpn95r2pi+ m1RENGgd4rG4hExhCMOIerRRIb0nKIn+IH4ZiP8t5+Q6VtHfKdo6HYGcHk/5HplA GLGQxDfFqZDYvdUNB4AJ5reNwJrZViqajOs2NC6Sc37ef2YWFszE9/bCVR/t1EZW ojlsbHKyV3uiSP64WbAKGA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1733599079; x= 1733685479; bh=GZwYRol97grL0PQDPhskpIcdlGKP1Z4QTNfMm6IoB2o=; b=U mT5E+ms1HpXyxZZ3tC1oR1p9vtsOxW2dG2b/t4qRLilIfbWgCZrB0rAl9Jcqgi+t TsmXgrRExIzvvEcC9v97g9dvv/z1E0LA+cV4fqXzgIIpP6iyEvKvKEX+C4BTDq5s I80Xn1xcQFfNAJtK0MJA6nDC4W/fAPqA8uRm0/EwHqeXqE9THIPE9ZUzUKrmWO2K LUHxXWB0IXe+TKXXQ7th3RgARmfEvpSa2HWB1rDIJyo649IyDDUktSFkzpJIdirV UfXkvXdLJoY/moqyx/CBtVx76CD0d2xq0xfi9f6gEaFC70OHhMBe0qULBZlHUGPl 31ksCpP3dq6JjgoNZuHpw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrjedugdduvdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephffvvefujghffgffkfggtgfgsehtqhertddtreej necuhfhrohhmpehjohhhnhcumhhuhhhluceojhhmsehpuhgsrdhpihhnkheqnecuggftrf grthhtvghrnhepgeevhedvtdetvdekuddvtddthefhvdfggfdvgfeitdejudehhfffjedt vdevveeknecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epjhhmsehpuhgsrdhpihhnkhdpnhgspghrtghpthhtohepiedpmhhouggvpehsmhhtphho uhhtpdhrtghpthhtohepvghgghgvrhhtsegtshdruhgtlhgrrdgvughupdhrtghpthhtoh epjhhonhgrshessggvrhhnohhulhdrlhhipdhrtghpthhtohepjeduheejvdesuggvsggs uhhgshdrghhnuhdrohhrghdprhgtphhtthhopegruggrmhesrghlphhhrghprghprgdrnh gvthdprhgtphhtthhopegvlhhiiiesghhnuhdrohhrghdprhgtphhtthhopehjughtshhm ihhthhesghhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: i74194916:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 7 Dec 2024 14:17:58 -0500 (EST) From: john muhl To: JD Smith Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate In-Reply-To: (JD Smith's message of "Sat, 7 Dec 2024 12:52:01 -0500") References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> <3530cd89-b5a2-4b25-95bf-1896c8ee4aef@cs.ucla.edu> <8CC4B1BB-B56A-4C3E-8B51-0E2D5B65C296@gmail.com> <86jzcbir3c.fsf@gnu.org> User-Agent: mu4e 1.12.1; emacs 31.0.50 Date: Sat, 07 Dec 2024 13:17:57 -0600 Message-ID: <874j3f2tga.fsf@pub.pink> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 71572 Cc: Adam Porter , 71572@debbugs.gnu.org, Eli Zaretskii , Jonas Bernoulli , Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) JD Smith writes: >> On Dec 7, 2024, at 8:02=E2=80=AFAM, Eli Zaretskii wrote: >>=20 >>> From: JD Smith >>> Date: Sat, 30 Nov 2024 13:58:52 -0500 >>> Cc: Eli Zaretskii , >>> Adam Porter , >>> jonas@bernoul.li, >>> Paul Eggert >>>=20 >>> I was recently reminded of the need for a more capable seconds-to-strin= g.=20=20 >>>=20 >>> Anyone have any additional comments on this proposed patch? If not, >>> I'd suggest someone with access >>> merges. >>=20 >> A few minor nits below, and then we can install: > > Thanks. Updated patch below. Thanks for working on this. I gave a quick try and noticed some amounts aren=E2=80=99t pluralized how I expect; e.g. (seconds-to-string 36541462 'expanded nil 1) ;; "1 year 1.9 month" (seconds-to-string 73082924 'expanded nil 2) ;; "2 year 3.79 months" (seconds-to-string 2511822 'expanded nil 3) ;; "4 week 1.072 day" I would expect those to output: 1 year 1.9 months 2 years 3.79 months 4 weeks 1.072 days According to the Chicago Manual of Style all fractional values are plural, even 1.0, 2.0 &c. The incorrect =E2=80=9C2 year=E2=80=9D, =E2=80=9C4 week=E2=80=9D only happe= n when PRECISION is non-nil; e.g. (seconds-to-string 2511822 'expanded nil) "4 weeks 1 day" p.s. There is a missing =E2=80=9Cis=E2=80=9D in the last sentence of the do= cstring for seconds-to-string. From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 08 14:54:20 2024 Received: (at 71572) by debbugs.gnu.org; 8 Dec 2024 19:54:20 +0000 Received: from localhost ([127.0.0.1]:51754 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKNMC-0003Yx-9F for submit@debbugs.gnu.org; Sun, 08 Dec 2024 14:54:20 -0500 Received: from mail-pg1-f170.google.com ([209.85.215.170]:53282) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKNM8-0003Ya-Si for 71572@debbugs.gnu.org; Sun, 08 Dec 2024 14:54:18 -0500 Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-7fd21e4aa2eso1684310a12.2 for <71572@debbugs.gnu.org>; Sun, 08 Dec 2024 11:54:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733687591; x=1734292391; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=T2CEOk19JDdzf/XjFy+hmeU0pcB8IWwJ/gSoBKJRrXg=; b=Tu1jMrkRDu566zwCKKMg9kAQO5WmuAPxG5QISsF73Fne0HjtSpcWDLXkgmZIIls/kL SQ92fmls1CVonyVnYr5ZyHZu5QZst0G0TPBO9V7Tb8Iy09riTVzVCVFhLmyiWkXwSg08 UjIoAAdmhf6GOlkJw9apBbitV4PePduHQ5uZbuLt8nd+ZHP/f2/iBlR7D5QzdyzWIPxu iqFvzFNgG4jZRRkBdM5Lj7bwKHvrG+Q2XYlTjLES2xS/hHLqNFD7c23Zfd1BQO4x4xr4 NbFZqTYmOYtVd+0Ts6P5niBrhfpwo04vNAs79EuZCt3EN9yvGfh2Y+TBfSEKW7DcZPwu mnzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733687591; x=1734292391; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=T2CEOk19JDdzf/XjFy+hmeU0pcB8IWwJ/gSoBKJRrXg=; b=vvUvtJ1Mr54YJvcaPFMdRHqf975Pt0EkWknrr88WCQyOlhkqdALHDGse7JcXFcqiyW M17yprmgIHJSGoYiBXfP5ZF4Rkv2cNhchWsEgJAyZ4R55UypY6uSBvmkJriGX1sB6242 UZsqlp2FxvPSEyrajqIy/eIY5tEjzfhvWBC18CNB+wW5am5NSvS2OmN6vMcLnGFlWcB8 5ISE7XaKlzdm8QrfaBX2QliYl8OYRUdxyCK3oJUIJftbBYavoibEZ9xMr4d24GncKRyR WzBsVKBuV63TGUXjftEO2S8kY9u5qu+hXLqEuzOk9aqZdRWR1GQAsUPySgm/pGT0z448 qV1Q== X-Forwarded-Encrypted: i=1; AJvYcCXVM6R7SvQ21ovr7KjnXMtvyo+JV1AdxdElhpJCTqFdSUd6u0QfIxEUNFWUqSjRQ82Y+EgrAw==@debbugs.gnu.org X-Gm-Message-State: AOJu0YyeckQ+/qjyEVqLvrS98cxOLvquDPDsz5f0raGUNFjA45kWrUf0 GjcUhlpJyu3rSjzM9Rtq+6Ev0oxNPMahFBtDfwUlG8xN/mXm+Q2l X-Gm-Gg: ASbGncsm0ThtBl/+aHn/+vYQLnGOzVTRSMGi/kJ0WJu2buAkCY/pdEIGIGmGd+vIe8Y 3HCI6k5o5qeKXE+V/Oy051GmKFiflJ3YndDM2CoZEcZSlt19cHSgyeoe81ThJaZ657BAi2HHQnH /0KqFieSg8OL85KBnsmjJZCG0qGJjmeDj71UYe3s7kUKXSG4OiEvEhg0gBe4NgdBxTmv4eIs5aj GpQVxCe+6lMd7M3bZZMwHayV/AnTct+FrncwEfhvsitbuZ3TRF0VALWJX0c/FVuU+I1s864Ciqa dLKOn3UG543KpFSTxjWWdtw= X-Google-Smtp-Source: AGHT+IEpg6UlAEIoLElFoBmnqsioRnnB8sNaIlFFyPw4g2uLPFcjOYIUC6Khz+PLbWHG7PY1gjeQsQ== X-Received: by 2002:a17:90b:3810:b0:2ea:356f:51b4 with SMTP id 98e67ed59e1d1-2ef69e16dc9mr15996623a91.13.1733687590654; Sun, 08 Dec 2024 11:53:10 -0800 (PST) Received: from smtpclient.apple (fs96f9cd8a.tkyc508.ap.nuro.jp. [150.249.205.138]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ef6d1fd68asm5244323a91.36.2024.12.08.11.53.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Dec 2024 11:53:09 -0800 (PST) From: JD Smith Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_DDBA6E5C-506F-4C03-B7B9-3E33D5165806" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate Date: Mon, 9 Dec 2024 04:52:56 +0900 In-Reply-To: <874j3f2tga.fsf@pub.pink> To: john muhl References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> <3530cd89-b5a2-4b25-95bf-1896c8ee4aef@cs.ucla.edu> <8CC4B1BB-B56A-4C3E-8B51-0E2D5B65C296@gmail.com> <86jzcbir3c.fsf@gnu.org> <874j3f2tga.fsf@pub.pink> X-Mailer: Apple Mail (2.3774.600.62) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 71572 Cc: Adam Porter , 71572@debbugs.gnu.org, Eli Zaretskii , Jonas Bernoulli , Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Apple-Mail=_DDBA6E5C-506F-4C03-B7B9-3E33D5165806 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Dec 8, 2024, at 4:17=E2=80=AFAM, john muhl wrote: >=20 > JD Smith > writes: >=20 >>> On Dec 7, 2024, at 8:02=E2=80=AFAM, Eli Zaretskii = wrote: >>>=20 >>>> From: JD Smith >>>> Date: Sat, 30 Nov 2024 13:58:52 -0500 >>>> Cc: Eli Zaretskii , >>>> Adam Porter , >>>> jonas@bernoul.li, >>>> Paul Eggert >>>>=20 >>>> I was recently reminded of the need for a more capable = seconds-to-string. =20 >>>>=20 >>>> Anyone have any additional comments on this proposed patch? If not, >>>> I'd suggest someone with access >>>> merges. >>>=20 >>> A few minor nits below, and then we can install: >>=20 >> Thanks. Updated patch below. >=20 > Thanks for working on this. I gave a quick try and noticed some > amounts aren=E2=80=99t pluralized how I expect; e.g. >=20 > (seconds-to-string 36541462 'expanded nil 1) > ;; "1 year 1.9 month" ... > According to the Chicago Manual of Style all fractional values are > plural, even 1.0, 2.0 &c. Thanks for this, a case I hadn't tested. Corrected in the attached. =EF=BF=BC --Apple-Mail=_DDBA6E5C-506F-4C03-B7B9-3E33D5165806 Content-Type: multipart/mixed; boundary="Apple-Mail=_511C128D-6BDC-4E62-99FA-55E18D861F0B" --Apple-Mail=_511C128D-6BDC-4E62-99FA-55E18D861F0B Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
On Dec 8, = 2024, at 4:17=E2=80=AFAM, john muhl <jm@pub.pink> wrote:

JD Smith <jdtsmith@gmail.com> = writes:

On Dec 7, 2024, at = 8:02=E2=80=AFAM, Eli Zaretskii <eliz@gnu.org> = wrote:

From: JD Smith = <jdtsmith@gmail.com>
Date: Sat, 30 Nov 2024 13:58:52 = -0500
Cc: Eli Zaretskii <eliz@gnu.org>,
Adam Porter = <adam@alphapapa.net>,
jonas@bernoul.li,
Paul Eggert = <eggert@cs.ucla.edu>

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:

Thanks. =  Updated patch below.

Thanks = for working on this. I gave a quick try and noticed some
amounts aren=E2=80=99t pluralized how I = expect; e.g.

 (seconds-to-string = 36541462 'expanded nil 1)
 ;; "1 year 1.9 = month"
...
According to the Chicago Manual of Style all = fractional values are
plural, even 1.0, 2.0 = &c.

Thanks for this, a case I = hadn't tested.  Corrected in the = attached.

= --Apple-Mail=_511C128D-6BDC-4E62-99FA-55E18D861F0B Content-Disposition: attachment; filename=0001-seconds-to-string-new-optional-arguments-for-readabl.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-seconds-to-string-new-optional-arguments-for-readabl.patch" Content-Transfer-Encoding: quoted-printable =46rom=20c1937c9969955cd040a6587cba9e4d91e79ec78c=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20JD=20Smith=20= <93749+jdtsmith@users.noreply.github.com>=0ADate:=20Thu,=2011=20Jul=20= 2024=2016:24:17=20-0400=0ASubject:=20[PATCH]=20seconds-to-string:=20new=20= optional=20arguments=20for=20readable=0A=20strings=0A=0A---=0A=20= doc/lispref/os.texi=20=20=20=20=20=20=20=20|=20=206=20+++=0A=20etc/NEWS=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=20=207=20++++=0A=20= lisp/calendar/time-date.el=20|=2082=20= ++++++++++++++++++++++++++++++++++++--=0A=203=20files=20changed,=2091=20= insertions(+),=204=20deletions(-)=0A=0Adiff=20--git=20= a/doc/lispref/os.texi=20b/doc/lispref/os.texi=0Aindex=20= 3ba3da459bf..ac9d5acdf3d=20100644=0A---=20a/doc/lispref/os.texi=0A+++=20= b/doc/lispref/os.texi=0A@@=20-2155,6=20+2155,12=20@@=20Time=20= Calculations=0A=20structure.=20=20For=20instance,=20the=20120th=20day=20= in=202004=20is=20April=2029th.=0A=20@end=20defun=0A=20=0A+@defun=20= seconds-to-string=20delay=20&optional=20readable=20abbrev=20precision=0A= +Return=20a=20string=20describing=20a=20given=20@var{delay}=20(in=20= seconds).=20=20Optional=0A+arguments=20can=20be=20used=20to=20configure=20= a=20human=20readable=20delay=20using=20various=0A+formats.=20=20For=20= example,=20a=20delay=20of=209861.5=20seconds=20with=20@var{readable}=20= set=0A+to=20the=20symbol=20@code{expanded}=20returns=20@samp{2=20hours=20= 44=20minutes}.=0A+=0A=20@node=20Timers=0A=20@section=20Timers=20for=20= Delayed=20Execution=0A=20@cindex=20timers=0Adiff=20--git=20a/etc/NEWS=20= b/etc/NEWS=0Aindex=20f10f9ae4d65..1fd2a9404bb=20100644=0A---=20= a/etc/NEWS=0A+++=20b/etc/NEWS=0A@@=20-30,6=20+30,13=20@@=20applies,=20= and=20please=20also=20update=20docstrings=20as=20needed.=0A=20=0C=0A=20*=20= Changes=20in=20Emacs=2031.1=0A=20=0A+**=20Time=20&=20Date=0A+=0A++++=0A= +***=20'seconds-to-string'=20includes=20new=20formatting=20options.=0A= +Options=20are=20provided=20to=20produce=20human-readable=20delay=20= strings=20in=20a=0A+variety=20of=20formats,=20for=20example=20"6=20= months=203=20weeks"=20or=20"5m=2052.5s".=0A+=0A=20=0C=0A=20*=20Editing=20= Changes=20in=20Emacs=2031.1=0A=20=0Adiff=20--git=20= a/lisp/calendar/time-date.el=20b/lisp/calendar/time-date.el=0Aindex=20= eca80f1e8b6..5d53052a65c=20100644=0A---=20a/lisp/calendar/time-date.el=0A= +++=20b/lisp/calendar/time-date.el=0A@@=20-409,11=20+409,85=20@@=20= seconds-to-string=0A=20=20=20=20=20=20=20=20=20(list=20(*=203600=2024=20= 400)=20"d"=20(*=203600.0=2024.0))=0A=20=20=20=20=20=20=20=20=20(list=20= nil=20"y"=20(*=20365.25=2024=203600)))=0A=20=20=20"Formatting=20used=20= by=20the=20function=20`seconds-to-string'.")=0A+=0A+(defvar=20= seconds-to-string-readable=0A+=20=20`(("Y"=20"year"=20=20=20"years"=20=20= =20,(round=20(*=2060=2060=2024=20365.2425)))=0A+=20=20=20=20("M"=20= "month"=20=20"months"=20=20,(round=20(*=2060=2060=2024=2030.436875)))=0A= +=20=20=20=20("w"=20"week"=20=20=20"weeks"=20=20=20,(*=2060=2060=2024=20= 7))=0A+=20=20=20=20("d"=20"day"=20=20=20=20"days"=20=20=20=20,(*=2060=20= 60=2024))=0A+=20=20=20=20("h"=20"hour"=20=20=20"hours"=20=20=20,(*=2060=20= 60))=0A+=20=20=20=20("m"=20"minute"=20"minutes"=2060)=0A+=20=20=20=20= ("s"=20"second"=20"seconds"=201))=0A+=20=20"Formatting=20used=20by=20the=20= function=20`seconds-to-string'=20with=20READABLE=20set.=0A+The=20format=20= is=20an=20alist,=20with=20string=20keys=20ABBREV-UNIT,=20and=20elements=20= like:=0A+=0A+=20=20(ABBREV-UNIT=20UNIT=20UNIT-PLURAL=20SECS)=0A+=0A= +where=20UNIT=20is=20a=20unit=20of=20time,=20ABBREV-UNIT=20is=20the=20= abreviated=20form=20of=0A+UNIT,=20UNIT-PLURAL=20is=20the=20plural=20form=20= of=20UNIT,=20and=20SECS=20is=20the=20number=20of=0A+seconds=20per=20= UNIT.")=0A+=0A=20;;;###autoload=0A-(defun=20seconds-to-string=20(delay)=0A= -=20=20;;=20FIXME:=20There's=20a=20similar=20(tho=20fancier)=20function=20= in=20mastodon.el!=0A-=20=20"Convert=20the=20time=20interval=20in=20= seconds=20to=20a=20short=20string."=0A-=20=20(cond=20((>=200=20delay)=20= (concat=20"-"=20(seconds-to-string=20(-=20delay))))=0A+(defun=20= seconds-to-string=20(delay=20&optional=20readable=20abbrev=20precision)=0A= +=20=20"Convert=20time=20interval=20DELAY=20(in=20seconds)=20to=20a=20= string.=0A+By=20default,=20the=20returned=20string=20is=20formatted=20as=20= a=20float=20in=20the=20smallest=0A+unit=20from=20the=20variable=20= `seconds-to-string'=20that=20is=20longer=20than=20DELAY,=0A+and=20a=20= precision=20of=20two.=20=20If=20READABLE=20is=20non-nil,=20convert=20= DELAY=20into=20a=0A+readable=20string,=20using=20the=20information=20= provided=20in=20the=20variable=0A+`seconds-to-string-readable'.=20=20If=20= it=20is=20the=20symbol=20`expanded',=20use=20two=0A+units=20to=20= describe=20DELAY,=20if=20appropriate.=20=20E.g.=20\"1=20hour=2032=20= minutes\".=0A+If=20ABBREV=20is=20non-nil,=20abbreviate=20the=20readable=20= units.=20=20If=20PRECISION=20is=20a=0A+whole=20number,=20round=20the=20= value=20associated=20with=20the=20smallest=20displayed=0A+unit=20to=20= that=20many=20digits=20after=20the=20decimal.=20=20If=20it=20is=20a=20= non-negative=0A+float=20less=20than=201.0,=20round=20to=20that=20value."=0A= +=20=20(cond=20((<=20delay=200)=0A+=09=20(concat=20"-"=20= (seconds-to-string=20(-=20delay)=20readable=20precision)))=0A+=20=20=20=20= =20=20=20=20(readable=0A+=20=20=20=20=20=20=20=20=20(let*=20((stsa=20= seconds-to-string-readable)=0A+=09=09(expanded=20(eq=20readable=20= 'expanded))=0A+=09=09digits=0A+=09=09(round-to=20(cond=20((wholenump=20= precision)=0A+=09=09=09=09=20(setq=20digits=20precision)=0A+=09=09=09=09=20= (expt=2010=20(-=20precision)))=0A+=09=09=09=09((and=20(floatp=20= precision)=20(<=20precision=201.))=0A+=09=09=09=09=20(setq=20digits=20(-=20= (floor=20(log=20precision=2010))))=0A+=09=09=09=09=20precision)=0A+=09=09= =09=09(t=20(setq=20digits=200)=201)))=0A+=09=09(dformat=20(if=20(>=20= digits=200)=20(format=20"%%0.%df"=20digits)))=0A+=09=09(padding=20(if=20= abbrev=20""=20"=20"))=0A+=09=09here=20cnt=20cnt-pre=20here-pre=20cnt-val=20= isfloatp)=0A+=09=20=20=20(if=20(=3D=20(round=20delay=20round-to)=200)=0A= +=09=20=20=20=20=20=20=20(format=20"0%s"=20(if=20abbrev=20"s"=20"=20= seconds"))=0A+=09=20=20=20=20=20(while=20(and=20(setq=20here=20(pop=20= stsa))=20stsa=0A+=09=09=09=20(<=20(/=20delay=20(nth=203=20here))=201)))=0A= +=09=20=20=20=20=20(or=20(and=0A+=09=09=20=20expanded=20stsa=20=09;=20= smaller=20unit=20remains=0A+=09=09=20=20(progn=0A+=09=09=20=20=20=20= (setq=0A+=09=09=20=20=20=20=20here-pre=20here=20here=20(car=20stsa)=0A+=09= =09=20=20=20=20=20cnt-pre=20(floor=20(/=20(float=20delay)=20(nth=203=20= here-pre)))=0A+=09=09=20=20=20=20=20cnt=20(round=0A+=09=09=09=20=20(/=20= (-=20(float=20delay)=20(*=20cnt-pre=20(nth=203=20here-pre)))=0A+=09=09=09= =20=20=20=20=20(nth=203=20here))=0A+=09=09=09=20=20round-to))=0A+=09=09=20= =20=20=20(if=20(>=20cnt=200)=20t=20(setq=20cnt=20cnt-pre=20here=20= here-pre=20here-pre=20nil))))=0A+=09=09=20(setq=20cnt=20(round=20(/=20= (float=20delay)=20(nth=203=20here))=20round-to)))=0A+=09=20=20=20=20=20= (setq=20cnt-val=20(*=20cnt=20round-to)=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20isfloatp=20(and=20(>=20digits=200)=0A+=09=09=09=20= =20=20=20=20=20=20=20=20=20=20=20(>=20(-=20cnt-val=20(floor=20cnt-val))=20= 0.)))=0A+=09=20=20=20=20=20(cl-labels=0A+=09=09=20((unit=20(val=20here=20= &optional=20plural)=0A+=09=09=20=20=20=20(cond=20(abbrev=20(car=20here))=0A= +=09=09=09=20=20((and=20(not=20plural)=20(<=3D=20(floor=20val)=201))=20= (nth=201=20here))=0A+=09=09=09=20=20(t=20(nth=202=20here)))))=0A+=09=20=20= =20=20=20=20=20(concat=0A+=09=09(when=20here-pre=0A+=09=09=20=20(concat=20= (number-to-string=20cnt-pre)=20padding=0A+=09=09=09=20=20(unit=20(*=20= cnt-pre=20round-to)=20here-pre)=20"=20"))=0A+=09=09(if=20isfloatp=20= (format=20dformat=20cnt-val)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(number-to-string=20(floor=20cnt-val)))=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20padding=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(unit=20cnt-val=20here=20isfloatp))))))=20;=20floats=20= are=20always=20plural=0A=20=20=20=20=20=20=20=20=20((=3D=200=20delay)=20= "0s")=0A=20=20=20=20=20=20=20=20=20(t=20(let=20((sts=20= seconds-to-string)=20here)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (while=20(and=20(car=20(setq=20here=20(pop=20sts)))=0A--=20=0A2.45.2=0A=0A= --Apple-Mail=_511C128D-6BDC-4E62-99FA-55E18D861F0B Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii

--Apple-Mail=_511C128D-6BDC-4E62-99FA-55E18D861F0B-- --Apple-Mail=_DDBA6E5C-506F-4C03-B7B9-3E33D5165806-- From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 08 17:52:05 2024 Received: (at 71572) by debbugs.gnu.org; 8 Dec 2024 22:52:05 +0000 Received: from localhost ([127.0.0.1]:51968 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKQ89-0004P7-Fs for submit@debbugs.gnu.org; Sun, 08 Dec 2024 17:52:05 -0500 Received: from fout-a7-smtp.messagingengine.com ([103.168.172.150]:45257) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKQ87-0004Ol-17 for 71572@debbugs.gnu.org; Sun, 08 Dec 2024 17:52:00 -0500 Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id EBF201383707; Sun, 8 Dec 2024 17:51:53 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Sun, 08 Dec 2024 17:51:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pub.pink; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1733698313; x=1733784713; bh=hlN+YMC1Ftovu+mco+4P1yIsUGmK8nYNti+2VvLgucs=; b= roonxBKKzb9MZg4LWV5j30JJ+PeasFFW+d3NYED5+AuEzuhRwfF5XHzw9jzo+dVi KpiUYCyC96o0C2Z7ARdngAsRJsayRuorTbYLMmD+2an2zzXR+S3MMtD8CKylSfso 1jYCEGLrEoavXC9Db//s4OjewxdRvmyML6YZjt0SdKUcr3ohBIddfMHxBIP7EyeO jiJjE8C26gfckBnExlKy6W7X5Mi3UpzLB8TuNGQE5fjsQZO3qhe1O/cB7KzJAG5d c4oMXcBHepIcmuQ4EV+rV21yWZMC+wYZ4jsAstuvn+NZlWCcjeEud4MsAOhXj1MX mNv8Eyavh9jb+pqy32lqyg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1733698313; x= 1733784713; bh=hlN+YMC1Ftovu+mco+4P1yIsUGmK8nYNti+2VvLgucs=; b=o DlaUyiIsjv800VX7FLaFmrhvbI57x0mPVkXa2fdEHYK7U931e07rTg/JbsfMWic8 GovFze/gKuqO6sCRCLiEMPavf289Tp5Kxb9/SqI1NIGIGd6mQBlN2+zXliuOXG4J d6yXm4Lce5XqiFsDcuZGxSgQDl2z5CjLutcgrDxoFHNoCnLJvp9JOfchwQOKR8yx TmsC77TrGV985OFEKP2CxZC328IvtqqZ0nSTJjaeWYDnI/kcKx5sbD/x3UULNLDH A+mkNxqOfWe8huq8esOnBanaY3+SJZoIcgmQaXvfteNW566NC4wDoUrgwtRRREqg BRskl8RHvfGG3DcvXsVxQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrjeeggddtfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpefhvfevufgjfhgffffkgggtgfesthhqredttderjeen ucfhrhhomhepjhhohhhnuchmuhhhlhcuoehjmhesphhusgdrphhinhhkqeenucggtffrrg htthgvrhhnpeegveehvddttedvkeduvddttdehhfdvgffgvdfgiedtjeduhefhffejtddv veevkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hjmhesphhusgdrphhinhhkpdhnsggprhgtphhtthhopeeipdhmohguvgepshhmthhpohhu thdprhgtphhtthhopegvghhgvghrthestghsrdhutghlrgdrvgguuhdprhgtphhtthhope hjohhnrghssegsvghrnhhouhhlrdhlihdprhgtphhtthhopeejudehjedvseguvggssghu ghhsrdhgnhhurdhorhhgpdhrtghpthhtoheprggurghmsegrlhhphhgrphgrphgrrdhnvg htpdhrtghpthhtohepvghlihiisehgnhhurdhorhhgpdhrtghpthhtohepjhguthhsmhhi thhhsehgmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: i74194916:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 8 Dec 2024 17:51:52 -0500 (EST) From: john muhl To: JD Smith Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate In-Reply-To: (JD Smith's message of "Mon, 9 Dec 2024 04:52:56 +0900") References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> <3530cd89-b5a2-4b25-95bf-1896c8ee4aef@cs.ucla.edu> <8CC4B1BB-B56A-4C3E-8B51-0E2D5B65C296@gmail.com> <86jzcbir3c.fsf@gnu.org> <874j3f2tga.fsf@pub.pink> User-Agent: mu4e 1.12.1; emacs 31.0.50 Date: Sun, 08 Dec 2024 16:51:51 -0600 Message-ID: <871pyhu6t4.fsf@pub.pink> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 71572 Cc: Adam Porter , 71572@debbugs.gnu.org, Eli Zaretskii , Jonas Bernoulli , Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) JD Smith writes: > On Dec 8, 2024, at 4:17=E2=80=AFAM, john muhl wrote: > > JD Smith writes: > > On Dec 7, 2024, at 8:02=E2=80=AFAM, Eli Zaretskii wrote: > > 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= .=20=20 > > 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: > > Thanks. Updated patch below. > > Thanks for working on this. I gave a quick try and noticed some > amounts aren=E2=80=99t pluralized how I expect; e.g. > > (seconds-to-string 36541462 'expanded nil 1) > ;; "1 year 1.9 month" > > ... > > According to the Chicago Manual of Style all fractional values are > plural, even 1.0, 2.0 &c. > > Thanks for this, a case I hadn't tested. Corrected in the attached. Looks good but the bigger interval is still always singular in the expanded w/ precision case: (seconds-to-string 73082924 'expanded nil 2) ;; "2 year 3.79 months" ;; ^ should be years I got it working with: @@ -477,7 +477,7 @@ seconds-to-string (concat (when here-pre (concat (number-to-string cnt-pre) padding - (unit (* cnt-pre round-to) here-pre) " ")) + (unit (* cnt-pre round-to) here-pre (> cnt-pre 1)) " ")) (if isfloatp (format dformat cnt-val) (number-to-string (floor cnt-val))) padding Thanks again. From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 15 13:09:10 2024 Received: (at 71572) by debbugs.gnu.org; 15 Dec 2024 18:09:10 +0000 Received: from localhost ([127.0.0.1]:51905 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tMt3F-0002uM-E5 for submit@debbugs.gnu.org; Sun, 15 Dec 2024 13:09:10 -0500 Received: from mail-qk1-f182.google.com ([209.85.222.182]:60862) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tMt3C-0002uC-4t for 71572@debbugs.gnu.org; Sun, 15 Dec 2024 13:09:07 -0500 Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-7b15d7b7a32so357740385a.1 for <71572@debbugs.gnu.org>; Sun, 15 Dec 2024 10:09:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734286085; x=1734890885; darn=debbugs.gnu.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=3L/RdWAuM/TjwLJXLhQKuY1uBo146EYfHiOhqT+fVVI=; b=YG1HWUPtttm1zmoLWasCo7HvQCnk6G4M47iOhtMR0pMYRijKVkqSxmaZOCIPehegxE ry5Bd073HEB5OoMok9FnbzfDmpj88mG6hhwOcxHfbYIRB/9lwWE4R6y3jx2yB90aPjGW VrXhISwNiWcLiZeP5mqUSQKx+QaJDcwzWh8z5QLjnaqzv+sRBGvKlxPGA9Xa+eW8tH80 BdruHuIfJ/a5y3ELurbQrpc0TkqaIXeENuHopnIE+Macj5Io+Mz5M1RVjav92uOLQ0EQ AyjaKwdXVSlPP49yMLg+7LubBVfVhYrCNikGGX57H64q6zb1lAm8mgY4DpT3nzOd2ENY xJJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734286085; x=1734890885; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3L/RdWAuM/TjwLJXLhQKuY1uBo146EYfHiOhqT+fVVI=; b=c/jWV1N8tq1NPGdgk15ix8NwptBJPnqa1zq1WSjxHpiC5Tubq8RCr5TiSn5qSkEqvG BMv1PQOPJiF4/TOMfnVWpljlYO9aD/yWl2e5i4OQdNhFOSy0nr4XehpzYGKB3MUHWF89 bJjwuw6UvQpVy3Io28oxlOLj+sfKef8cz89B36rv2d4OFbFILGGPjNJGDVC3GVEwfeco VIGrNoNtqPevJM+zZUg5Kao/hOzDjyVqW+1OFXO36PRCKmBna2C1Xk/23K0iv3yBBGij EoVtU1SI5qT2OuY0AHUcsEzmLCuLI5IUmWsEcyD0F5ROfhk2v98NISIy+FQ843fa3Gfy lF5w== X-Forwarded-Encrypted: i=1; AJvYcCUQNkvQRWpHIN1/s6ETqC20vZBjNk1iGXjiVwhexA6/LfQHSIiQTi5gS2DNxKTG+kc20raakw==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yzr+ht/zYyqLOhngJo8GfgrLLrCt0Qeq7GIbG/oU6m/DEIUla3m DZb98yTmPNjW9OeZOtZLwEUEIqAkwzou/0WjFxz2bkeZLuKSmLMX X-Gm-Gg: ASbGncupCQ5Jfu2pCQsFf4Wakw9c/5rTzrRp5jrjR693lBhCTHYAhPt02z5L6AX1dXP 9cNDvnhSkmplNyWeQH7EuB66k+JmzmN7x8aXCxeSuwecDl+o/tzBAyDRFYTDDG0OkUKTolmksWJ 5qqk48YbWvD3xQPTh2FOt+tQBtfgbrm8GjKujhwI9/krUgGYqmu78H6GH9FiYtHRmM01TfkZBL1 ZVq1UueZN9iR+X/iAO8DMqYyk5Obtq5rjaJGttNbjiBrwbLFbJkLxLDftHftGwwmpVt7Qw= X-Google-Smtp-Source: AGHT+IFXaPZFy0PAEGNSY9AQ5NNc+UPH/Dm6Qn/H28n1fEn+9WUkN5mUPREfNksCoDeBuPCpHXtYGg== X-Received: by 2002:a05:620a:438b:b0:7b6:6a76:3a44 with SMTP id af79cd13be357-7b6fbee814amr1677057185a.17.1734286085260; Sun, 15 Dec 2024 10:08:05 -0800 (PST) Received: from smtpclient.apple ([198.30.180.20]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7b7048ca970sm151777785a.108.2024.12.15.10.08.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Dec 2024 10:08:04 -0800 (PST) From: JD Smith Message-Id: <1CCC10A3-F76D-477C-9E04-AA0903853EAC@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_1D16646F-CD29-4AF7-8419-EE1BC6DCCBE9" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate Date: Sun, 15 Dec 2024 13:07:52 -0500 In-Reply-To: <871pyhu6t4.fsf@pub.pink> To: john muhl References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> <3530cd89-b5a2-4b25-95bf-1896c8ee4aef@cs.ucla.edu> <8CC4B1BB-B56A-4C3E-8B51-0E2D5B65C296@gmail.com> <86jzcbir3c.fsf@gnu.org> <874j3f2tga.fsf@pub.pink> <871pyhu6t4.fsf@pub.pink> X-Mailer: Apple Mail (2.3774.600.62) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 71572 Cc: Adam Porter , 71572@debbugs.gnu.org, Eli Zaretskii , Jonas Bernoulli , Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Apple-Mail=_1D16646F-CD29-4AF7-8419-EE1BC6DCCBE9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 >> On Dec 8, 2024, at 4:17=E2=80=AFAM, john muhl wrote: >>=20 >> Thanks for working on this. I gave a quick try and noticed some >> amounts aren=E2=80=99t pluralized how I expect; e.g. >>=20 >> (seconds-to-string 36541462 'expanded nil 1) >> ;; "1 year 1.9 month" Thanks again. This was another small bug in the units for the first = expanded term. Corrected (final?) patch attached. Could you please = give another quick test? For posterity I also include below a more complete test script and its = output (see new column s2s-e1). ++ Delay (s) s2s s2s-r s2s-ra s2s-ra1 s2s-rah = s2s-e s2s-e1 s2s-ea s2s-ea1 s2s-ea3 = s2s-eah 0.000 0s 0 seconds 0s 0s 0s = 0 seconds 0 seconds 0s 0s 0s = 0s 0.450 450.00ms 0 seconds 0s 0.4s 0.5s = 0 seconds 0.4 seconds 0s 0.4s 0.450s = 0.5s 0.855 855.00ms 1 second 1s 0.9s 1s = 1 second 0.9 seconds 1s 0.9s 0.855s = 1s 1.624 1.62s 2 seconds 2s 1.6s 1.5s = 2 seconds 1.6 seconds 2s 1.6s 1.624s = 1.5s 3.087 3.09s 3 seconds 3s 3.1s 3s = 3 seconds 3.1 seconds 3s 3.1s 3.087s = 3s 5.864 5.86s 6 seconds 6s 5.9s 6s = 6 seconds 5.9 seconds 6s 5.9s 5.864s = 6s 11.142 11.14s 11 seconds 11s 11.1s 11s = 11 seconds 11.1 seconds 11s 11.1s 11.142s = 11s 21.171 21.17s 21 seconds 21s 21.2s 21s = 21 seconds 21.2 seconds 21s 21.2s 21.171s = 21s 40.224 40.22s 40 seconds 40s 40.2s 40s = 40 seconds 40.2 seconds 40s 40.2s 40.224s = 40s 76.426 76.43s 1 minute 1m 1.3m 1.5m 1 = minute 16 seconds 1 minute 16.4 seconds 1m 16s 1m 16.4s 1m = 16.426s 1m 16.5s 145.209 2.42m 2 minutes 2m 2.4m 2.5m 2 = minutes 25 seconds 2 minutes 25.2 seconds 2m 25s 2m 25.2s 2m = 25.209s 2m 25s 275.898 4.60m 5 minutes 5m 4.6m 4.5m 4 = minutes 36 seconds 4 minutes 35.9 seconds 4m 36s 4m 35.9s 4m = 35.898s 4m 36s 524.206 8.74m 9 minutes 9m 8.7m 8.5m 8 = minutes 44 seconds 8 minutes 44.2 seconds 8m 44s 8m 44.2s 8m = 44.206s 8m 44s 995.992 16.60m 17 minutes 17m 16.6m 16.5m 16 = minutes 36 seconds 16 minutes 36 seconds 16m 36s 16m 36s 16m = 35.992s 16m 36s 1892.384 31.54m 32 minutes 32m 31.5m 31.5m 31 = minutes 32 seconds 31 minutes 32.4 seconds 31m 32s 31m 32.4s 31m = 32.384s 31m 32.5s 3595.530 59.93m 60 minutes 60m 59.9m 60m 59 = minutes 56 seconds 59 minutes 55.5 seconds 59m 56s 59m 55.5s 59m = 55.530s 59m 55.5s 6831.507 1.90h 2 hours 2h 1.9h 2h 1 = hour 54 minutes 1 hour 53.9 minutes 1h 54m 1h 53.9m 1h = 53.858m 1h 54m 12979.864 3.61h 4 hours 4h 3.6h 3.5h 3 = hours 36 minutes 3 hours 36.3 minutes 3h 36m 3h 36.3m 3h = 36.331m 3h 36.5m 24661.741 6.85h 7 hours 7h 6.9h 7h 6 = hours 51 minutes 6 hours 51 minutes 6h 51m 6h 51m 6h = 51.029m 6h 51m 46857.308 13.02h 13 hours 13h 13h 13h 13 = hours 1 minute 13 hours 1 minute 13h 1m 13h 1m 13h 0.955m = 13h 1m 89028.885 24.73h 1 day 1d 1d 1d = 1 day 1 hour 1 day 0.7 hours 1d 1h 1d 0.7h 1d 0.730h = 1d 0.5h 169154.881 1.96d 2 days 2d 2d 2d = 1 day 23 hours 1 day 23 hours 1d 23h 1d 23h 1d 22.987h = 1d 23h 321394.273 3.72d 4 days 4d 3.7d 3.5d 3 = days 17 hours 3 days 17.3 hours 3d 17h 3d 17.3h 3d 17.276h = 3d 17.5h 610649.119 7.07d 1 week 1w 1w 1w = 1 week 1 week 0.1 days 1w 1w 0.1d 1w 0.068d = 1w 1160233.326 13.43d 2 weeks 2w 1.9w 2w = 1 week 6 days 1 week 6.4 days 1w 6d 1w 6.4d 1w 6.429d = 1w 6.5d 2204443.319 25.51d 4 weeks 4w 3.6w 3.5w = 3 weeks 5 days 3 weeks 4.5 days 3w 5d 3w 4.5d 3w 4.514d = 3w 4.5d 4188442.306 48.48d 2 months 2M 1.6M 1.5M 1 = month 3 weeks 1 month 2.6 weeks 1M 3w 1M 2.6w 1M 2.577w = 1M 2.5w 7958040.381 92.11d 3 months 3M 3M 3M = 3 months 3 months 0.1 weeks 3M 3M 0.1w 3M 0.114w = 3M 15120276.725 175.00d 6 months 6M 5.7M 5.5M 5 = months 3 weeks 5 months 3.3 weeks 5M 3w 5M 3.3w 5M 3.260w = 5M 3.5w 28728525.777 332.51d 11 months 11M 10.9M 11M 10 = months 4 weeks 10 months 4 weeks 10M 4w 10M 4w 10M 4.020w = 10M 4w 54584198.976 1.73y 2 years 2Y 1.7Y 1.5Y 1 = year 9 months 1 year 8.8 months 1Y 9M 1Y 8.8M 1Y 8.756M = 1Y 9M 103709978.054 3.29y 3 years 3Y 3.3Y 3.5Y 3 = years 3 months 3 years 3.4 months 3Y 3M 3Y 3.4M 3Y 3.437M = 3Y 3.5M 197048958.302 6.24y 6 years 6Y 6.2Y 6Y 6 = years 3 months 6 years 2.9 months 6Y 3M 6Y 2.9M 6Y 2.931M = 6Y 3M 374393020.774 11.86y 12 years 12Y 11.9Y 12Y 11 = years 10 months 11 years 10.4 months 11Y 10M 11Y 10.4M 11Y = 10.369M 11Y 10.5M 711346739.471 22.54y 23 years 23Y 22.5Y 22.5Y 22 = years 7 months 22 years 6.5 months 22Y 7M 22Y 6.5M 22Y 6.500M = 22Y 6.5M =EF=BF=BC=EF=BF=BC --Apple-Mail=_1D16646F-CD29-4AF7-8419-EE1BC6DCCBE9 Content-Type: multipart/mixed; boundary="Apple-Mail=_60A67380-BDEC-4F4A-A5BC-30D57CEAAC58" --Apple-Mail=_60A67380-BDEC-4F4A-A5BC-30D57CEAAC58 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Dec 8, 2024, at 4:17=E2=80=AFAM, john muhl <jm@pub.pink> = wrote:

Thanks for working on this. I gave a quick try and noticed = some
amounts aren=E2=80=99t pluralized how I expect; = e.g.

 (seconds-to-string 36541462 'expanded nil = 1)
 ;; "1 year 1.9 = month"

Thanks again. =  This was another small bug in the units for the first expanded = term.  Corrected (final?) patch attached.  Could you please = give another quick test?

For posterity I also = include below a more complete test script and its output (see new column = s2s-e1).

++
    =  Delay (s)        s2s       = s2s-r  s2s-ra  s2s-ra1  s2s-rah       =            s2s-e       =             s2s-e1   s2s-ea   =  s2s-ea1      s2s-ea3   =  s2s-eah
    =      0.000         0s   0 = seconds      0s       0s     =   0s              0 seconds =                0 seconds   =     0s         0s       =     0s         0s
         0.450   = 450.00ms   0 seconds      0s     0.4s =     0.5s              0 = seconds              0.4 seconds =       0s       0.4s       = 0.450s       0.5s
         0.855   855.00ms   =  1 second      1s     0.9s     =   1s               1 second =              0.9 seconds   =     1s       0.9s       0.855s =         1s
         1.624      1.62s =   2 seconds      2s     1.6s     = 1.5s              2 seconds   =            1.6 seconds     =   2s       1.6s       1.624s   =     1.5s
  =        3.087      3.09s   3 = seconds      3s     3.1s       = 3s              3 seconds   =            3.1 seconds     =   3s       3.1s       3.087s   =       3s
         5.864      5.86s =   6 seconds      6s     5.9s     =   6s              6 seconds =              5.9 seconds   =     6s       5.9s       5.864s =         6s
        11.142     11.14s  11 = seconds     11s    11.1s      11s =             11 seconds     =         11.1 seconds      11s   =    11.1s      11.142s       =  11s
    =     21.171     21.17s  21 seconds     = 21s    21.2s      21s       =       21 seconds           =   21.2 seconds      21s      21.2s =      21.171s       =  21s
    =     40.224     40.22s  40 seconds     = 40s    40.2s      40s       =       40 seconds           =   40.2 seconds      40s      40.2s =      40.224s       =  40s
    =     76.426     76.43s    1 minute   =    1m     1.3m     1.5m    1 = minute 16 seconds    1 minute 16.4 seconds   1m 16s =   1m 16.4s   1m 16.426s   1m 16.5s
       145.209     =  2.42m   2 minutes      2m     2.4m =     2.5m   2 minutes 25 seconds   2 minutes 25.2 = seconds   2m 25s   2m 25.2s   2m 25.209s     2m = 25s
      =  275.898      4.60m   5 minutes     =  5m     4.6m     4.5m   4 minutes 36 = seconds   4 minutes 35.9 seconds   4m 36s   4m 35.9s =   4m 35.898s     4m 36s
       524.206     =  8.74m   9 minutes      9m     8.7m =     8.5m   8 minutes 44 seconds   8 minutes 44.2 = seconds   8m 44s   8m 44.2s   8m 44.206s     8m = 44s
      =  995.992     16.60m  17 minutes     17m =    16.6m    16.5m  16 minutes 36 seconds   =  16 minutes 36 seconds  16m 36s    16m 36s  16m = 35.992s    16m 36s
      1892.384     31.54m  32 = minutes     32m    31.5m    31.5m  31 = minutes 32 seconds  31 minutes 32.4 seconds  31m 32s  31m = 32.4s  31m 32.384s  31m 32.5s
      3595.530     59.93m =  60 minutes     60m    59.9m     =  60m  59 minutes 56 seconds  59 minutes 55.5 seconds =  59m 56s  59m 55.5s  59m 55.530s  59m = 55.5s
      = 6831.507      1.90h     2 hours     =  2h     1.9h       2h     =  1 hour 54 minutes      1 hour 53.9 minutes   = 1h 54m   1h 53.9m   1h 53.858m     1h = 54m
    =  12979.864      3.61h     4 hours   =    4h     3.6h     3.5h     3 = hours 36 minutes     3 hours 36.3 minutes   3h 36m   = 3h 36.3m   3h 36.331m   3h 36.5m
     24661.741     =  6.85h     7 hours      7h     = 6.9h       7h     6 hours 51 minutes   =     6 hours 51 minutes   6h 51m     6h 51m =   6h 51.029m     6h 51m
     46857.308     13.02h =    13 hours     13h      13h   =    13h      13 hours 1 minute     =    13 hours 1 minute   13h 1m     13h 1m   = 13h 0.955m     13h 1m
     89028.885     24.73h     =   1 day      1d       1d   =     1d           1 day 1 hour   =        1 day 0.7 hours    1d 1h   =  1d 0.7h    1d 0.730h    1d = 0.5h
    = 169154.881      1.96d      2 days   =    2d       2d       2d   =       1 day 23 hours           1 = day 23 hours   1d 23h     1d 23h   1d 22.987h   =   1d 23h
    = 321394.273      3.72d      4 days   =    4d     3.7d     3.5d     =    3 days 17 hours        3 days 17.3 = hours   3d 17h   3d 17.3h   3d 17.276h   3d = 17.5h
    = 610649.119      7.07d      1 week   =    1w       1w       1w   =               1 week     =      1 week 0.1 days       1w   =  1w 0.1d    1w 0.068d         = 1w
   1160233.326 =     13.43d     2 weeks      2w   =   1.9w       2w          1 = week 6 days          1 week 6.4 days   =  1w 6d    1w 6.4d    1w 6.429d    1w = 6.5d
  =  2204443.319     25.51d     4 weeks   =    4w     3.6w     3.5w     =     3 weeks 5 days         3 weeks 4.5 = days    3w 5d    3w 4.5d    3w 4.514d =    3w 4.5d
  =  4188442.306     48.48d    2 months   =    2M     1.6M     1.5M     =    1 month 3 weeks        1 month 2.6 = weeks    1M 3w    1M 2.6w    1M 2.577w =    1M 2.5w
  =  7958040.381     92.11d    3 months   =    3M       3M       3M   =             3 months       = 3 months 0.1 weeks       3M    3M 0.1w   =  3M 0.114w         3M
  15120276.725    175.00d   =  6 months      6M     5.7M     = 5.5M       5 months 3 weeks       5 months = 3.3 weeks    5M 3w    5M 3.3w    5M 3.260w =    5M 3.5w
  = 28728525.777    332.51d   11 months     11M =    10.9M      11M      10 months = 4 weeks        10 months 4 weeks   10M 4w =     10M 4w   10M 4.020w     10M = 4w
  54584198.976 =      1.73y     2 years      2Y =     1.7Y     1.5Y        1 year = 9 months        1 year 8.8 months    1Y 9M =    1Y 8.8M    1Y 8.756M      1Y = 9M
 103709978.054 =      3.29y     3 years      3Y =     3.3Y     3.5Y       3 years 3 = months       3 years 3.4 months    3Y 3M   =  3Y 3.4M    3Y 3.437M    3Y = 3.5M
 197048958.302 =      6.24y     6 years      6Y =     6.2Y       6Y       6 years = 3 months       6 years 2.9 months    6Y 3M =    6Y 2.9M    6Y 2.931M      6Y = 3M
 374393020.774 =     11.86y    12 years     12Y   =  11.9Y      12Y     11 years 10 months =     11 years 10.4 months  11Y 10M  11Y 10.4M =  11Y 10.369M  11Y 10.5M
 711346739.471     22.54y    23 years =     23Y    22.5Y    22.5Y     =  22 years 7 months      22 years 6.5 months   = 22Y 7M   22Y 6.5M   22Y 6.500M   22Y = 6.5M



<= /div>= --Apple-Mail=_60A67380-BDEC-4F4A-A5BC-30D57CEAAC58 Content-Disposition: attachment; filename=0001-seconds-to-string-new-optional-arguments-for-readabl.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-seconds-to-string-new-optional-arguments-for-readabl.patch" Content-Transfer-Encoding: quoted-printable =46rom=20e72354cdf2bc0394890c42a28fe8e892a0e6f9a8=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20JD=20Smith=20= <93749+jdtsmith@users.noreply.github.com>=0ADate:=20Thu,=2011=20Jul=20= 2024=2016:24:17=20-0400=0ASubject:=20[PATCH]=20seconds-to-string:=20new=20= optional=20arguments=20for=20readable=0A=20strings=0A=0A---=0A=20= doc/lispref/os.texi=20=20=20=20=20=20=20=20|=20=206=20+++=0A=20etc/NEWS=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=20=207=20++++=0A=20= lisp/calendar/time-date.el=20|=2082=20= ++++++++++++++++++++++++++++++++++++--=0A=203=20files=20changed,=2091=20= insertions(+),=204=20deletions(-)=0A=0Adiff=20--git=20= a/doc/lispref/os.texi=20b/doc/lispref/os.texi=0Aindex=20= 3ba3da459bf..ac9d5acdf3d=20100644=0A---=20a/doc/lispref/os.texi=0A+++=20= b/doc/lispref/os.texi=0A@@=20-2155,6=20+2155,12=20@@=20Time=20= Calculations=0A=20structure.=20=20For=20instance,=20the=20120th=20day=20= in=202004=20is=20April=2029th.=0A=20@end=20defun=0A=20=0A+@defun=20= seconds-to-string=20delay=20&optional=20readable=20abbrev=20precision=0A= +Return=20a=20string=20describing=20a=20given=20@var{delay}=20(in=20= seconds).=20=20Optional=0A+arguments=20can=20be=20used=20to=20configure=20= a=20human=20readable=20delay=20using=20various=0A+formats.=20=20For=20= example,=20a=20delay=20of=209861.5=20seconds=20with=20@var{readable}=20= set=0A+to=20the=20symbol=20@code{expanded}=20returns=20@samp{2=20hours=20= 44=20minutes}.=0A+=0A=20@node=20Timers=0A=20@section=20Timers=20for=20= Delayed=20Execution=0A=20@cindex=20timers=0Adiff=20--git=20a/etc/NEWS=20= b/etc/NEWS=0Aindex=20f10f9ae4d65..1fd2a9404bb=20100644=0A---=20= a/etc/NEWS=0A+++=20b/etc/NEWS=0A@@=20-30,6=20+30,13=20@@=20applies,=20= and=20please=20also=20update=20docstrings=20as=20needed.=0A=20=0C=0A=20*=20= Changes=20in=20Emacs=2031.1=0A=20=0A+**=20Time=20&=20Date=0A+=0A++++=0A= +***=20'seconds-to-string'=20includes=20new=20formatting=20options.=0A= +Options=20are=20provided=20to=20produce=20human-readable=20delay=20= strings=20in=20a=0A+variety=20of=20formats,=20for=20example=20"6=20= months=203=20weeks"=20or=20"5m=2052.5s".=0A+=0A=20=0C=0A=20*=20Editing=20= Changes=20in=20Emacs=2031.1=0A=20=0Adiff=20--git=20= a/lisp/calendar/time-date.el=20b/lisp/calendar/time-date.el=0Aindex=20= eca80f1e8b6..c3206d1aa54=20100644=0A---=20a/lisp/calendar/time-date.el=0A= +++=20b/lisp/calendar/time-date.el=0A@@=20-409,11=20+409,85=20@@=20= seconds-to-string=0A=20=20=20=20=20=20=20=20=20(list=20(*=203600=2024=20= 400)=20"d"=20(*=203600.0=2024.0))=0A=20=20=20=20=20=20=20=20=20(list=20= nil=20"y"=20(*=20365.25=2024=203600)))=0A=20=20=20"Formatting=20used=20= by=20the=20function=20`seconds-to-string'.")=0A+=0A+(defvar=20= seconds-to-string-readable=0A+=20=20`(("Y"=20"year"=20=20=20"years"=20=20= =20,(round=20(*=2060=2060=2024=20365.2425)))=0A+=20=20=20=20("M"=20= "month"=20=20"months"=20=20,(round=20(*=2060=2060=2024=2030.436875)))=0A= +=20=20=20=20("w"=20"week"=20=20=20"weeks"=20=20=20,(*=2060=2060=2024=20= 7))=0A+=20=20=20=20("d"=20"day"=20=20=20=20"days"=20=20=20=20,(*=2060=20= 60=2024))=0A+=20=20=20=20("h"=20"hour"=20=20=20"hours"=20=20=20,(*=2060=20= 60))=0A+=20=20=20=20("m"=20"minute"=20"minutes"=2060)=0A+=20=20=20=20= ("s"=20"second"=20"seconds"=201))=0A+=20=20"Formatting=20used=20by=20the=20= function=20`seconds-to-string'=20with=20READABLE=20set.=0A+The=20format=20= is=20an=20alist,=20with=20string=20keys=20ABBREV-UNIT,=20and=20elements=20= like:=0A+=0A+=20=20(ABBREV-UNIT=20UNIT=20UNIT-PLURAL=20SECS)=0A+=0A= +where=20UNIT=20is=20a=20unit=20of=20time,=20ABBREV-UNIT=20is=20the=20= abreviated=20form=20of=0A+UNIT,=20UNIT-PLURAL=20is=20the=20plural=20form=20= of=20UNIT,=20and=20SECS=20is=20the=20number=20of=0A+seconds=20per=20= UNIT.")=0A+=0A=20;;;###autoload=0A-(defun=20seconds-to-string=20(delay)=0A= -=20=20;;=20FIXME:=20There's=20a=20similar=20(tho=20fancier)=20function=20= in=20mastodon.el!=0A-=20=20"Convert=20the=20time=20interval=20in=20= seconds=20to=20a=20short=20string."=0A-=20=20(cond=20((>=200=20delay)=20= (concat=20"-"=20(seconds-to-string=20(-=20delay))))=0A+(defun=20= seconds-to-string=20(delay=20&optional=20readable=20abbrev=20precision)=0A= +=20=20"Convert=20time=20interval=20DELAY=20(in=20seconds)=20to=20a=20= string.=0A+By=20default,=20the=20returned=20string=20is=20formatted=20as=20= a=20float=20in=20the=20smallest=0A+unit=20from=20the=20variable=20= `seconds-to-string'=20that=20is=20longer=20than=20DELAY,=0A+and=20a=20= precision=20of=20two.=20=20If=20READABLE=20is=20non-nil,=20convert=20= DELAY=20into=20a=0A+readable=20string,=20using=20the=20information=20= provided=20in=20the=20variable=0A+`seconds-to-string-readable'.=20=20If=20= it=20is=20the=20symbol=20`expanded',=20use=20two=0A+units=20to=20= describe=20DELAY,=20if=20appropriate.=20=20E.g.=20\"1=20hour=2032=20= minutes\".=0A+If=20ABBREV=20is=20non-nil,=20abbreviate=20the=20readable=20= units.=20=20If=20PRECISION=20is=20a=0A+whole=20number,=20round=20the=20= value=20associated=20with=20the=20smallest=20displayed=0A+unit=20to=20= that=20many=20digits=20after=20the=20decimal.=20=20If=20it=20is=20a=20= non-negative=0A+float=20less=20than=201.0,=20round=20to=20that=20value."=0A= +=20=20(cond=20((<=20delay=200)=0A+=09=20(concat=20"-"=20= (seconds-to-string=20(-=20delay)=20readable=20precision)))=0A+=20=20=20=20= =20=20=20=20(readable=0A+=20=20=20=20=20=20=20=20=20(let*=20((stsa=20= seconds-to-string-readable)=0A+=09=09(expanded=20(eq=20readable=20= 'expanded))=0A+=09=09digits=0A+=09=09(round-to=20(cond=20((wholenump=20= precision)=0A+=09=09=09=09=20(setq=20digits=20precision)=0A+=09=09=09=09=20= (expt=2010=20(-=20precision)))=0A+=09=09=09=09((and=20(floatp=20= precision)=20(<=20precision=201.))=0A+=09=09=09=09=20(setq=20digits=20(-=20= (floor=20(log=20precision=2010))))=0A+=09=09=09=09=20precision)=0A+=09=09= =09=09(t=20(setq=20digits=200)=201)))=0A+=09=09(dformat=20(if=20(>=20= digits=200)=20(format=20"%%0.%df"=20digits)))=0A+=09=09(padding=20(if=20= abbrev=20""=20"=20"))=0A+=09=09here=20cnt=20cnt-pre=20here-pre=20cnt-val=20= isfloatp)=0A+=09=20=20=20(if=20(=3D=20(round=20delay=20round-to)=200)=0A= +=09=20=20=20=20=20=20=20(format=20"0%s"=20(if=20abbrev=20"s"=20"=20= seconds"))=0A+=09=20=20=20=20=20(while=20(and=20(setq=20here=20(pop=20= stsa))=20stsa=0A+=09=09=09=20(<=20(/=20delay=20(nth=203=20here))=201)))=0A= +=09=20=20=20=20=20(or=20(and=0A+=09=09=20=20expanded=20stsa=20=09;=20= smaller=20unit=20remains=0A+=09=09=20=20(progn=0A+=09=09=20=20=20=20= (setq=0A+=09=09=20=20=20=20=20here-pre=20here=20here=20(car=20stsa)=0A+=09= =09=20=20=20=20=20cnt-pre=20(floor=20(/=20(float=20delay)=20(nth=203=20= here-pre)))=0A+=09=09=20=20=20=20=20cnt=20(round=0A+=09=09=09=20=20(/=20= (-=20(float=20delay)=20(*=20cnt-pre=20(nth=203=20here-pre)))=0A+=09=09=09= =20=20=20=20=20(nth=203=20here))=0A+=09=09=09=20=20round-to))=0A+=09=09=20= =20=20=20(if=20(>=20cnt=200)=20t=20(setq=20cnt=20cnt-pre=20here=20= here-pre=20here-pre=20nil))))=0A+=09=09=20(setq=20cnt=20(round=20(/=20= (float=20delay)=20(nth=203=20here))=20round-to)))=0A+=09=20=20=20=20=20= (setq=20cnt-val=20(*=20cnt=20round-to)=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20isfloatp=20(and=20(>=20digits=200)=0A+=09=09=09=20= =20=20=20=20=20=20=20=20=20=20=20(>=20(-=20cnt-val=20(floor=20cnt-val))=20= 0.)))=0A+=09=20=20=20=20=20(cl-labels=0A+=09=09=20((unit=20(val=20here=20= &optional=20plural)=0A+=09=09=20=20=20=20(cond=20(abbrev=20(car=20here))=0A= +=09=09=09=20=20((and=20(not=20plural)=20(<=3D=20(floor=20val)=201))=20= (nth=201=20here))=0A+=09=09=09=20=20(t=20(nth=202=20here)))))=0A+=09=20=20= =20=20=20=20=20(concat=0A+=09=09(when=20here-pre=0A+=09=09=20=20(concat=20= (number-to-string=20cnt-pre)=20padding=0A+=09=09=09=20=20(unit=20cnt-pre=20= here-pre)=20"=20"))=0A+=09=09(if=20isfloatp=20(format=20dformat=20= cnt-val)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (number-to-string=20(floor=20cnt-val)))=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20padding=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(unit=20cnt-val=20here=20isfloatp))))))=20;=20float=20formats=20are=20= always=20plural=0A=20=20=20=20=20=20=20=20=20((=3D=200=20delay)=20"0s")=0A= =20=20=20=20=20=20=20=20=20(t=20(let=20((sts=20seconds-to-string)=20= here)=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20(while=20(and=20(car=20= (setq=20here=20(pop=20sts)))=0A--=20=0A2.45.2=0A=0A= --Apple-Mail=_60A67380-BDEC-4F4A-A5BC-30D57CEAAC58 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii
--Apple-Mail=_60A67380-BDEC-4F4A-A5BC-30D57CEAAC58 Content-Disposition: attachment; filename=s2s_test.el Content-Type: application/octet-stream; x-unix-mode=0644; name="s2s_test.el" Content-Transfer-Encoding: quoted-printable (require=20'cl-lib)=0A=0A(defun=20s2s/example=20()=0A=20=20(interactive)=0A= =20=20(with-temp-buffer-window=20"s2s/example"=20nil=20nil=0A=20=20=20=20= (princ=0A=20=20=20=20=20(concat=0A=20=20=20=20=20=20(format=20"%14s=20= %10s=20=20%10s=20=20%6s=20=20%7s=20=20%7s=20=20%21s=20=20%23s=20=20%7s=20= =20%9s=20=20%11s=20=20%9s\n"=0A=09=20=20=20=20=20=20"Delay=20(s)"=20= "s2s"=20"s2s-r"=20"s2s-ra"=20"s2s-ra1"=20"s2s-rah"=20"s2s-e"=20"s2s-e1"=20= "s2s-ea"=20"s2s-ea1"=0A=09=20=20=20=20=20=20"s2s-ea3"=20"s2s-eah")=0A=20=20= =20=20=20=20(cl-loop=20for=20s=20=3D=200.0=20then=20(if=20(zerop=20s)=20= 0.45=20(*=20s=201.9))=0A=09=20=20=20=20=20=20=20while=20(<=20s=20(*=20= 365.25=2024=203600=2040))=0A=09=20=20=20=20=20=20=20concat=20(format=20= "%14.3f=20%10s=20=20%10s=20=20%6s=20=20%7s=20=20%7s=20=20%21s=20=20%23s=20= =20%7s=20=20%9s=20=20%11s=20=20%9s\n"=20s=0A=09=09=09=20=20=20=20=20=20= (seconds-to-string=20s)=0A=09=09=09=20=20=20=20=20=20(seconds-to-string=20= s=20'readable)=0A=09=09=09=20=20=20=20=20=20(seconds-to-string=20s=20= 'readable=20'abbrev)=0A=09=09=09=20=20=20=20=20=20(seconds-to-string=20s=20= 'readable=20'abbrev=201)=0A=09=09=09=20=20=20=20=20=20(seconds-to-string=20= s=20'readable=20'abbrev=200.5)=0A=09=09=09=20=20=20=20=20=20= (seconds-to-string=20s=20'expanded)=0A=09=09=09=20=20=20=20=20=20= (seconds-to-string=20s=20'expanded=20nil=201)=0A=09=09=09=20=20=20=20=20=20= (seconds-to-string=20s=20'expanded=20'abbrev)=0A=09=09=09=20=20=20=20=20=20= (seconds-to-string=20s=20'expanded=20'abbrev=201)=0A=09=09=09=20=20=20=20= =20=20(seconds-to-string=20s=20'expanded=20'abbrev=203)=0A=09=09=09=20=20= =20=20=20=20(seconds-to-string=20s=20'expanded=20'abbrev=200.5)))))))=0A=0A= (defun=20s2s/benchmark=20()=0A=20=20(interactive)=0A=20=20(let*=20= ((ndelays=20100000)=0A=09=20(delays=20(cl-loop=20for=20i=20from=201=20to=20= ndelays=0A=09=09=09=20=20with=20max=20=3D=20(*=20365.25=2024=203600=20= 40)=0A=09=09=09=20=20collect=20(cl-random=20max)))=0A=09=20(bsmpl=20= (benchmark-run=20nil=0A=09=09=20=20(cl-loop=20for=20d=20in=20delays=0A=09= =09=09=20=20=20do=20(seconds-to-string=20d))))=0A=09=20(brdbl=20= (benchmark-run=20nil=0A=09=09=20=20(cl-loop=20for=20d=20in=20delays=0A=09= =09=09=20=20=20do=20(seconds-to-string=20d=20t=20t=200.1)))))=0A=20=20=20= =20(with-temp-buffer-window=20"s2s/benchmarks"=20nil=20nil=0A=20=20=20=20= =20=20(princ=20"seconds-to-string=20benchmarks\n")=0A=20=20=20=20=20=20= (princ=20(format=20"=20=20default=20timing:=20%0.2f=C2=B5s\n\t%S\n"=0A=09= =09=20=20=20=20=20(/=20(car=20bsmpl)=20ndelays=201e-6)=20bsmpl))=0A=20=20= =20=20=20=20(princ=20(format=20"=20readable=20timing:=20= %0.2f=C2=B5s\n\t%S\n\n"=0A=09=09=20=20=20=20=20(/=20(car=20brdbl)=20= ndelays=201e-6)=20brdbl))=0A=20=20=20=20=20=20(princ=20(format=20= "readable/default:=20%0.2f\n"=20(/=20(car=20brdbl)=20(car=20bsmpl)))))))=0A= --Apple-Mail=_60A67380-BDEC-4F4A-A5BC-30D57CEAAC58 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=us-ascii



--Apple-Mail=_60A67380-BDEC-4F4A-A5BC-30D57CEAAC58-- --Apple-Mail=_1D16646F-CD29-4AF7-8419-EE1BC6DCCBE9-- From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 15 18:26:15 2024 Received: (at 71572) by debbugs.gnu.org; 15 Dec 2024 23:26:15 +0000 Received: from localhost ([127.0.0.1]:52628 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tMy07-0001e7-GB for submit@debbugs.gnu.org; Sun, 15 Dec 2024 18:26:15 -0500 Received: from fout-a8-smtp.messagingengine.com ([103.168.172.151]:58709) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tMy03-0001dm-VW for 71572@debbugs.gnu.org; Sun, 15 Dec 2024 18:26:13 -0500 Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfout.phl.internal (Postfix) with ESMTP id 834DA13838F1; Sun, 15 Dec 2024 18:26:06 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-09.internal (MEProxy); Sun, 15 Dec 2024 18:26:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pub.pink; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1734305166; x=1734391566; bh=YrZyV0XIc8uV/83TqkVEMLPBywCA6Vo66Zy48/8fZjI=; b= YpnUNxJ3Lg/dM58eoRLG3bz0hGXJ1omrwRP2XrjMdzV6N6xgLo5q5qSRcfBYMLDt PK9S+SFfeV7/0SNWXOH3QjNmj4PmhRgEJaNEVGBWk5d3wG63c6MstRSzHlGBWWM2 5klsePvDq27nDaq7/KHo27171B2HqfvuD49aLBTO1TcrRxt0SLXPiHxu4oqAZI8T ie2132xDviuyWOWKc5p1qcCec+rXZDWrsdW6C6NcyoGxSuJ79iBeMKZgcHa2lTZN kLLKBFbcEM/ms1gIPB9x4q6a9InR/ZkCPL74qnXhn201xUCRlEi27xgUeQryefiR 9i1iRbjUDUV0r5z4OSWhlw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1734305166; x= 1734391566; bh=YrZyV0XIc8uV/83TqkVEMLPBywCA6Vo66Zy48/8fZjI=; b=Q IZTHs+6C9JDwq26mYaDMSEq+3ZEUfkkC9wG+2HCvbCmSO7YrTBWobOIofcyfnlSQ 56TOc5oSzxSYpW4XHdLBWK/YwnQgHvzqxwLMeOMQMs0yeupV2i6BV+/PQm6tcHXL y9wB7PmzdkmiXEzxL1WR+yACSZm+NgAiko9N+JbiXJcAzpYmMOOUMm0fnEDmOmz7 D3cKumMk1r2zto3d5+VoVGDaR4hGw2nGp4fHORENlTZtpv0dH2hW7RPpHdsg6zed /vOhgjheTSASR278Aok6khTKFOaGlMXsNdjOHCVAmAycywm/gfHpLxt4tpItsO6l OxR2854KOwIpTjX8QWsIg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrledvgddutdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnth hsucdlqddutddtmdenucfjughrpefhvfevufgjfhgffffkgggtgfesthhqredttderjeen ucfhrhhomhepjhhohhhnuchmuhhhlhcuoehjmhesphhusgdrphhinhhkqeenucggtffrrg htthgvrhhnpeegveehvddttedvkeduvddttdehhfdvgffgvdfgiedtjeduhefhffejtddv veevkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hjmhesphhusgdrphhinhhkpdhnsggprhgtphhtthhopeeipdhmohguvgepshhmthhpohhu thdprhgtphhtthhopegvghhgvghrthestghsrdhutghlrgdrvgguuhdprhgtphhtthhope hjohhnrghssegsvghrnhhouhhlrdhlihdprhgtphhtthhopeejudehjedvseguvggssghu ghhsrdhgnhhurdhorhhgpdhrtghpthhtoheprggurghmsegrlhhphhgrphgrphgrrdhnvg htpdhrtghpthhtohepvghlihiisehgnhhurdhorhhgpdhrtghpthhtohepjhguthhsmhhi thhhsehgmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: i74194916:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 15 Dec 2024 18:26:05 -0500 (EST) From: john muhl To: JD Smith Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate In-Reply-To: <1CCC10A3-F76D-477C-9E04-AA0903853EAC@gmail.com> (JD Smith's message of "Sun, 15 Dec 2024 13:07:52 -0500") References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> <3530cd89-b5a2-4b25-95bf-1896c8ee4aef@cs.ucla.edu> <8CC4B1BB-B56A-4C3E-8B51-0E2D5B65C296@gmail.com> <86jzcbir3c.fsf@gnu.org> <874j3f2tga.fsf@pub.pink> <871pyhu6t4.fsf@pub.pink> <1CCC10A3-F76D-477C-9E04-AA0903853EAC@gmail.com> User-Agent: mu4e 1.12.1; emacs 31.0.50 Date: Sun, 15 Dec 2024 17:26:04 -0600 Message-ID: <87y10gjzoz.fsf@pub.pink> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 71572 Cc: Adam Porter , 71572@debbugs.gnu.org, Eli Zaretskii , Jonas Bernoulli , Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) JD Smith writes: > On Dec 8, 2024, at 4:17=E2=80=AFAM, john muhl wrote: > > Thanks for working on this. I gave a quick try and noticed some > amounts aren=E2=80=99t pluralized how I expect; e.g. > > (seconds-to-string 36541462 'expanded nil 1) > ;; "1 year 1.9 month" > > Thanks again. This was another small bug in the units for the first expa= nded > term. Corrected (final?) patch attached. Could you please give another = quick > test? Works for all my test cases. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 21 05:32:21 2024 Received: (at 71572-done) by debbugs.gnu.org; 21 Dec 2024 10:32:21 +0000 Received: from localhost ([127.0.0.1]:45387 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tOwmS-0001qX-M2 for submit@debbugs.gnu.org; Sat, 21 Dec 2024 05:32:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46240) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tOwmP-0001qG-AA for 71572-done@debbugs.gnu.org; Sat, 21 Dec 2024 05:32:19 -0500 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 1tOwmH-0000gu-Ge; Sat, 21 Dec 2024 05:32:09 -0500 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=zBqY8avuzNrdiqCdPuMyoY3WT1PmPMtWnSz320DRvtA=; b=dgLkl+SUi3bXVGzm9CN5 gilKoXBLSiauw3mt2GTF4FS61iFazbCSapzJ8k+PxeJLNu/FIvbnyzHGXmPEcF8T+qPpe3N5jC0lM fUpEYsMFSn5QOq4GhhO9OUMDxVbJLEQNCzj8eamqrdtc+j4J/BN6WDq1TQFxM8TY/InHmn2TJG/t1 udihS7I1A6eNnhf8dhVW2t4VvDua55GevGuxVT1vXh8Us+7ddoACenVFklj6rqkxrYpVpO7SCFvLS mchjqlLeuosRsIAcapGoXqiP3qSWTVPVxXMScEHWmhvlnN5aLn7AxexZ4MEEmNkm/1xDTnv2SEOfD NjJOseCGOXb1ZA==; Date: Sat, 21 Dec 2024 12:32:04 +0200 Message-Id: <8634ih8gyj.fsf@gnu.org> From: Eli Zaretskii To: john muhl In-Reply-To: <87y10gjzoz.fsf@pub.pink> (message from john muhl on Sun, 15 Dec 2024 17:26:04 -0600) Subject: Re: bug#71572: [PATCH] seconds-to-string-approximate References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> <3530cd89-b5a2-4b25-95bf-1896c8ee4aef@cs.ucla.edu> <8CC4B1BB-B56A-4C3E-8B51-0E2D5B65C296@gmail.com> <86jzcbir3c.fsf@gnu.org> <874j3f2tga.fsf@pub.pink> <871pyhu6t4.fsf@pub.pink> <1CCC10A3-F76D-477C-9E04-AA0903853EAC@gmail.com> <87y10gjzoz.fsf@pub.pink> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 71572-done Cc: adam@alphapapa.net, jonas@bernoul.li, 71572-done@debbugs.gnu.org, jdtsmith@gmail.com, eggert@cs.ucla.edu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: john muhl > Cc: Eli Zaretskii , Adam Porter , > 71572@debbugs.gnu.org, Jonas Bernoulli , Paul Eggert > > Date: Sun, 15 Dec 2024 17:26:04 -0600 > > JD Smith writes: > > > On Dec 8, 2024, at 4:17 AM, john muhl wrote: > > > > Thanks for working on this. I gave a quick try and noticed some > > amounts aren’t pluralized how I expect; e.g. > > > > (seconds-to-string 36541462 'expanded nil 1) > > ;; "1 year 1.9 month" > > > > Thanks again. This was another small bug in the units for the first expanded > > term. Corrected (final?) patch attached. Could you please give another quick > > test? > > Works for all my test cases. Thanks. Thanks, now installed on master, and closing the bug. From unknown Sat Jun 21 10:11:45 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 18 Jan 2025 12:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator