changeset 52231:9529ff0804c2

Edward M. Reingold <reingold@emr.cs.iit.edu> (calendar-goto-day-of-year): New function.
author Glenn Morris <rgm@gnu.org>
date Sun, 17 Aug 2003 22:49:46 +0000
parents 75388c0f3104
children e1debf3a5153
files lisp/calendar/cal-move.el
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/calendar/cal-move.el	Sun Aug 17 22:48:54 2003 +0000
+++ b/lisp/calendar/cal-move.el	Sun Aug 17 22:49:46 2003 +0000
@@ -327,6 +327,27 @@
   (calendar-cursor-to-visible-date date)
   (run-hooks 'calendar-move-hook))
 
+(defun calendar-goto-day-of-year (year day &optional noecho)
+  "Move cursor to YEAR, DAY number; echo DAY/YEAR unless NOECHO is t.
+Negative DAY counts backward from end of year."
+  (interactive
+   (let* ((year (calendar-read
+                 "Year (>0): "
+                 (lambda (x) (> x 0))
+                 (int-to-string (extract-calendar-year
+                                 (calendar-current-date)))))
+          (last (if (calendar-leap-year-p year) 366 365))
+          (day (calendar-read
+                (format "Day number (+/- 1-%d): " last)
+                '(lambda (x) (and (<= 1 (abs x)) (<= (abs x) last))))))
+     (list year day)))
+  (calendar-goto-date
+   (calendar-gregorian-from-absolute
+    (if (< 0 day)
+        (+ -1 day (calendar-absolute-from-gregorian (list 1 1 year)))
+      (+ 1 day (calendar-absolute-from-gregorian (list 12 31 year))))))
+  (or noecho (calendar-print-day-of-year)))
+
 (provide 'cal-move)
 
 ;;; cal-move.el ends here