2

I want a yasnippet to insert an org-mode date and time.

The date should be today's date, but the time should be fixed.

So far my snippet correctly inserts today's date, but not the time:

# -*- mode: snippet; require-final-newline: nil -*-
# name: jdt 
# key: jdt
# binding: direct-keybinding
# --

* TODO meditate
  SCHEDULED: `(let ((x (org-insert-time-stamp (current-time)))))` 

How do I get the time (8:30am) inside the timestamp?

Desired output:

* TODO meditate
  SCHEDULED: <2015-09-18 Fri 8:30am>
  • 1
    It's not an answer to the question you asked, but you might also consider using repeating tasks. That way you get the behavior you want (if it repeats on a fixed schedule), but you also get all the logging of those tasks in one place. – zck Sep 18 '15 at 20:46
3

You can use the format-time-string function to format the time in different ways, for your example this should work:

* TODO meditate
  SCHEDULED: `(format-time-string "<%Y-%m-%d %a 8:30am>" (current-time))`
  • 1
    I don't want the current time, I want a fixed time, 8:30am. Also the let is necessary otherwise yasnippet inserts the timestamp twice. – incandescentman Sep 18 '15 at 19:16
  • Creating a todo list for the day and scheduling all of my tasks for the exact same time (the time I create the list) would be insane. The whole point of scheduling in the first place is so I can plan when to do things throughout the day—meditate at 8:30am, gym at 9:00am, etc. – incandescentman Sep 18 '15 at 19:22
  • 1
    @incandescentman Ok, now I understand. I have updated the post. – clemera Sep 18 '15 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.