导出时的组织模式时间戳格式

Mit*_*ops 8 emacs datetime org-mode

我正在将我的org-mode文件导出到LaTeX,并经常使用C-c .时间戳作为顶级标题作为滚动日记.

但是,当它导出为PDF时,<2014-04-25 Fri>看起来有点滑稽.是否存在将时间戳转换为某种格式化日期的常规设置,例如"2014年4月25日星期五"或其他一些常见的日期字符串格式?

我看了一下,明白有几种方法可以输入日期,但我想也必须有输出格式.我也看到,有一个出口时间戳设置在这里,

<:
Toggle inclusion of any time/date active/inactive stamps (org-export-with-timestamps). 
Run Code Online (Sandbox Code Playgroud)

但目前还不清楚实施意味着什么.

art*_*can 5

尝试这个:

(let ((org-time-stamp-custom-formats
       '("<%A, %B %d, %Y>" . "<%A, %B %d, %Y %H:%M>"))
      (org-display-custom-times 't))
  (org-latex-export-to-latex))
Run Code Online (Sandbox Code Playgroud)

更新:如果<>要从输出字符串中删除括号,则必须修补函数org-translate-time。正常行为:

(let ((org-time-stamp-custom-formats
       '("<%A, %B %d, %Y>" . "<%A, %B %d, %Y %H:%M>"))
      (org-display-custom-times 't))
  (org-translate-time "<2014-04-29 Tu.>")) => "<Tuesday, April 29, 2014>"
Run Code Online (Sandbox Code Playgroud)

具有此处的修补功能https://gist.github.com/boykov/11387660

(let ((org-time-stamp-custom-formats
       '("<%A, %B %d, %Y>" . "<%A, %B %d, %Y %H:%M>"))
      (org-display-custom-times 't))
  (org-translate-time "<2014-04-29 Tu.>")) => "Tuesday, April 29, 2014"
Run Code Online (Sandbox Code Playgroud)

括号<>在功能中进行了硬编码,org-translate-time不能org-time-stamp-custom-formats仅通过固定将其删除。


joo*_*oon 5

org-translate-time您可以通过将以下函数添加到以下内容来删除括号,而不是修补org-export-filter-timestamp-functions:

(defun org-export-filter-timestamp-remove-brackets (timestamp backend info)
  "removes relevant brackets from a timestamp"
  (cond
   ((org-export-derived-backend-p backend 'latex)
    (replace-regexp-in-string "[<>]\\|[][]" "" timestamp))
   ((org-export-derived-backend-p backend 'html)
    (replace-regexp-in-string "&[lg]t;\\|[][]" "" timestamp))))

(eval-after-load 'ox '(add-to-list
                       'org-export-filter-timestamp-functions
                       'org-export-filter-timestamp-remove-brackets))
Run Code Online (Sandbox Code Playgroud)

有关详细信息,请参阅http://endlessparentheses.com/better-time-stamps-in-org-export.html.