Subject: bug#71572: [PATCH] seconds-to-string-approximate

From: JD Smith <[email-masked]>
Date: Sun, 15 Dec 2024 13:07:52 -0500

>> On Dec 8, 2024, at 4:17 AM, john muhl <[email-masked]> 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?

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

￼￼