emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ebdb 480fc95 02/16: Fix functions for browsing annivers


From: Eric Abrahamsen
Subject: [elpa] externals/ebdb 480fc95 02/16: Fix functions for browsing anniversary dates
Date: Sun, 16 Jun 2019 12:23:06 -0400 (EDT)

branch: externals/ebdb
commit 480fc95ef2cf667845f233e1304af3320dea79f6
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>

    Fix functions for browsing anniversary dates
    
    * ebdb.el (ebdb-field-anniversary-calendar,
      ebdb-field-anniversary-agenda): Both of these should show the *next*
      upcoming occurrence of the anniversary. Also, there was a bug in the
      agenda function: it expects a string, not a list.
---
 ebdb.el | 39 ++++++++++++++++++++++-----------------
 1 file changed, 22 insertions(+), 17 deletions(-)

diff --git a/ebdb.el b/ebdb.el
index 57fb8ca..d094d40 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -2917,30 +2917,35 @@ or actual image data."
                                               (field ebdb-field-anniversary))
   "Go to the date of anniversary FIELD in the calendar.
 If FIELD doesn't specify a year, use the current year."
-  ;; This and the next function should be rethought.  Do people really
-  ;; want to look at the original date?  Won't they usually want to
-  ;; see the most recent, or the upcoming, occurrence of the date?
-  (let ((date (slot-value field 'date)))
-   (calendar)
-   (calendar-goto-date
-    (if (nth 2 date)
-       date
-      (pcase-let ((`(,month ,day) date)
-                 (cur-year (nth 5 (decode-time (current-time)))))
-       (list month day cur-year))))))
+  (let* ((date (slot-value field 'date))
+        (this-year (nth 5 (decode-time (current-time))))
+        (year (+ this-year
+                 ;; If this year's occurrence is already in the past,
+                 ;; use next year's.
+                 (if (time-less-p
+                      (encode-time
+                       1 1 1 (nth 1 date) (nth 0 date) this-year)
+                      nil)
+                     1 0))))
+    (calendar)
+    (calendar-goto-date
+     (append (seq-subseq date 0 2) (list year)))))
 
 (cl-defmethod ebdb-field-anniversary-agenda ((_record ebdb-record)
                                             (field ebdb-field-anniversary))
   "Go to the date of anniversary FIELD in the Org agenda.
 If FIELD doesn't specify a year, use the current year."
-  (let ((date (slot-value field 'date)))
+  (let* ((date (slot-value field 'date))
+        (this-year (nth 5 (decode-time (current-time))))
+        (year (+ this-year
+                 (if (time-less-p
+                      (encode-time
+                       1 1 1 (nth 1 date) (nth 0 date) this-year)
+                      nil)
+                     1 0))))
     (org-agenda-list
      nil
-     (calendar-absolute-from-gregorian
-      (if (nth 2 date)
-         date
-       (append date (list (nth 5 (decode-time
-                                  (current-time))))))))))
+     (format "%d-%d-%d" year (nth 0 date) (nth 1 date)))))
 
 (cl-defmethod ebdb-field-anniv-diary-entry ((field ebdb-field-anniversary)
                                            (record ebdb-record))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]