Aaron Madlon-Kay <[email protected]> writes:

> Hello. I noticed the following behavior and wondered if it was correct or 
> unintentional.
>
> [[BEFORE]]
>
> * TODO foo
>   SCHEDULED: <2025-11-14 Fri 10:00-11:00 .+1h>
>
> * TODO bar
>   SCHEDULED: <2025-11-14 Fri 20:00-21:00 .+1h>
>
> [[AFTER]]
>
> * TODO foo
>   SCHEDULED: <2025-11-14 Fri 22:53 .+1h>
>
> * TODO bar
>   SCHEDULED: <2025-11-14 Fri 22:53-23:53 .+1h>

Confirmed.

> Note that the end time of foo has been discarded. I tried following
> the logic of org-auto-repeat-maybe, org-timestamp-change, etc., but
> couldn’t quite understand if this was intended.

Most of that code was written before hour repeater were added. So, the
logic may simply not consider this scenario.

> Breaking on org-timestamp-change and then doing org-shiftright on foo shows 
> that a first pass is done to change it to something like <2025-11-14 Fri 
> 21:59-23:89 .+1h>. Note the invalid end time (23:89). Then in a second pass, 
> the invalid time is discarded. Indeed, you can induce an invalid time by 
> manually placing the point at the start of a timestamp and executing 
> (org-timestamp-change n ‘minute) with sufficiently large n. A key part of the 
> invalid minutes value is in org-modify-ts-extra at the line
>
>       (when (> minute 59) (setq minute (- minute 60) hour (1+ hour)))
>
> which doesn’t seem to handle the case where the minutes is too large by more 
> than 60 minutes.
>
> Is this intentional?

Most likely not.

I think something like
-       (when (< minute 0) (setq minute (+ minute 60) hour (1- hour)))
-       (when (> minute 59) (setq minute (- minute 60) hour (1+ hour)))
+       (while (< minute 0) (setq minute (+ minute 60) hour (1- hour)))
+       (while (> minute 59) (setq minute (- minute 60) hour (1+ hour)))
will work

But there will probably be similar issues with hours overflowing 0..24 range.

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
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