|
From: | JD Smith |
Subject: | bug#71572: [PATCH] seconds-to-string-approximate |
Date: | Thu, 4 Jul 2024 11:27:41 -0400 |
<snip>
I definitely think rounding makes more sense for a readable unit; consider 2.98y.
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 = 5.47515s, so s2s has it right.
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. Updated output at the same delays for the various new options (r: readable, e: readable=expanded, 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 ½s 0 seconds 0s ½s 1.03 1.03s 1 second 1s 1s 1 second 1s 1s 2.38 2.38s 2 seconds 2s 2½s 2 seconds 2s 2½s 5.48 5.48s 5 seconds 5s 5½s 5 seconds 5s 5½s 12.59 12.59s 13 seconds 13s 12½s 13 seconds 13s 12½s 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½s 153.22 2.55m 3 minutes 3m 2½m 2 minutes 33 seconds 2m 33s 2m 33s 352.40 5.87m 6 minutes 6m 6m 5 minutes 52 seconds 5m 52s 5m 52½s 810.52 13.51m 14 minutes 14m 13½m 13 minutes 31 seconds 13m 31s 13m 30½s 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½m 9861.58 2.74h 3 hours 3h 2½h 2 hours 44 minutes 2h 44m 2h 44½m 22681.64 6.30h 6 hours 6h 6½h 6 hours 18 minutes 6h 18m 6h 18m 52167.76 14.49h 14 hours 14h 14½h 14 hours 29 minutes 14h 29m 14h 29½m 119985.86 1.39d 1 day 1d 1½d 1 day 9 hours 1d 9h 1d 9½h 275967.47 3.19d 3 days 3d 3d 3 days 5 hours 3d 5h 3d 4½h 634725.18 7.35d 1 week 1w 1w 7 days 7d 1w ½d 1459867.91 16.90d 2 weeks 2w 2½w 2 weeks 3 days 2w 3d 2w 3d 3357696.19 38.86d 1 month 1M 1½M 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½w 40853089.56 1.29y 1 year 1Y 1½Y 1 year 4 months 1Y 4M 1Y 3½M 93962106.00 2.98y 3 years 3Y 3Y 2 years 12 months 2Y 12M 2Y 11½M 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 = 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)))) |
time-data-readable-seconds-2.patch
Description: Binary data
[Prev in Thread] | Current Thread | [Next in Thread] |