From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: JD Smith Newsgroups: gmane.emacs.bugs Subject: bug#71572: [PATCH] seconds-to-string-approximate Date: Sun, 15 Dec 2024 13:07:52 -0500 Message-ID: <1CCC10A3-F76D-477C-9E04-AA0903853EAC@gmail.com> 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> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_1D16646F-CD29-4AF7-8419-EE1BC6DCCBE9" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25072"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Adam Porter , 71572@debbugs.gnu.org, Eli Zaretskii , Jonas Bernoulli , Paul Eggert To: john muhl Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 15 19:10:28 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 1tMt4V-0006LB-Kl for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 15 Dec 2024 19:10:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tMt4J-0005uv-FT; Sun, 15 Dec 2024 13:10:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tMt4B-0005rk-KB for bug-gnu-emacs@gnu.org; Sun, 15 Dec 2024 13:10:08 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tMt47-0002ZA-94 for bug-gnu-emacs@gnu.org; Sun, 15 Dec 2024 13:10:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:Date:Mime-Version:From:To:Subject; bh=3L/RdWAuM/TjwLJXLhQKuY1uBo146EYfHiOhqT+fVVI=; b=ZbCmMT90tOUGapUKvbeTnIPmwyiQkpoWRf3L1T2hAI3rFnpBXzQMZR99LDN6fnGqPaV0AONAsI/cZwVbaPeIcRgbdcj7m5nA6y2PSyyIMpYT9xef5VBPlNmGhiOlUzJa3KVlwsNMxJ5o8tTU24I5hIuqehBz/tZLTZBpB8rkysPzzUeQ6l6iizAqr8Q2tLksWBhcyluBYaseeueSWz9SCJ9AorA6/FF0/+pyI00m1PZwib1t4EcPb+bbmuHZqW+6HfTwen7jy6x0Xpr6DcZ/aDx05D2QmUAdhV4rggNExlEu+jCAQ/oKRb/SQeYWm/7F0DjlXLg/LN85sWaIkptZjA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tMt46-0002w4-FY for bug-gnu-emacs@gnu.org; Sun, 15 Dec 2024 13:10:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: JD Smith Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 15 Dec 2024 18:10: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.173428615011187 (code B ref 71572); Sun, 15 Dec 2024 18:10:02 +0000 Original-Received: (at 71572) by debbugs.gnu.org; 15 Dec 2024 18:09:10 +0000 Original-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 Original-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 Original-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) Original-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) In-Reply-To: <871pyhu6t4.fsf@pub.pink> X-Mailer: Apple Mail (2.3774.600.62) 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:297117 Archived-At: --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--