Mercurial > emacs
comparison lisp/calendar/calendar.el @ 70581:1eaae4fee224
(calendar-basic-setup): Set day to 1 in
prefix arg case, to avoid view-diary-entries-initially error.
Reported by Stephen Berman <Stephen.Berman at gmx.net>.
(calendar-date-is-legal-p): Handle dates with no day part.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Thu, 11 May 2006 06:57:32 +0000 |
parents | 53ca33e3b6a5 |
children | 7a79aa083c6b |
comparison
equal
deleted
inserted
replaced
70580:80f0136fc4af | 70581:1eaae4fee224 |
---|---|
1372 | 1372 |
1373 (defsubst extract-calendar-month (date) | 1373 (defsubst extract-calendar-month (date) |
1374 "Extract the month part of DATE which has the form (month day year)." | 1374 "Extract the month part of DATE which has the form (month day year)." |
1375 (car date)) | 1375 (car date)) |
1376 | 1376 |
1377 ;; Note gives wrong answer for result of (calendar-read-date 'noday). | |
1377 (defsubst extract-calendar-day (date) | 1378 (defsubst extract-calendar-day (date) |
1378 "Extract the day part of DATE which has the form (month day year)." | 1379 "Extract the day part of DATE which has the form (month day year)." |
1379 (car (cdr date))) | 1380 (car (cdr date))) |
1380 | 1381 |
1381 (defsubst extract-calendar-year (date) | 1382 (defsubst extract-calendar-year (date) |
1637 (date (if arg | 1638 (date (if arg |
1638 (calendar-read-date t) | 1639 (calendar-read-date t) |
1639 (calendar-current-date))) | 1640 (calendar-current-date))) |
1640 (month (extract-calendar-month date)) | 1641 (month (extract-calendar-month date)) |
1641 (year (extract-calendar-year date))) | 1642 (year (extract-calendar-year date))) |
1643 ;; (calendar-read-date t) returns a date with day = nil, which is | |
1644 ;; not a legal date for the visible test in the diary section. | |
1645 (if arg (setcar (cdr date) 1)) | |
1642 (pop-to-buffer calendar-buffer) | 1646 (pop-to-buffer calendar-buffer) |
1643 (increment-calendar-month month year (- calendar-offset)) | 1647 (increment-calendar-month month year (- calendar-offset)) |
1644 (generate-calendar-window month year) | 1648 (generate-calendar-window month year) |
1645 (if (and view-diary-entries-initially (calendar-date-is-visible-p date)) | 1649 (if (and view-diary-entries-initially (calendar-date-is-visible-p date)) |
1646 (diary-view-entries))) | 1650 (diary-view-entries))) |
2895 "Return t if DATE is a valid date." | 2899 "Return t if DATE is a valid date." |
2896 (let ((month (extract-calendar-month date)) | 2900 (let ((month (extract-calendar-month date)) |
2897 (day (extract-calendar-day date)) | 2901 (day (extract-calendar-day date)) |
2898 (year (extract-calendar-year date))) | 2902 (year (extract-calendar-year date))) |
2899 (and (<= 1 month) (<= month 12) | 2903 (and (<= 1 month) (<= month 12) |
2900 (<= 1 day) (<= day (calendar-last-day-of-month month year)) | 2904 ;; (calendar-read-date t) returns a date with day = nil. |
2905 ;; Should not be valid (?), since many funcs prob assume integer. | |
2906 ;; (calendar-read-date 'noday) returns (month year), which | |
2907 ;; currently results in extract-calendar-year returning nil. | |
2908 day year (<= 1 day) (<= day (calendar-last-day-of-month month year)) | |
2901 ;; BC dates left as non-valid, to suppress errors from | 2909 ;; BC dates left as non-valid, to suppress errors from |
2902 ;; complex holiday algorithms not suitable for years BC. | 2910 ;; complex holiday algorithms not suitable for years BC. |
2903 ;; Note there are side effects on calendar navigation. | 2911 ;; Note there are side effects on calendar navigation. |
2904 (<= 1 year)))) | 2912 (<= 1 year)))) |
2905 | 2913 |