unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: JD Smith <jdtsmith@gmail.com>
Cc: Adam Porter <adam@alphapapa.net>,
	71572@debbugs.gnu.org, Eli Zaretskii <eliz@gnu.org>,
	jonas@bernoul.li, Paul Eggert <eggert@cs.ucla.edu>
Subject: bug#71572: [PATCH] seconds-to-string-approximate
Date: Thu, 04 Jul 2024 17:57:55 +0000	[thread overview]
Message-ID: <87jzi19h0c.fsf@localhost> (raw)
In-Reply-To: <88073600-0BF6-4EA1-9EE4-9455FDF20EAC@gmail.com>

JD Smith <jdtsmith@gmail.com> writes:

> I had not seen that function, thanks for pointing it out.  Looks useful and 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 need started), you can have ages from seconds to many years, so you need something that accommodates that dynamic range well.  magit--age was the inspiration, and we're in fact just reusing Jonas' configuration variable.

  Delay (s)      s-to-s            mastodon    mastodon (3600s)    mast (1yr)  s-to-s (rdb)                  Org     Org (frac) s-to-s (rdb=abbrev, half)
        0.5    450.00ms               0 sec               0 sec         0 sec           0s                 0min        0.01min   ½s
        1.0       1.03s               1 sec               1 sec         1 sec           1s                 0min        0.02min   1s
        2.4       2.38s              2 secs              2 secs        2 secs           2s                 0min        0.04min   2½s
        5.5       5.48s              5 secs              5 secs        5 secs           5s                 0min        0.09min   5½s
       12.6      12.59s             12 secs             12 secs       12 secs          13s                 0min        0.21min   12½s
       29.0      28.96s             28 secs             28 secs       28 secs          29s                 0min        0.48min   29s
       66.6      66.62s               1 min               1 min         1 min           1m                 1min        1.11min   1m
      153.2       2.55m              2 mins              2 mins        2 mins           3m                 2min        2.55min   2½m
      352.4       5.87m              5 mins              5 mins        5 mins           6m                 5min        5.87min   6m
      810.5      13.51m             13 mins             13 mins       13 mins          14m                13min       13.51min   13½m
     1864.2      31.07m             31 mins             31 mins       31 mins          31m                31min       31.07min   31m
     4287.6      71.46m     1 hour, 11 mins              1 hour        1 hour           1h             1h 11min          1.19h   1h
     9861.6       2.74h    2 hours, 44 mins             2 hours       2 hours           3h             2h 44min          2.74h   2½h
    22681.6       6.30h    6 hours, 18 mins             6 hours       6 hours           6h             6h 18min          6.30h   6½h
    52167.8      14.49h   14 hours, 29 mins            14 hours      14 hours          14h            14h 29min         14.49h   14½h
   119985.9       1.39d      1 day, 9 hours      1 day, 9 hours         1 day           1d          1d 9h 19min          1.39d   1½d
   275967.5       3.19d     3 days, 4 hours     3 days, 4 hours        3 days           3d          3d 4h 39min          3.19d   3d
   634725.2       7.35d              1 week              1 week        1 week           1w          7d 8h 18min          7.35d   1w
  1459867.9      16.90d     2 weeks, 2 days     2 weeks, 2 days       2 weeks           2w        16d 21h 31min         16.90d   2½w
  3357696.2      38.86d     1 month, 1 week     1 month, 1 week       1 month           1M      1m 8d 20h 41min          1.30m   1½M
  7722701.2      89.38d   2 months, 4 weeks   2 months, 4 weeks      2 months           3M      2m 29d 9h 11min          2.98m   3M
 17762212.9     205.58d   6 months, 3 weeks   6 months, 3 weeks      6 months           7M     6m 25d 13h 56min          6.85m   7M
 40853089.6       1.29y    1 year, 3 months    1 year, 3 months        1 year           1Y   1y 3m 17d 14h 4min          1.29y   1½Y
 93962106.0       2.98y  2 years, 11 months  2 years, 11 months       2 years           3Y     2y 11m 27d 35min          2.98y   3Y
216112843.8       6.85y  6 years, 10 months  6 years, 10 months       6 years           7Y  6y 10m 9d 19h 20min          6.85y   7Y
497059540.7      15.75y  15 years, 9 months  15 years, 9 months      15 years          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 (frac)" "s-to-s (rdb=abbrev, half)")
 (cl-loop for s = 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))))

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>





  reply	other threads:[~2024-07-04 17:57 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-15 17:24 bug#71573: [PATCH] seconds-to-string-approximate JD Smith
2024-06-15 17:36 ` Eli Zaretskii
2024-06-17  6:20 ` bug#71573: Related functions from ts.el Adam Porter
2024-06-22 10:55   ` Stefan Kangas
2024-06-22 21:54     ` Adam Porter
2024-06-22  8:45 ` bug#71572: [PATCH] seconds-to-string-approximate Eli Zaretskii
2024-06-22 21:56   ` Adam Porter
2024-06-22 23:42   ` Paul Eggert
2024-06-23  2:16     ` JD Smith
2024-07-04  5:29       ` Eli Zaretskii
2024-07-04  6:04         ` Eli Zaretskii
2024-07-04  7:09         ` Paul Eggert
2024-07-06 19:29           ` JD Smith
2024-07-06 21:09             ` Paul Eggert
2024-07-11 21:01               ` JD Smith
2024-11-30 18:58                 ` JD Smith
2024-07-04 15:27         ` JD Smith
2024-07-04 15:59           ` Eli Zaretskii
2024-07-04 17:16             ` JD Smith
2024-07-04 18:06               ` Eli Zaretskii
2024-07-04 16:36           ` Ihor Radchenko
2024-07-04 17:23             ` JD Smith
2024-07-04 17:57               ` Ihor Radchenko [this message]
2024-06-23  5:13     ` Eli Zaretskii
2024-07-03 20:32       ` JD Smith
2024-07-04  5:29         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87jzi19h0c.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=71572@debbugs.gnu.org \
    --cc=adam@alphapapa.net \
    --cc=eggert@cs.ucla.edu \
    --cc=eliz@gnu.org \
    --cc=jdtsmith@gmail.com \
    --cc=jonas@bernoul.li \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).