org模式:org时间戳自定义格式显示午夜时间



我希望TODO的时间戳采用以下格式:

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

在我的.emacs中,我有以下内容:

(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]>"))))  

通过检查该变量的值

M-xdescribe-variableRETorg-time-stamp-custom-formats

显示:

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.    

然而,在进行操作时(通过按C-C-s),我的TODO总是安排在00:00:

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

我想我的配置出了问题。如何更正时间戳的配置?

如何使其工作

  1. org-time-stamp-custom-formats的第一个元素中移除[%H:%M]部分。配置文件的相关部分应该如下所示:

    (custom-set-variables
     ;; ...
     '(org-time-stamp-custom-formats (quote ("<%d/%m/%Y %a>" . "<%d %m %Y  %a [%H:%M]>"))))  
    
  2. 要安排项目,

    • 命中C-C C-s(像往常一样)
    • 输入时间,例如1pm10am9:0018:00
    • 命中RET

解释

据我所知,从org-mode源的略读文档和相关部分来看,org-mode使用的第一个元素

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

用于格式化不包含时间的日期,而第二个元素用于格式化包含时间的日期。因此,当您在不提供时间的情况下立即执行C-C C-s时,org-mode将尝试插入根据org-time-stamp-custom-formats第一个元素格式化的日期。在您当前的配置中,这将失败(按照您描述的方式),因为org-mode不知道用什么来替换格式字符串中的%H%M

当我试图重现你描述的行为时,让我感到困惑(可能也让你绊倒了)的是,当通过C-C C-s调用org-schedule时出现的日期提示是否包含正确格式的(当前)时间。。。

学分

  • 回答有关计划TODO的时间戳的类似问题

相关内容

最新更新