2016-06-28 21 views
0

如何定义希伯来周年纪念日(如生日)以显示在组织议程?最好的办法是通过BBDB做到这一点。到目前为止,我设法向BBDB添加周年纪念日/生日,并将其显示在org-agenda中。现在我需要转到下一步,并将这些日期提供为希伯来语日期。在日记模式中,日期看起来像HSivan 17,5766。但是,如果我将其插入BBDB,如anniversary: HSivan 17, 5776 birthday - 我在尝试生成议程视图时遇到错误:bad-sexp at line 5 /path/to/agenda.org (org-bbdb-anniversaries)。也许还有其他方法(没有BBDB),也许我可以直接在.org文件中列出它们?如何定义希伯来周年纪念日出现在组织议程中?

回答

1

在一般情况下,组织模式不处理好(或全部)具有比其他日历ISO为主,西部日历。

如果要在bbdb中存储不同格式的日期,可以使用 自定义org-bbdb-extract-date-fun。你将不得不编写自己的函数来解析希伯来语日期并返回(月日)。

这将允许您使用希伯来语日期使用bbdb数据库,但它会而不是存在,例如,使用希伯来语日期的日程表输出。这是一个更难的问题,特别是因为ISO日历假设渗透到组织模式代码库。

编辑:下面是需要一个字符串,如“Heshvan 17日,5776”作为参数并产生(月,日,年)的函数元组组织可以使用:

;;; 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. 
+0

我很满意这个纪念日将在ISO日历上显示的事实,我唯一需要的是它将显示在对应于希伯来语日期的ISO日期中。 – user1876484

+0

然后按照上面的建议书写函数应该就足够了。你可以在'org-bbdb-anniv-extract-date'上建模,但不是采用'YYYY-MM-DD'形式的字符串,而是采用希伯来语日期字符串。您可能可以使用日历功能进行转换,但这超出了我的知识范围。 – Nick

+1

cal-hebrew.el包含以下月份名称数组:'(defconst calendar-hebrew-month-name-array-common-year [“Nisan”“Iyar”“Sivan”“Tammuz”“Av”“Elul” “Tishri” “Heshvan”“Kislev”“Teveth”“Shevat”“Adar”] “字符串列出希伯来语月份的名称在一个共同的年份。几个月用整数表示;假设基于0,“Heshvan”是7,所以Heshvan 17,5776将由(7 17 5776)表示。这个转换是通过'(calendar-gregorian-from-absolute(calendar-hebrew-to-absolute'(7 17 5776)))'来完成的,它给出了(2015年9月30日)。 – Nick

0

我相信你可以把这个在您的.emacs解决您的BBDB问题:

(require 'org-bbdb) 
+0

添加此行没有解决问题。其实它是/正在为格里高利日期工作。我只需要在日程视图生成期间将希伯来语日期转换为格里高利的方法。有趣的事情:如果我写上'周年纪念:HSivan 23,5776生日',我会得到上面的错误,但是如果我用ISO格式写出来,比如'周年纪念:H5776-03-23生日',我没有错误,但生日是没有显示。我刚刚发现[类似问题的中文](http://stackoverflow.com/questions/36557402/viewing-chinese-korean-lunar-birthday-on-org-agenda)。 – user1876484

+0

对不起,但我对这个问题所知甚少。您可以尝试查看Emacs文档:https://www.gnu.org/software/emacs/manual/html_node/emacs/Other-Calendars.html#Other-Calendars,或者尝试阅读希伯来语日历的源代码,对于我位于'/ usr/local/share/emacs/24.4/lisp/calendar/cal-hebrew.el.gz'。 –

相关问题