aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2004-10-04 23:42:37 +0000
committerGlenn Morris2004-10-04 23:42:37 +0000
commitb76a84cd8644432940235ad5e96482892007a58b (patch)
treed911611e887b58ffc78ea5807e0ab3d9c498bea4
parent554b59cd747c9ce6a8c3f356767dc875f312c105 (diff)
downloademacs-b76a84cd8644432940235ad5e96482892007a58b.tar.gz
emacs-b76a84cd8644432940235ad5e96482892007a58b.zip
Update copyright and maintainer.
(calendar-iso-read-args): New function, for old interactive spec from calendar-goto-iso-date. (calendar-goto-iso-date): Use it. (calendar-goto-iso-week): New function. Suggested by Emilio C. Lopes <eclig@gmx.net>.
-rw-r--r--lisp/calendar/cal-iso.el53
1 files changed, 33 insertions, 20 deletions
diff --git a/lisp/calendar/cal-iso.el b/lisp/calendar/cal-iso.el
index 0d9ad45c7d6..058bdf071d7 100644
--- a/lisp/calendar/cal-iso.el
+++ b/lisp/calendar/cal-iso.el
@@ -1,8 +1,9 @@
1;;; cal-iso.el --- calendar functions for the ISO calendar 1;;; cal-iso.el --- calendar functions for the ISO calendar
2 2
3;; Copyright (C) 1995, 1997 Free Software Foundation, Inc. 3;; Copyright (C) 1995, 1997, 2004 Free Software Foundation, Inc.
4 4
5;; Author: Edward M. Reingold <reingold@cs.uiuc.edu> 5;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
6;; Maintainer: Glenn Morris <gmorris@ast.cam.ac.uk>
6;; Keywords: calendar 7;; Keywords: calendar
7;; Human-Keywords: ISO calendar, calendar, diary 8;; Human-Keywords: ISO calendar, calendar, diary
8 9
@@ -96,27 +97,39 @@ Defaults to today's date if DATE is not given."
96 (message "ISO date: %s" 97 (message "ISO date: %s"
97 (calendar-iso-date-string (calendar-cursor-to-date t)))) 98 (calendar-iso-date-string (calendar-cursor-to-date t))))
98 99
100(defun calendar-iso-read-args (&optional dayflag)
101 "Interactively read the arguments for an iso date command."
102 (let* ((today (calendar-current-date))
103 (year (calendar-read
104 "ISO calendar year (>0): "
105 '(lambda (x) (> x 0))
106 (int-to-string (extract-calendar-year today))))
107 (no-weeks (extract-calendar-month
108 (calendar-iso-from-absolute
109 (1-
110 (calendar-dayname-on-or-before
111 1 (calendar-absolute-from-gregorian
112 (list 1 4 (1+ year))))))))
113 (week (calendar-read
114 (format "ISO calendar week (1-%d): " no-weeks)
115 '(lambda (x) (and (> x 0) (<= x no-weeks)))))
116 (day (if dayflag (calendar-read
117 "ISO day (1-7): "
118 '(lambda (x) (and (<= 1 x) (<= x 7))))
119 1)))
120 (list (list week day year))))
121
99(defun calendar-goto-iso-date (date &optional noecho) 122(defun calendar-goto-iso-date (date &optional noecho)
100 "Move cursor to ISO DATE; echo ISO date unless NOECHO is t." 123 "Move cursor to ISO DATE; echo ISO date unless NOECHO is t."
101 (interactive 124 (interactive (calendar-iso-read-args t))
102 (let* ((today (calendar-current-date)) 125 (calendar-goto-date (calendar-gregorian-from-absolute
103 (year (calendar-read 126 (calendar-absolute-from-iso date)))
104 "ISO calendar year (>0): " 127 (or noecho (calendar-print-iso-date)))
105 '(lambda (x) (> x 0)) 128
106 (int-to-string (extract-calendar-year today)))) 129(defun calendar-goto-iso-week (date &optional noecho)
107 (no-weeks (extract-calendar-month 130 "Move cursor to ISO DATE; echo ISO date unless NOECHO is t.
108 (calendar-iso-from-absolute 131Interactively, goes to the first day of the specified week."
109 (1- 132 (interactive (calendar-iso-read-args))
110 (calendar-dayname-on-or-before
111 1 (calendar-absolute-from-gregorian
112 (list 1 4 (1+ year))))))))
113 (week (calendar-read
114 (format "ISO calendar week (1-%d): " no-weeks)
115 '(lambda (x) (and (> x 0) (<= x no-weeks)))))
116 (day (calendar-read
117 "ISO day (1-7): "
118 '(lambda (x) (and (<= 1 x) (<= x 7))))))
119 (list (list week day year))))
120 (calendar-goto-date (calendar-gregorian-from-absolute 133 (calendar-goto-date (calendar-gregorian-from-absolute
121 (calendar-absolute-from-iso date))) 134 (calendar-absolute-from-iso date)))
122 (or noecho (calendar-print-iso-date))) 135 (or noecho (calendar-print-iso-date)))