如何定义希伯来纪念日在Org议程中出现? [英] How to define Hebrew anniversaries to show up in Org agenda?
问题描述
如何定义希伯来纪念日(如生日)以显示在机构议程中?最好的是通过BBDB。到目前为止,我设法添加周年纪念日/生日到BBDB,并显示在组织日程。现在我需要移动到下一步,并提供这些日期作为希伯来日期。在日记模式中,日期看起来像HSivan 17,5776。但是,如果我插入它BBDB像周年:HSivan 17,5776生日
- 我在尝试生成议程视图时出错: bad-sexp在线5 /path/to/agenda.org(org-bbdb-anniversaries)
。
How to define Hebrew anniversaries (like birthdays) to show up in Org agenda? The best would be to do it through BBDB. So far I managed to add anniversaries/birthdays to BBDB and display them in org-agenda. Now I need to move to the next step and provide those dates as Hebrew dates. In diary mode the dates seem to look like HSivan 17, 5776 . However if I insert it to BBDB like anniversary: HSivan 17, 5776 birthday
- I get error while trying to generate agenda view: bad-sexp at line 5 /path/to/agenda.org (org-bbdb-anniversaries)
. Maybe there are other ways (without BBDB), maybe I can list them in an .org file directly?
推荐答案
一般来说,
如果你想在bbdb中存储不同格式的日期,你可以使用可以
自定义 org-bbdb-extract-date-fun
。您必须编写自己的函数来解析希伯来日期并返回(月日年)。
If you want to store differently formatted dates in bbdb, you can
customize org-bbdb-extract-date-fun
. You'll have to write your own function to parse Hebrew dates and return (month day year).
这将允许您使用希伯来日期使用bbdb数据库,但是它将不呈现,例如,使用希伯来语日期的议程输出。这是一个更难的问题,特别是因为ISO日历假设渗透了组织模式的代码库。
That will allow you to use a bbdb database using Hebrew dates, but it will not present e.g., agenda output using Hebrew dates. That is a much harder problem, particularly because the ISO calendar assumption permeates the org-mode code base.
编辑:这里有一个函数接受一个字符串Heshvan 17, 5776作为参数,并产生一个(月,日,年)元组,org可以使用:
Here's a function that takes a string like "Heshvan 17, 5776" as argument and produces a (month, day, year) tuple that org can use:
;;; This function uses functions and variables defined in calendar.el
;;; and cal-hebrew.el
(require 'calendar)
(require 'cal-hebrew)
(defun org-bbdb-anniv-extract-hebrew-date (date-string)
"Parse the string, assumed to be in the form \"MONTHNAME day,
year\", using Hebrew month names. Day is an integer, roughly
between 1 and 30 (the range depends on the month and the
year), and year is an integer representing a Hebrew calendar
year (roughly 5776 ~= 2015)."
(let* ((date-list (split-string date-string))
(month-name (nth 0 date-list))
(day (string-to-number (nth 1 date-list)))
(year (string-to-number (nth 2 date-list)))
(month-array (if (calendar-hebrew-leap-year-p year)
calendar-hebrew-month-name-array-leap-year
calendar-hebrew-month-name-array-common-year))
(month (cdr (assoc-string
month-name
(calendar-make-alist month-array 1)))))
(calendar-gregorian-from-absolute
(calendar-hebrew-to-absolute (list month day year)))))
;; test: (org-bbdb-anniv-extract-hebrew-date "Heshvan 17, 5776") ==> (10 30 2015)
;; test: (org-bbdb-anniv-extract-hebrew-date "Heshvan 17, 3762") ==> (10 22 1)
;; I hope these are right.
;; To get org-bbdb to use this function to read dates from the BBDB
;; database, instead of the standard org-bbdb-anniv-extract-date, do
;; this:
;; (setq org-bbdb-extract-date-fun #'org-bbdb-anniv-extract-hebrew-date)
;; N.B. *ALL* dates in the BBDB database will be read using this
;; function, so *ALL* of them must be Hebrew calendar dates. There is
;; no provision for dates in different formats. To do that, one would
;; need to write a function that can recognize dates in different
;; formats (probably using heuristics) and then call the right
;; conversion function. That's beyond the scope of this answer.
;; Also, calendrical calculations are notoriously difficult to get
;; right: this is no exception. In particular, the month calculation
;; is probably valid only for dates in the Common Era, i.e. for years
;; >= 3762. cal-hebrew.el has more details. But in any case, no
;; guarantees: if it breaks, you get to keep the pieces.
这篇关于如何定义希伯来纪念日在Org议程中出现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!