emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* help with sexp in org-capture-template
       [not found] <mailman.57.1585670407.11838.emacs-orgmode@gnu.org>
@ 2020-04-01  5:10 ` Bala Ramadurai
  2020-04-05 20:36   ` Kyle Meyer
  0 siblings, 1 reply; 2+ messages in thread
From: Bala Ramadurai @ 2020-04-01  5:10 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 567 bytes --]

Hello All,
  Hope everyone's safe.

I am working on a org-capture-template and one of the entries is a date (30
days later) I want in European format.

My solution is this:
| *Due Date*: %(concat (substring (org-read-date nil nil "+30d") 8 10) "-"
(substring(org-read-date nil nil "+30d") 5 7) "-" (substring(org-read-date
nil nil "+30d") 0 4)) |

Although this does the job, it is extremely inelegant and only reflects my
poor knowledge in elisp.

Can any of you please help me in making this code better?

Thanks and have a safe day!
Bala

http://balaramadurai.net

[-- Attachment #2: Type: text/html, Size: 1107 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: help with sexp in org-capture-template
  2020-04-01  5:10 ` help with sexp in org-capture-template Bala Ramadurai
@ 2020-04-05 20:36   ` Kyle Meyer
  0 siblings, 0 replies; 2+ messages in thread
From: Kyle Meyer @ 2020-04-05 20:36 UTC (permalink / raw)
  To: Bala Ramadurai; +Cc: emacs-orgmode

Hi Bala,

Bala Ramadurai <nikimonikado@gmail.com> writes:

> I am working on a org-capture-template and one of the entries is a date (30
> days later) I want in European format.
>
> My solution is this:
> | *Due Date*: %(concat (substring (org-read-date nil nil "+30d") 8 10) "-"
> (substring(org-read-date nil nil "+30d") 5 7) "-" (substring(org-read-date
> nil nil "+30d") 0 4)) |
>
> Although this does the job, it is extremely inelegant and only reflects my
> poor knowledge in elisp.
>
> Can any of you please help me in making this code better?

Does the job is the important part :)  One thing you could do that'd
make it a little nicer to my eyes is let-binding

  (org-read-date nil nil "+30d")

result to avoid calling it three times.

Here's another approach:

    (format-time-string "%d-%m-%Y" (time-add (days-to-time 30) nil))


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-05 20:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.57.1585670407.11838.emacs-orgmode@gnu.org>
2020-04-01  5:10 ` help with sexp in org-capture-template Bala Ramadurai
2020-04-05 20:36   ` Kyle Meyer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).