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: Felipe Balbi
Subject: Re: org-habit and hourly repeats
Date: Thu, 19 Jan 2023 12:58:09 +0200

Hi,

On Thu, Jan 19, 2023 at 12:47 PM Ihor Radchenko <yantar92@posteo.net> wrote:
>
> 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/

That's very interesting, because repeated tasks clearly mention hourly repeats:

https://orgmode.org/manual/Repeated-tasks.html

"You can use yearly, monthly, weekly, daily and hourly repeat cookies by
using the ‘y’, ‘m’, ‘w’, ‘d’ and ‘h’ letters."

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

Do you mind expanding on this? Just generally curious, really.

-- 
balbi



reply via email to

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