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 17:57:55 +0000 Message-ID: <87jzi19h0c.fsf@localhost> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1878"; 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 19:57:17 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 1sPQho-0000Bs-Tx for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Jul 2024 19:57:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sPQhg-0001xJ-35; Thu, 04 Jul 2024 13:57:09 -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 1sPQhZ-0001jf-1H for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2024 13:57:01 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sPQhX-00058o-JZ for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2024 13:57:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sPQhZ-0000b8-UJ for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2024 13:57:01 -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 17:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71572 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 71572-submit@debbugs.gnu.org id=B71572.17201158032270 (code B ref 71572); Thu, 04 Jul 2024 17:57:01 +0000 Original-Received: (at 71572) by debbugs.gnu.org; 4 Jul 2024 17:56:43 +0000 Original-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 Original-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 Original-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== Original-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) In-Reply-To: <88073600-0BF6-4EA1-9EE4-9455FDF20EAC@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:288384 Archived-At: 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