emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: org-habit and hourly repeats


From: Ihor Radchenko
Subject: Re: org-habit and hourly repeats
Date: Thu, 19 Jan 2023 10:48:16 +0000

Felipe Balbi <balbi@kernel.org> writes:

> 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:

Habits occurring multiple times a day are not properly supported in
general. See https://list.orgmode.org/orgmode/87leplsggg.fsf@localhost/

> 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?

I afraid that things are not that simple.

-- 
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 via email to

[Prev in Thread] Current Thread [Next in Thread]