/[emacs]/emacs/lisp/calendar/icalendar.el
ViewVC logotype

Diff of /emacs/lisp/calendar/icalendar.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2.2.2 by miles, Fri Oct 22 10:13:52 2004 UTC revision 1.2.2.3 by miles, Wed Oct 27 05:42:04 2004 UTC
# Line 39  Line 39 
39  ;;        Added icalendar-export-region.  ;;        Added icalendar-export-region.
40  ;;        The import and export commands do not clear their target file,  ;;        The import and export commands do not clear their target file,
41  ;;        but append their results to the target file.  ;;        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.
44    
45  ;;  0.06: Bugfixes regarding icalendar-import-format-*.  ;;  0.06: Bugfixes regarding icalendar-import-format-*.
46  ;;        Fix in icalendar-convert-diary-to-ical -- thanks to Philipp  ;;        Fix in icalendar-convert-diary-to-ical -- thanks to Philipp
# Line 167  longer than they are." Line 169  longer than they are."
169  ;; NO USER SERVICABLE PARTS BELOW THIS LINE  ;; NO USER SERVICABLE PARTS BELOW THIS LINE
170  ;; ======================================================================  ;; ======================================================================
171    
172  (defconst icalendar-weekdayabbrev-table  (defconst icalendar--weekday-array ["SU" "MO" "TU" "WE" "TH" "FR" "SA"])
   '(("mon\\(day\\)?"    . "MO")  
     ("tue\\(sday\\)?"   . "TU")  
     ("wed\\(nesday\\)?" . "WE")  
     ("thu\\(rsday\\)?"  . "TH")  
     ("fri\\(day\\)?"    . "FR")  
     ("sat\\(urday\\)?"  . "SA")  
     ("sun\\(day\\)?"    . "SU"))  
   "Translation table for weekdays.")  
   
 (defconst icalendar-monthnumber-table  
   '(("^jan\\(uar\\)?y?$"       . 1)  
     ("^feb\\(ruar\\)?y?$"      . 2)  
     ("^mar\\(ch\\)?\\|märz$"   . 3)  
     ("^apr\\(il\\)?$"          . 4)  
     ("^ma[iy]$"                . 5)  
     ("^jun[ie]?$"              . 6)  
     ("^jul[iy]?$"              . 7)  
     ("^aug\\(ust\\)?$"         . 8)  
     ("^sep\\(tember\\)?$"      . 9)  
     ("^o[ck]t\\(ober\\)?$"     . 10)  
     ("^nov\\(ember\\)?$"       . 11)  
     ("^de[cz]\\(ember\\)?$"    . 12))  
   "Regular expressions for month names.  
 Currently this matches only German and English.")  
173    
174  (defvar icalendar-debug nil ".")  (defvar icalendar-debug nil ".")
175    
# Line 511  Note that this silently ignores seconds. Line 489  Note that this silently ignores seconds.
489    
490  (defun icalendar--get-month-number (monthname)  (defun icalendar--get-month-number (monthname)
491    "Return the month number for the given MONTHNAME."    "Return the month number for the given MONTHNAME."
492    (save-match-data    (catch 'found
493      (let ((case-fold-search t))      (let ((num 1)
494        (assoc-default monthname icalendar-monthnumber-table            (m (downcase monthname)))
495                       'string-match))))        (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    
519  (defun icalendar--get-weekday-abbrev (weekday)  (defun icalendar--get-weekday-abbrev (weekday)
520    "Return the abbreviated WEEKDAY."    "Return the abbreviated WEEKDAY."
521    ;;FIXME: ISO-like(?).    (catch 'found
522    (save-match-data      (let ((num 0)
523      (let ((case-fold-search t))            (w (downcase weekday)))
524        (assoc-default weekday icalendar-weekdayabbrev-table        (mapc (lambda (day)
525                       'string-match))))                (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        "??"))
533    
534  (defun icalendar--datestring-to-isodate (datestring &optional day-shift)  (defun icalendar--datestring-to-isodate (datestring &optional day-shift)
535    "Convert diary-style DATESTRING to iso-style date.    "Convert diary-style DATESTRING to iso-style date.
# Line 648  FExport diary data into iCalendar file: Line 655  FExport diary data into iCalendar file:
655      (save-excursion      (save-excursion
656        (goto-char min)        (goto-char min)
657        (while (re-search-forward        (while (re-search-forward
658                "^\\([^ \t\n].*\\)\\(\n[ \t].*\\)*" max t)                "^\\([^ \t\n].*\\)\\(\\(\n[ \t].*\\)*\\)" max t)
659          (setq entry-main (match-string 1))          (setq entry-main (match-string 1))
660          (if (match-beginning 2)          (if (match-beginning 2)
661              (setq entry-rest (match-string 2))              (setq entry-rest (match-string 2))
# Line 1171  written into the buffer ` *icalendar-err Line 1178  written into the buffer ` *icalendar-err
1178                           ;; weekly and not all-day                           ;; weekly and not all-day
1179                           (let* ((byday (cadr (assoc 'BYDAY rrule-props)))                           (let* ((byday (cadr (assoc 'BYDAY rrule-props)))
1180                                  (weekday                                  (weekday
1181                                   (cdr (rassoc                                   (icalendar--get-weekday-number byday)))
                                        byday  
                                        icalendar-weekdayabbrev-table))))  
1182                             (icalendar--dmsg "weekly not-all-day")                             (icalendar--dmsg "weekly not-all-day")
1183                             (if weekday                             (if (> weekday -1)
1184                                 (setq diary-string                                 (setq diary-string
1185                                       (format "%s %s%s%s" weekday                                       (format "%s %s%s%s"
1186                                                 (aref calendar-day-name-array
1187                                                       weekday)
1188                                               start-t (if end-t "-" "")                                               start-t (if end-t "-" "")
1189                                               (or end-t "")))                                               (or end-t "")))
1190                               ;; FIXME!!!!                               ;; FIXME!!!!

Legend:
Removed from v.1.2.2.2  
changed lines
  Added in v.1.2.2.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26