From: Felipe Balbi <balbi@kernel.org>
To: emacs-orgmode@gnu.org
Subject: org-habit and hourly repeats
Date: Wed, 18 Jan 2023 08:38:46 +0200 [thread overview]
Message-ID: <87ilh4mjnt.fsf@balbi.sh> (raw)
Hi,
I'm trying to start using `org-habit' but I noticed that hourly repeats
are not properly parsed by `org-habit-duration-to-days', however that's
a valid use case --- e.g. drinking water, medicine schedule,
physiotherapy sessions during the day, periodically practicing a new
language. For example, here's an easy TODO item that reproduces the
problem:
8< -------------------- cut here --------------------
* TODO Foo
SCHEDULED: <2023-01-18 Wed 11:00 .+8h>
:PROPERTIES:
:STYLE: habit
:END:
8< -------------------- cut here --------------------
It appears that a simple solution would be modify
`org-habit-duration-to-days' to accept the `h' suffix and set it to a
fraction of a day, something like:
8< -------------------- cut here --------------------
(defun org-habit-duration-to-days (ts)
(if (string-match "\\([0-9]+\\)\\([hdwmy]\\)" ts)
;; lead time is specified.
(floor (* (string-to-number (match-string 1 ts))
(cdr (assoc (match-string 2 ts)
'(("h" . 0.042) ("d" . 1)
("w" . 7) ("m" . 30.4)
("y" . 365.25))))))
(error "Invalid duration string: %s" ts)))
8< -------------------- cut here --------------------
Would something like this be an acceptable solution?
--
balbi
next reply other threads:[~2023-01-18 13:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-18 6:38 Felipe Balbi [this message]
2023-01-19 10:48 ` org-habit and hourly repeats Ihor Radchenko
2023-01-19 10:58 ` Felipe Balbi
2023-01-19 11:04 ` Ihor Radchenko
2023-01-19 11:06 ` Felipe Balbi
2023-01-19 11:13 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ilh4mjnt.fsf@balbi.sh \
--to=balbi@kernel.org \
--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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.