From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.bugs Subject: bug#71572: [PATCH] seconds-to-string-approximate Date: Thu, 04 Jul 2024 16:36:03 +0000 Message-ID: <87plrt9kss.fsf@localhost> References: <86r0cpicwt.fsf@gnu.org> <86msmxafog.fsf@gnu.org> <1FFF1E0D-A0E0-4EB9-AC97-AEB0BFADFBBC@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37489"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Adam Porter , 71572@debbugs.gnu.org, Eli Zaretskii , jonas@bernoul.li, Paul Eggert To: JD Smith Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 04 18:35:19 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sPPQT-0009WJ-GY for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Jul 2024 18:35:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sPPQD-0002pe-Ra; Thu, 04 Jul 2024 12:35:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sPPQC-0002pE-8j for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2024 12:35:00 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sPPQC-0004i4-0f for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2024 12:35:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sPPQE-0006rL-AI for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2024 12:35:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Jul 2024 16:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71572 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 71572-submit@debbugs.gnu.org id=B71572.172011088226323 (code B ref 71572); Thu, 04 Jul 2024 16:35:02 +0000 Original-Received: (at 71572) by debbugs.gnu.org; 4 Jul 2024 16:34:42 +0000 Original-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 Original-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 Original-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== Original-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) In-Reply-To: <1FFF1E0D-A0E0-4EB9-AC97-AEB0BFADFBBC@gmail.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:288380 Archived-At: 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