【问题标题】:org-mode: org-time-stamp-custom-formats shows midnight timeorg-mode: org-time-stamp-custom-formats 显示午夜时间
【发布时间】:2014-04-22 11:34:54
【问题描述】:

我希望我的 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-x describe-variable RET org-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 C-s),我的 TODO 总是安排在 00:00

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

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

【问题讨论】:

    标签: emacs customization org-mode


    【解决方案1】:

    如何让它工作

    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 后跟 RET 不提供时间时,org-mode 将尝试插入根据 org-time-stamp-custom-formats 的第一个 元素。使用您当前的配置,这将失败(以您描述的方式),因为org-mode 不知道用什么替换格式字符串中的%H%M

    当我试图重现您描述的行为时,让我感到困惑(并且可能也让您感到困惑)的事情是通过 C-c C-s 调用 org-schedule 时出现的日期提示是否以正确的格式包含(当前)时间...

    学分

    • Answer 回答关于计划 TODO 时间戳的类似问题。

    【讨论】:

    • 感谢解决方案 2. 和解释。你提到的有趣的点也让我感到困惑。您会看到正确显示的时间,但未在最终时间戳中使用。但是好的,您提供的解决方案正好满足我的需求。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-06
    • 1970-01-01
    • 2023-03-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多