emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Samuel Wales <samologist@gmail.com>
To: M <Elwood151@web.de>
Cc: emacs orgmode-mailinglist <emacs-orgmode@gnu.org>
Subject: Re: How can I calculate the "age" of a headline?
Date: Tue, 19 Aug 2014 14:30:33 -0700	[thread overview]
Message-ID: <CAJcAo8v+o-JPOZcfyis3itghrO6w8Szsw-SuiEWeUypBT2=qgA@mail.gmail.com> (raw)
In-Reply-To: <D019395F.1F15A%Elwood151@web.de>

i call these time spans.

to me, it would be excellent as a custom timestamp format.

this requires a patch to org at this location:

	Modified lisp/org.el
diff --git a/lisp/org.el b/lisp/org.el
index b1dc1ce..4497693 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16814,6 +16814,8 @@ The command returns the inserted time stamp."
 	  tf (funcall (if with-hm 'cdr 'car) org-time-stamp-custom-formats)
 	  time (org-fix-decoded-time t1)
 	  str (org-add-props
+                  ;; fixme alpha make it so that you can run a function
+                  ;; (alpha-org-annotate-ts-with-time-span
 		  (format-time-string
 		   (substring tf 1 -1) (apply 'encode-time time))
 		  nil 'mouse-face 'highlight)

then the code for the time spans is as follows.

(defun alpha-org-time-span-as-string (&optional from now)
  "Return the time span from now
to the active or inactive Org timestamp at point, or nil.

+1 means tomorrow.
 0 means today.
-1 means yesterday.

from and now are daynums.
"
  ;; (alpha-org-time-span from now)
  (let ((from (or from (alpha-org-daynum-from-ts-at-point)))
        (now (or now (alpha-org-daynum-from-now))))
    (when (and from now)
      (alpha-org-format-time-span (- from now)))))
(defun alpha-org-format-time-span (span)
  ;; + makes the numbers line up better
  ;; fixme emacs bug with 0
  (format " = %+-3g" span))
  ;; (format " [= %+-3g]" span))

(defun alpha-org-daynum-from-ts (ts)
  (time-to-days (org-time-string-to-time ts)))
;; (alpha-org-daynum-from-now)
(defun alpha-org-daynum-from-now ()
  (alpha-org-daynum-from-ts "<now>"))
(defun alpha-org-daynum-from-ts-at-point ()
  ;; inactive too
  ;; (if ts
  ;; (alpha-org-daynum-from-ts ts)
  (when (org-at-timestamp-p t)
    (alpha-org-daynum-from-ts
     (substring (match-string 1) 0 10))))





On 8/19/14, M <Elwood151@web.de> wrote:
> In my task lists, I'm working with scheduled and deadline dates.
> However, it would also often be very interesting, how "old" a task is, how
> long it is lurking around on my lists..
>
> Therefore it would be interesting to find the oldest timestamp below this
> heading and calculate the difference in days to today.
>
> Is that possible with org-mode already?
> Could I display this information in a tabular agenda view in a column?
>
> Kind regards
>
> Martin
>
>
>
>


-- 
The Kafka Pandemic: http://thekafkapandemic.blogspot.com

The disease DOES progress.  MANY people have died from it.  And
ANYBODY can get it.

Denmark: free Karina Hansen NOW.

      parent reply	other threads:[~2014-08-19 21:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-19 15:26 How can I calculate the "age" of a headline? M
2014-08-19 15:34 ` Thorsten Jolitz
2014-08-19 16:30   ` M
2014-08-19 17:50     ` Thorsten Jolitz
2014-08-19 15:41 ` John Kitchin
2014-08-19 21:30 ` Samuel Wales [this message]

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.orgmode.org/

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

  git send-email \
    --in-reply-to='CAJcAo8v+o-JPOZcfyis3itghrO6w8Szsw-SuiEWeUypBT2=qgA@mail.gmail.com' \
    --to=samologist@gmail.com \
    --cc=Elwood151@web.de \
    --cc=emacs-orgmode@gnu.org \
    /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/org-mode.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).