tzc
tzc copied to clipboard
When there is no selection, convert time or timestamp at point
When using the package commands to convert times, it took me a few tries until I realized I have to select the time or timestamp.
It would be a helpful convenience if the conversion commands could work "at-point", I think other packages have trained us to expect that behaviour.
Agreed, that'd be great. I was expecting tzc-convert-org-time-stamp-at-mark
to work that way.
It's possible to get the timestamp at point with
(let* ((element (org-element-context))
(type (org-element-type element)))
(if (eq type 'timestamp)
(org-element-property :raw-value element) ; this will return e.g. "<2024-09-05 to. 11:30-12:00 +1w>"
(message "No timestamp at point")))
You can also use :begin
and :end
instead of :raw-value
if you prefer to work with buffer positions.