Question

I want to have timestamps for my TODOs in the following format:

<%d/%m/%Y %a [%H:%M]>

In my .emacs I have the following:

(custom-set-variables
 '(org-display-custom-times t)
 '(org-time-stamp-custom-formats (quote ("<%d/%m/%Y %a [%H:%M]>" . "<%d %m %Y  %a [%H:%M]>"))))  

Checking the value of that variable via

M-x describe-variable RET org-time-stamp-custom-formats

shows:

org-time-stamp-custom-formats is a variable defined in `org.el'.
Its value is ("<%d/%m/%Y %a [%H:%M]>" . "<%d %m %Y  %a [%H:%M]>")

Documentation:
Custom formats for time stamps.  See `format-time-string' for the syntax.
These are overlaid over the default ISO format if the variable
`org-display-custom-times' is set.  Time like %H:%M should be at the
end of the second format.  The custom formats are also honored by export
commands, if custom time display is turned on at the time of export.

You can customize this variable.    

However, when going in action (by pressing C-c C-s) I get always my TODOs scheduled at 00:00:

** TODO SCHEDULED: <22/04/2014 Tue [00:00]> 

Something is going wrong in my config I suppose. How can I correct my configuration of timestamps?

Était-ce utile?

La solution

How to make it work

  1. Remove the [%H:%M] portion from the first element of org-time-stamp-custom-formats. The relevant parts of your config file should look like this:

    (custom-set-variables
     ;; ...
     '(org-time-stamp-custom-formats (quote ("<%d/%m/%Y %a>" . "<%d %m %Y  %a [%H:%M]>"))))  
    
  2. To schedule an item,

    • hit C-c C-s (as usual)
    • enter a time, e.g. 1pm, 10am, 9:00, or 18:00
    • hit RET

Explanation

As far as I can tell from skimming documentation and associated portions of the org-mode source, org-mode uses the first element of

("<%d/%m/%Y %a [%H:%M]>" . "<%d %m %Y  %a [%H:%M]>")

for formatting dates that do not include a time, while the second element is used for formatting dates that do. So when you do C-c C-s immediately followed by RET without providing a time, org-mode will try to insert a date formatted according to the first element of org-time-stamp-custom-formats. With your current configuration this will fail (in the way you describe) because org-mode doesn't know what to substitute for %H and %M in the format string.

The thing that had me confused (and probably tripped you up as well) when I tried to reproduce the behavior you describe was that the date prompt that comes up when calling org-schedule via C-c C-s does include the (current) time in the correct format...

Credits

  • Answer to a similar question about timestamps for scheduled TODOs.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top