changeset 99284:b39c4aef1848

icalendar: uid-creation improved
author Ulf Jasper <ulf.jasper@web.de>
date Fri, 31 Oct 2008 18:27:05 +0000
parents 563e71d339f2
children 26e573b758f1
files lisp/calendar/icalendar.el
diffstat 1 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/calendar/icalendar.el	Fri Oct 31 15:57:31 2008 +0000
+++ b/lisp/calendar/icalendar.el	Fri Oct 31 18:27:05 2008 +0000
@@ -877,6 +877,21 @@
 (defalias 'icalendar-convert-diary-to-ical 'icalendar-export-file)
 (make-obsolete 'icalendar-convert-diary-to-ical 'icalendar-export-file)
 
+(defvar icalendar--uid-count 0
+  "Auxiliary counter for creating unique ids.")
+
+(defun icalendar--create-uid ()
+  "Create a unique identifier.
+Use `current-time' and a counter to create unique ids. The
+counter is necessary for systems which do not provide resolution
+finer than a second."
+  (setq icalendar--uid-count (1+ icalendar--uid-count))
+  (format "emacs%d%d%d%d"
+          (car (current-time))
+          (cadr (current-time))
+          (car (cddr (current-time)))
+          icalendar--uid-count))
+
 ;;;###autoload
 (defun icalendar-export-region (min max ical-filename)
   "Export region in diary file to iCalendar format.
@@ -916,10 +931,8 @@
         (if (match-beginning 2)
             (setq entry-rest (match-string 2))
           (setq entry-rest ""))
-        (setq header (format "\nBEGIN:VEVENT\nUID:emacs%d%d%d"
-                             (car (current-time))
-                             (cadr (current-time))
-                             (car (cddr (current-time)))))
+        (setq header (format "\nBEGIN:VEVENT\nUID:%s"
+                             (icalendar--create-uid)))
         (condition-case error-val
             (progn
               (setq contents-n-summary