Mercurial > emacs
comparison lisp/calendar/cal-iso.el @ 93809:3ff2b47de8f2
Update for calendar.el name changes.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Mon, 07 Apr 2008 01:59:37 +0000 |
parents | a7aaeba2c2bc |
children | bf9ef749c23e |
comparison
equal
deleted
inserted
replaced
93808:2c72483f42c9 | 93809:3ff2b47de8f2 |
---|---|
39 weeks start on Monday and end on Sunday. The first week of the ISO year is | 39 weeks start on Monday and end on Sunday. The first week of the ISO year is |
40 the first such week in which at least 4 days are in a year. The ISO | 40 the first such week in which at least 4 days are in a year. The ISO |
41 commercial DATE has the form (week day year) in which week is in the range | 41 commercial DATE has the form (week day year) in which week is in the range |
42 1..52 and day is in the range 0..6 (1 = Monday, 2 = Tuesday, ..., 0 = | 42 1..52 and day is in the range 0..6 (1 = Monday, 2 = Tuesday, ..., 0 = |
43 Sunday). The Gregorian date Sunday, December 31, 1 BC is imaginary." | 43 Sunday). The Gregorian date Sunday, December 31, 1 BC is imaginary." |
44 (let ((day (extract-calendar-day date))) | 44 (let ((day (calendar-extract-day date))) |
45 (+ (calendar-dayname-on-or-before | 45 (+ (calendar-dayname-on-or-before |
46 1 (+ 3 (calendar-absolute-from-gregorian | 46 1 (+ 3 (calendar-absolute-from-gregorian |
47 (list 1 1 (extract-calendar-year date))))) | 47 (list 1 1 (calendar-extract-year date))))) |
48 ;; ISO date is (week day year); normally (month day year). | 48 ;; ISO date is (week day year); normally (month day year). |
49 (* 7 (1- (extract-calendar-month date))) | 49 (* 7 (1- (calendar-extract-month date))) |
50 (if (zerop day) 6 (1- day))))) | 50 (if (zerop day) 6 (1- day))))) |
51 | 51 |
52 (define-obsolete-function-alias 'calendar-absolute-from-iso | 52 (define-obsolete-function-alias 'calendar-absolute-from-iso |
53 'calendar-iso-to-absolute "23.1") | 53 'calendar-iso-to-absolute "23.1") |
54 | 54 |
59 first such week in which at least 4 days are in a year. The ISO commercial | 59 first such week in which at least 4 days are in a year. The ISO commercial |
60 date has the form (week day year) in which week is in the range 1..52 and | 60 date has the form (week day year) in which week is in the range 1..52 and |
61 day is in the range 0..6 (1 = Monday, 2 = Tuesday, ..., 0 = Sunday). The | 61 day is in the range 0..6 (1 = Monday, 2 = Tuesday, ..., 0 = Sunday). The |
62 absolute date is the number of days elapsed since the (imaginary) Gregorian | 62 absolute date is the number of days elapsed since the (imaginary) Gregorian |
63 date Sunday, December 31, 1 BC." | 63 date Sunday, December 31, 1 BC." |
64 (let* ((approx (extract-calendar-year | 64 (let* ((approx (calendar-extract-year |
65 (calendar-gregorian-from-absolute (- date 3)))) | 65 (calendar-gregorian-from-absolute (- date 3)))) |
66 (year (+ approx | 66 (year (+ approx |
67 (calendar-sum y approx | 67 (calendar-sum y approx |
68 (>= date (calendar-iso-to-absolute | 68 (>= date (calendar-iso-to-absolute |
69 (list 1 1 (1+ y)))) | 69 (list 1 1 (1+ y)))) |
80 (or date (calendar-current-date)))) | 80 (or date (calendar-current-date)))) |
81 (day (% d 7)) | 81 (day (% d 7)) |
82 (iso-date (calendar-iso-from-absolute d))) | 82 (iso-date (calendar-iso-from-absolute d))) |
83 (format "Day %s of week %d of %d" | 83 (format "Day %s of week %d of %d" |
84 (if (zerop day) 7 day) | 84 (if (zerop day) 7 day) |
85 (extract-calendar-month iso-date) | 85 (calendar-extract-month iso-date) |
86 (extract-calendar-year iso-date)))) | 86 (calendar-extract-year iso-date)))) |
87 | 87 |
88 ;;;###cal-autoload | 88 ;;;###cal-autoload |
89 (defun calendar-iso-print-date () | 89 (defun calendar-iso-print-date () |
90 "Show equivalent ISO date for the date under the cursor." | 90 "Show equivalent ISO date for the date under the cursor." |
91 (interactive) | 91 (interactive) |
100 Reads a year and week, and if DAYFLAG is non-nil a day (otherwise | 100 Reads a year and week, and if DAYFLAG is non-nil a day (otherwise |
101 taken to be 1)." | 101 taken to be 1)." |
102 (let* ((year (calendar-read | 102 (let* ((year (calendar-read |
103 "ISO calendar year (>0): " | 103 "ISO calendar year (>0): " |
104 (lambda (x) (> x 0)) | 104 (lambda (x) (> x 0)) |
105 (int-to-string (extract-calendar-year | 105 (int-to-string (calendar-extract-year |
106 (calendar-current-date))))) | 106 (calendar-current-date))))) |
107 (no-weeks (extract-calendar-month | 107 (no-weeks (calendar-extract-month |
108 (calendar-iso-from-absolute | 108 (calendar-iso-from-absolute |
109 (1- | 109 (1- |
110 (calendar-dayname-on-or-before | 110 (calendar-dayname-on-or-before |
111 1 (calendar-absolute-from-gregorian | 111 1 (calendar-absolute-from-gregorian |
112 (list 1 4 (1+ year)))))))) | 112 (list 1 4 (1+ year)))))))) |