aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2004-10-23 16:13:06 +0000
committerGlenn Morris2004-10-23 16:13:06 +0000
commitf2aa54499ec7a97d599dba2f5ce8383b2c4ef04a (patch)
tree21467606c15a7c385b0515e29e55696fdea73d65
parent45af6ed7f792822b36534c1b3df7b413bf74a258 (diff)
downloademacs-f2aa54499ec7a97d599dba2f5ce8383b2c4ef04a.tar.gz
emacs-f2aa54499ec7a97d599dba2f5ce8383b2c4ef04a.zip
From Ulf Jasper <ulf.jasper@web.de>:
(icalendar--weekday-array): New constant. (icalendar-weekdayabbrev-table) (icalendar-monthnumber-table): Delete. (icalendar--get-month-number): Use calendar-month-name-array. (icalendar--get-weekday-number): New function. (icalendar--get-weekday-abbrev) Use calendar-day-name-array. (icalendar-export-region): Handle multi-line entries. (icalendar--convert-ical-to-diary): Use calendar-day-name-array.
-rw-r--r--lisp/calendar/icalendar.el87
1 files changed, 47 insertions, 40 deletions
diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el
index 9e5f2b93c22..5f581e1d74a 100644
--- a/lisp/calendar/icalendar.el
+++ b/lisp/calendar/icalendar.el
@@ -39,6 +39,8 @@
39;; Added icalendar-export-region. 39;; Added icalendar-export-region.
40;; The import and export commands do not clear their target file, 40;; The import and export commands do not clear their target file,
41;; but append their results to the target file. 41;; but append their results to the target file.
42;; I18n-problems fixed -- use calendar-(month|day)-name-array.
43;; Fixed problems with export of multi-line diary entries.
42 44
43;; 0.06: Bugfixes regarding icalendar-import-format-*. 45;; 0.06: Bugfixes regarding icalendar-import-format-*.
44;; Fix in icalendar-convert-diary-to-ical -- thanks to Philipp 46;; Fix in icalendar-convert-diary-to-ical -- thanks to Philipp
@@ -167,31 +169,7 @@ longer than they are."
167;; NO USER SERVICABLE PARTS BELOW THIS LINE 169;; NO USER SERVICABLE PARTS BELOW THIS LINE
168;; ====================================================================== 170;; ======================================================================
169 171
170(defconst icalendar-weekdayabbrev-table 172(defconst icalendar--weekday-array ["SU" "MO" "TU" "WE" "TH" "FR" "SA"])
171 '(("mon\\(day\\)?" . "MO")
172 ("tue\\(sday\\)?" . "TU")
173 ("wed\\(nesday\\)?" . "WE")
174 ("thu\\(rsday\\)?" . "TH")
175 ("fri\\(day\\)?" . "FR")
176 ("sat\\(urday\\)?" . "SA")
177 ("sun\\(day\\)?" . "SU"))
178 "Translation table for weekdays.")
179
180(defconst icalendar-monthnumber-table
181 '(("^jan\\(uar\\)?y?$" . 1)
182 ("^feb\\(ruar\\)?y?$" . 2)
183 ("^mar\\(ch\\)?\\|märz$" . 3)
184 ("^apr\\(il\\)?$" . 4)
185 ("^ma[iy]$" . 5)
186 ("^jun[ie]?$" . 6)
187 ("^jul[iy]?$" . 7)
188 ("^aug\\(ust\\)?$" . 8)
189 ("^sep\\(tember\\)?$" . 9)
190 ("^o[ck]t\\(ober\\)?$" . 10)
191 ("^nov\\(ember\\)?$" . 11)
192 ("^de[cz]\\(ember\\)?$" . 12))
193 "Regular expressions for month names.
194Currently this matches only German and English.")
195 173
196(defvar icalendar-debug nil ".") 174(defvar icalendar-debug nil ".")
197 175
@@ -511,18 +489,47 @@ Note that this silently ignores seconds."
511 489
512(defun icalendar--get-month-number (monthname) 490(defun icalendar--get-month-number (monthname)
513 "Return the month number for the given MONTHNAME." 491 "Return the month number for the given MONTHNAME."
514 (save-match-data 492 (catch 'found
515 (let ((case-fold-search t)) 493 (let ((num 1)
516 (assoc-default monthname icalendar-monthnumber-table 494 (m (downcase monthname)))
517 'string-match)))) 495 (mapc (lambda (month)
496 (let ((mm (downcase month)))
497 (if (or (string-equal mm m)
498 (string-equal (substring mm 0 3) m))
499 (throw 'found num))
500 (setq num (1+ num))))
501 calendar-month-name-array))
502 ;; Error:
503 -1))
504
505(defun icalendar--get-weekday-number (abbrevweekday)
506 "Return the number for the ABBREVWEEKDAY."
507 (catch 'found
508 (let ((num 0)
509 (aw (downcase abbrevweekday)))
510 (mapc (lambda (day)
511 (let ((d (downcase day)))
512 (if (string-equal d aw)
513 (throw 'found num))
514 (setq num (1+ num))))
515 icalendar--weekday-array))
516 ;; Error:
517 -1))
518 518
519(defun icalendar--get-weekday-abbrev (weekday) 519(defun icalendar--get-weekday-abbrev (weekday)
520 "Return the abbreviated WEEKDAY." 520 "Return the abbreviated WEEKDAY."
521 ;;FIXME: ISO-like(?). 521 (catch 'found
522 (save-match-data 522 (let ((num 0)
523 (let ((case-fold-search t)) 523 (w (downcase weekday)))
524 (assoc-default weekday icalendar-weekdayabbrev-table 524 (mapc (lambda (day)
525 'string-match)))) 525 (let ((d (downcase day)))
526 (if (or (string-equal d w)
527 (string-equal (substring d 0 3) w))
528 (throw 'found (aref icalendar--weekday-array num)))
529 (setq num (1+ num))))
530 calendar-day-name-array))
531 ;; Error:
532 "??"))
526 533
527(defun icalendar--datestring-to-isodate (datestring &optional day-shift) 534(defun icalendar--datestring-to-isodate (datestring &optional day-shift)
528 "Convert diary-style DATESTRING to iso-style date. 535 "Convert diary-style DATESTRING to iso-style date.
@@ -648,7 +655,7 @@ FExport diary data into iCalendar file: ")
648 (save-excursion 655 (save-excursion
649 (goto-char min) 656 (goto-char min)
650 (while (re-search-forward 657 (while (re-search-forward
651 "^\\([^ \t\n].*\\)\\(\n[ \t].*\\)*" max t) 658 "^\\([^ \t\n].*\\)\\(\\(\n[ \t].*\\)*\\)" max t)
652 (setq entry-main (match-string 1)) 659 (setq entry-main (match-string 1))
653 (if (match-beginning 2) 660 (if (match-beginning 2)
654 (setq entry-rest (match-string 2)) 661 (setq entry-rest (match-string 2))
@@ -1171,13 +1178,13 @@ written into the buffer ` *icalendar-errors*'."
1171 ;; weekly and not all-day 1178 ;; weekly and not all-day
1172 (let* ((byday (cadr (assoc 'BYDAY rrule-props))) 1179 (let* ((byday (cadr (assoc 'BYDAY rrule-props)))
1173 (weekday 1180 (weekday
1174 (cdr (rassoc 1181 (icalendar--get-weekday-number byday)))
1175 byday
1176 icalendar-weekdayabbrev-table))))
1177 (icalendar--dmsg "weekly not-all-day") 1182 (icalendar--dmsg "weekly not-all-day")
1178 (if weekday 1183 (if (> weekday -1)
1179 (setq diary-string 1184 (setq diary-string
1180 (format "%s %s%s%s" weekday 1185 (format "%s %s%s%s"
1186 (aref calendar-day-name-array
1187 weekday)
1181 start-t (if end-t "-" "") 1188 start-t (if end-t "-" "")
1182 (or end-t ""))) 1189 (or end-t "")))
1183 ;; FIXME!!!! 1190 ;; FIXME!!!!