emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Tim Landscheidt <tim@tim-landscheidt.de>
To: emacs-orgmode@gnu.org
Subject: Testing if a scheduled date is prior to another date
Date: Sun, 22 Aug 2021 13:26:18 +0000	[thread overview]
Message-ID: <87a6l9ehl1.fsf@vagabond.tim-landscheidt.de> (raw)

Hi,

in a capture template, I want to test whether the scheduled
date for a specific task is prior to another, calculated
date (and depending on the answer, insert a checkbox or
not).

I can get the scheduled date for the task by:

| (with-current-buffer (find-file-noselect "/path/to/file.org")
|   (save-mark-and-excursion
|     (goto-char
|      (org-find-entry-with-id "TASK_ID"))
|     (org-element-property ':scheduled (org-element-at-point))))

which returns a structure like:

| (timestamp
|  (:type active
|   :raw-value "<2021-08-30 Mo 08:00 .+4d>"
|   :year-start 2021
|   :month-start 8
|   :day-start 30
|   :hour-start 8
|   :minute-start 0
|   :year-end 2021
|   :month-end 8
|   :day-end 30
|   :hour-end 8
|   :minute-end 0
|   :begin 436166
|   :end 436192
|   :post-blank 0
|   :repeater-type restart
|   :repeater-value 4
|   :repeater-unit day))

However, comparing this value with org-time< & Co. is futile
as org-2ft always returns 0.

Before I wade through the various functions to build a con-
version chain, what is the best practice to compare time-
stamp values with dates?  (And if there is an org-mode func-
tion that checks if the task at point is scheduled prior to
another date, I'd appreciate pointers as well :-).)

TIA,
Tim



             reply	other threads:[~2021-08-22 13:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-22 13:26 Tim Landscheidt [this message]
2021-08-30 14:59 ` Testing if a scheduled date is prior to another date Ihor Radchenko

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=87a6l9ehl1.fsf@vagabond.tim-landscheidt.de \
    --to=tim@tim-landscheidt.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).