comparison lisp/calendar/cal-coptic.el @ 92627:73ee52037e9a

Formatting changes only.
author Glenn Morris <rgm@gnu.org>
date Sat, 08 Mar 2008 20:12:25 +0000
parents a7f58647496a
children 5d415a63a344
comparison
equal deleted inserted replaced
92626:6e8a8b70004a 92627:73ee52037e9a
55 (zerop (mod (1+ year) 4))) 55 (zerop (mod (1+ year) 4)))
56 56
57 (defun coptic-calendar-last-day-of-month (month year) 57 (defun coptic-calendar-last-day-of-month (month year)
58 "Return last day of MONTH, YEAR on the Coptic calendar. 58 "Return last day of MONTH, YEAR on the Coptic calendar.
59 The 13th month is not really a month, but the 5 (6 in leap years) day period of 59 The 13th month is not really a month, but the 5 (6 in leap years) day period of
60 Nisi (Kebus) at the end of the year." 60 Nisi (Kebus) at the end of the year."
61 (if (< month 13) 61 (if (< month 13)
62 30 62 30
63 (if (coptic-calendar-leap-year-p year) 63 (if (coptic-calendar-leap-year-p year)
64 6 64 6
65 5))) 65 5)))
69 The absolute date is the number of days elapsed since the (imaginary) 69 The absolute date is the number of days elapsed since the (imaginary)
70 Gregorian date Sunday, December 31, 1 BC." 70 Gregorian date Sunday, December 31, 1 BC."
71 (let ((month (extract-calendar-month date)) 71 (let ((month (extract-calendar-month date))
72 (day (extract-calendar-day date)) 72 (day (extract-calendar-day date))
73 (year (extract-calendar-year date))) 73 (year (extract-calendar-year date)))
74 (+ (1- coptic-calendar-epoch);; Days before start of calendar 74 (+ (1- coptic-calendar-epoch) ; days before start of calendar
75 (* 365 (1- year)) ;; Days in prior years 75 (* 365 (1- year)) ; days in prior years
76 (/ year 4) ;; Leap days in prior years 76 (/ year 4) ; leap days in prior years
77 (* 30 (1- month)) ;; Days in prior months this year 77 (* 30 (1- month)) ; days in prior months this year
78 day))) ;; Days so far this month 78 day))) ; days so far this month
79 79
80 80
81 (defun calendar-coptic-from-absolute (date) 81 (defun calendar-coptic-from-absolute (date)
82 "Compute the Coptic equivalent for absolute date DATE. 82 "Compute the Coptic equivalent for absolute date DATE.
83 The result is a list of the form (MONTH DAY YEAR). 83 The result is a list of the form (MONTH DAY YEAR).
84 The absolute date is the number of days elapsed since the imaginary 84 The absolute date is the number of days elapsed since the imaginary
85 Gregorian date Sunday, December 31, 1 BC." 85 Gregorian date Sunday, December 31, 1 BC."
86 (if (< date coptic-calendar-epoch) 86 (if (< date coptic-calendar-epoch)
87 (list 0 0 0);; pre-Coptic date 87 (list 0 0 0) ; pre-Coptic date
88 (let* ((approx (/ (- date coptic-calendar-epoch) 88 (let* ((approx (/ (- date coptic-calendar-epoch)
89 366)) ;; Approximation from below. 89 366)) ; approximation from below
90 (year ;; Search forward from the approximation. 90 (year ; search forward from the approximation
91 (+ approx 91 (+ approx
92 (calendar-sum y approx 92 (calendar-sum y approx
93 (>= date (calendar-absolute-from-coptic (list 1 1 (1+ y)))) 93 (>= date (calendar-absolute-from-coptic (list 1 1 (1+ y))))
94 1))) 94 1)))
95 (month ;; Search forward from Tot. 95 (month ; search forward from Tot
96 (1+ (calendar-sum m 1 96 (1+ (calendar-sum m 1
97 (> date 97 (> date
98 (calendar-absolute-from-coptic 98 (calendar-absolute-from-coptic
99 (list m 99 (list m
100 (coptic-calendar-last-day-of-month m year) 100 (coptic-calendar-last-day-of-month m year)
101 year))) 101 year)))
102 1))) 102 1)))
103 (day ;; Calculate the day by subtraction. 103 (day ; calculate the day by subtraction
104 (- date 104 (- date
105 (1- (calendar-absolute-from-coptic (list month 1 year)))))) 105 (1- (calendar-absolute-from-coptic (list month 1 year))))))
106 (list month day year)))) 106 (list month day year))))
107 107
108 ;;;###autoload 108 ;;;###autoload