Michael Game Dev via "General discussions about Org-mode."
<emacs-orgmode@gnu.org> writes:

> I'm trying to use org-capture templates (file+datetree+prompt) to enter the 
> time I spend on things at work. I want to have the date and begin and end 
> times in the note added without re-selecting the date.

Note that file+datetree+prompt is an obsolete specification.
You should use file+olp+datetree with :time-prompt property.

> The suggestion was to use %T, but I noticed the end time was cut off. The 
> other user in the thread sent this: 
> I dug into org-capture-fill-template, and discovered that the code handling 
> the %T placeholder uses a (let* ((org-end-time-was-given nil))) to suppress 
> the end-time.

This sounds like a rather unusual use case.
According to the documentation,

 :time-prompt        Prompt for a date/time to be used for date/week trees
                     and when filling the template.

It does not talk about time or date ranges.

In fact,

  %t          Time stamp, date only.  The time stamp is the current
              time, except when called from agendas with
              `\\[org-agenda-capture]' or with
              `org-capture-use-agenda-date' set.
  %T          Time stamp as above, with date and time.

also says nothing about ranges.

Your use case is simply not supported in the way you attempted.

> I was curious if this was something that could be changed, or if we could get 
> a different placeholder that could have end times?

It might be changed. In fact, I do not see why we cannot (in principle)
support your use case - if :time-prompt answer contains a range, it
gotta be intentional, and your expectation makes sense.

But that would be a non-trivial change. %tTuU template expansion is
coded in `org-capture-fill-template' using `format-time-string' and
simply does not consider ranges. Furthermore, :default-time, which is
used to set "current" time internally in the capture template, does not
have any notion of ranges. So, we should introduce some new capture
property for "end time", and then check it during template expansion.

I'd call implementing such a new feature as moderately difficult task
(mostly because one will need to make sure that nothing is broken as a
result).

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