annotate lisp/calendar/cal-julian.el @ 99552:01c76322ff53

Removed ns-emacs.texi
author Chong Yidong <cyd@stupidchicken.com>
date Fri, 14 Nov 2008 20:47:58 +0000
parents e49abd957e81
children a9dc0e7c3f2b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38422
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 24189
diff changeset
1 ;;; cal-julian.el --- calendar functions for the Julian calendar
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
2
92608
18dc9ef91100 (calendar-absolute-from-julian): Use zerop.
Glenn Morris <rgm@gnu.org>
parents: 92587
diff changeset
3 ;; Copyright (C) 1995, 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
18dc9ef91100 (calendar-absolute-from-julian): Use zerop.
Glenn Morris <rgm@gnu.org>
parents: 92587
diff changeset
4 ;; 2008 Free Software Foundation, Inc.
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
5
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
6 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
67465
a55ee709ec8d Update copyright pending Emacs 22.
Glenn Morris <rgm@gnu.org>
parents: 65145
diff changeset
7 ;; Maintainer: Glenn Morris <rgm@gnu.org>
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
8 ;; Keywords: calendar
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
9 ;; Human-Keywords: Julian calendar, Julian day number, calendar, diary
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
10
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
12
94653
e49abd957e81 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93844
diff changeset
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
94653
e49abd957e81 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93844
diff changeset
15 ;; the Free Software Foundation, either version 3 of the License, or
e49abd957e81 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93844
diff changeset
16 ;; (at your option) any later version.
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
17
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
21 ;; GNU General Public License for more details.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
22
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
94653
e49abd957e81 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93844
diff changeset
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
25
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
26 ;;; Commentary:
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
27
93482
103d07c67833 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93447
diff changeset
28 ;; See calendar.el.
20462
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 17380
diff changeset
29
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
30 ;;; Code:
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
31
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
32 (require 'calendar)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
33
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
34 (defun calendar-julian-to-absolute (date)
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
35 "The number of days elapsed between the Gregorian date 12/31/1 BC and DATE.
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
36 The Gregorian date Sunday, December 31, 1 BC is imaginary."
93809
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93783
diff changeset
37 (let ((month (calendar-extract-month date))
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93783
diff changeset
38 (year (calendar-extract-year date)))
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
39 (+ (calendar-day-number date)
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
40 (if (and (zerop (% year 100))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
41 (not (zerop (% year 400)))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
42 (> month 2))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
43 1 0) ; correct for Julian but not Gregorian leap year
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
44 (* 365 (1- year))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
45 (/ (1- year) 4)
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
46 -2)))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
47
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
48 (define-obsolete-function-alias 'calendar-absolute-from-julian
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
49 'calendar-julian-to-absolute "23.1")
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
50
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
51 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
52 (defun calendar-julian-from-absolute (date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
53 "Compute the Julian (month day year) corresponding to the absolute DATE.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
54 The absolute date is the number of days elapsed since the (imaginary)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
55 Gregorian date Sunday, December 31, 1 BC."
92819
8863bb0c2832 Re-format comments.
Glenn Morris <rgm@gnu.org>
parents: 92608
diff changeset
56 (let* ((approx (/ (+ date 2) 366)) ; approximation from below
8863bb0c2832 Re-format comments.
Glenn Morris <rgm@gnu.org>
parents: 92608
diff changeset
57 (year ; search forward from the approximation
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
58 (+ approx
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
59 (calendar-sum y approx
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
60 (>= date (calendar-julian-to-absolute
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
61 (list 1 1 (1+ y))))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
62 1)))
92819
8863bb0c2832 Re-format comments.
Glenn Morris <rgm@gnu.org>
parents: 92608
diff changeset
63 (month ; search forward from January
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
64 (1+ (calendar-sum m 1
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
65 (> date
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
66 (calendar-julian-to-absolute
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
67 (list m
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
68 (if (and (= m 2) (zerop (% year 4)))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
69 29
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
70 (aref [31 28 31 30 31 30 31
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
71 31 30 31 30 31]
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
72 (1- m)))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
73 year)))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
74 1)))
92819
8863bb0c2832 Re-format comments.
Glenn Morris <rgm@gnu.org>
parents: 92608
diff changeset
75 (day ; calculate the day by subtraction
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
76 (- date (1- (calendar-julian-to-absolute (list month 1 year))))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
77 (list month day year)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
78
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
79 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
80 (defun calendar-julian-date-string (&optional date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
81 "String of Julian date of Gregorian DATE.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
82 Defaults to today's date if DATE is not given.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
83 Driven by the variable `calendar-date-display-form'."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
84 (calendar-date-string
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
85 (calendar-julian-from-absolute
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
86 (calendar-absolute-from-gregorian (or date (calendar-current-date))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
87 nil t))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
88
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
89 ;;;###cal-autoload
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
90 (defun calendar-julian-print-date ()
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
91 "Show the Julian calendar equivalent of the date under the cursor."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
92 (interactive)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
93 (message "Julian date: %s"
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
94 (calendar-julian-date-string (calendar-cursor-to-date t))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
95
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
96 (define-obsolete-function-alias 'calendar-print-julian-date
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
97 'calendar-julian-print-date "23.1")
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
98
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
99 ;;;###cal-autoload
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
100 (defun calendar-julian-goto-date (date &optional noecho)
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
101 "Move cursor to Julian DATE; echo Julian date unless NOECHO is non-nil."
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
102 (interactive
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
103 (let* ((today (calendar-current-date))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
104 (year (calendar-read
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
105 "Julian calendar year (>0): "
92587
267241a78df9 Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents: 79703
diff changeset
106 (lambda (x) (> x 0))
93844
bf9ef749c23e Replace int-to-string with number-to-string.
Glenn Morris <rgm@gnu.org>
parents: 93809
diff changeset
107 (number-to-string
93809
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93783
diff changeset
108 (calendar-extract-year
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
109 (calendar-julian-from-absolute
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
110 (calendar-absolute-from-gregorian
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
111 today))))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
112 (month-array calendar-month-name-array)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
113 (completion-ignore-case t)
54076
9e3e3d184730 (calendar-goto-julian-date): Use assoc-string instead of
Glenn Morris <rgm@gnu.org>
parents: 52401
diff changeset
114 (month (cdr (assoc-string
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
115 (completing-read
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
116 "Julian calendar month name: "
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
117 (mapcar 'list (append month-array nil))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
118 nil t)
54076
9e3e3d184730 (calendar-goto-julian-date): Use assoc-string instead of
Glenn Morris <rgm@gnu.org>
parents: 52401
diff changeset
119 (calendar-make-alist month-array 1) t)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 38422
diff changeset
120 (last
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
121 (if (and (zerop (% year 4)) (= month 2))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
122 29
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
123 (aref [31 28 31 30 31 30 31 31 30 31 30 31] (1- month))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
124 (day (calendar-read
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
125 (format "Julian calendar day (%d-%d): "
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
126 (if (and (= year 1) (= month 1)) 3 1) last)
92587
267241a78df9 Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents: 79703
diff changeset
127 (lambda (x)
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
128 (and (< (if (and (= year 1) (= month 1)) 2 0) x)
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
129 (<= x last))))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
130 (list (list month day year))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
131 (calendar-goto-date (calendar-gregorian-from-absolute
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
132 (calendar-julian-to-absolute date)))
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
133 (or noecho (calendar-julian-print-date)))
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
134
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
135 (define-obsolete-function-alias 'calendar-goto-julian-date
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
136 'calendar-julian-goto-date "23.1")
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
137
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
138 ;;;###holiday-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
139 (defun holiday-julian (month day string)
92819
8863bb0c2832 Re-format comments.
Glenn Morris <rgm@gnu.org>
parents: 92608
diff changeset
140 "Holiday on MONTH, DAY (Julian) called STRING.
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
141 If MONTH, DAY (Julian) is visible, the value returned is corresponding
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
142 Gregorian date in the form of the list (((month day year) STRING)). Returns
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
143 nil if it is not visible in the current calendar window."
93496
cdfc8242a666 (holiday-julian): Use calendar-nongregorian-visible-p.
Glenn Morris <rgm@gnu.org>
parents: 93482
diff changeset
144 (let ((gdate (calendar-nongregorian-visible-p
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
145 month day 'calendar-julian-to-absolute
93496
cdfc8242a666 (holiday-julian): Use calendar-nongregorian-visible-p.
Glenn Morris <rgm@gnu.org>
parents: 93482
diff changeset
146 'calendar-julian-from-absolute
cdfc8242a666 (holiday-julian): Use calendar-nongregorian-visible-p.
Glenn Morris <rgm@gnu.org>
parents: 93482
diff changeset
147 ;; In the Gregorian case, we'd use the lower year when
cdfc8242a666 (holiday-julian): Use calendar-nongregorian-visible-p.
Glenn Morris <rgm@gnu.org>
parents: 93482
diff changeset
148 ;; month >= 11. In the Julian case, there is an offset
cdfc8242a666 (holiday-julian): Use calendar-nongregorian-visible-p.
Glenn Morris <rgm@gnu.org>
parents: 93482
diff changeset
149 ;; of two weeks (ie 1 Nov Greg = 19 Oct Julian). So we
cdfc8242a666 (holiday-julian): Use calendar-nongregorian-visible-p.
Glenn Morris <rgm@gnu.org>
parents: 93482
diff changeset
150 ;; use month >= 10, since it can't cause any problems.
cdfc8242a666 (holiday-julian): Use calendar-nongregorian-visible-p.
Glenn Morris <rgm@gnu.org>
parents: 93482
diff changeset
151 (lambda (m) (< m 10)))))
cdfc8242a666 (holiday-julian): Use calendar-nongregorian-visible-p.
Glenn Morris <rgm@gnu.org>
parents: 93482
diff changeset
152 (if gdate (list (list gdate string)))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
153
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
154 ;;;###cal-autoload
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
155 (defun calendar-astro-to-absolute (d)
13673
da11ffac4f8b (calendar-absolute-from-astro): Doc fix.
Paul Eggert <eggert@twinsun.com>
parents: 13053
diff changeset
156 "Absolute date of astronomical (Julian) day number D."
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
157 (- d 1721424.5))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
158
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
159 (define-obsolete-function-alias 'calendar-absolute-from-astro
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
160 'calendar-astro-to-absolute "23.1")
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
161
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
162 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
163 (defun calendar-astro-from-absolute (d)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
164 "Astronomical (Julian) day number of absolute date D."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
165 (+ d 1721424.5))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
166
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
167 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
168 (defun calendar-astro-date-string (&optional date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
169 "String of astronomical (Julian) day number after noon UTC of Gregorian DATE.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
170 Defaults to today's date if DATE is not given."
93844
bf9ef749c23e Replace int-to-string with number-to-string.
Glenn Morris <rgm@gnu.org>
parents: 93809
diff changeset
171 (number-to-string
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
172 (ceiling
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
173 (calendar-astro-from-absolute
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
174 (calendar-absolute-from-gregorian (or date (calendar-current-date)))))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
175
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
176 ;;;###cal-autoload
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
177 (defun calendar-astro-print-day-number ()
92819
8863bb0c2832 Re-format comments.
Glenn Morris <rgm@gnu.org>
parents: 92608
diff changeset
178 "Show astronomical (Julian) day number after noon UTC on cursor date."
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
179 (interactive)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
180 (message
15069
6237f2b08205 Spelling error.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 14169
diff changeset
181 "Astronomical (Julian) day number (at noon UTC): %s.0"
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
182 (calendar-astro-date-string (calendar-cursor-to-date t))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
183
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
184 (define-obsolete-function-alias 'calendar-print-astro-day-number
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
185 'calendar-astro-print-day-number "23.1")
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
186
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
187 ;;;###cal-autoload
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
188 (defun calendar-astro-goto-day-number (daynumber &optional noecho)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
189 "Move cursor to astronomical (Julian) DAYNUMBER.
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
190 Echo astronomical (Julian) day number unless NOECHO is non-nil."
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
191 (interactive (list (calendar-read
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
192 "Astronomical (Julian) day number (>1721425): "
92587
267241a78df9 Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents: 79703
diff changeset
193 (lambda (x) (> x 1721425)))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
194 (calendar-goto-date
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
195 (calendar-gregorian-from-absolute
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
196 (floor
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
197 (calendar-astro-to-absolute daynumber))))
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
198 (or noecho (calendar-astro-print-day-number)))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
199
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
200 (define-obsolete-function-alias 'calendar-goto-astro-day-number
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
201 'calendar-astro-goto-day-number "23.1")
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
202
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
203 (defvar date)
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
204
93783
2d18de0ed108 Comment.
Glenn Morris <rgm@gnu.org>
parents: 93636
diff changeset
205 ;; To be called from diary-list-sexp-entries, where DATE is bound.
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
206 ;;;###diary-autoload
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
207 (defun diary-julian-date ()
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
208 "Julian calendar equivalent of date diary entry."
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
209 (format "Julian date: %s" (calendar-julian-date-string date)))
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
210
93783
2d18de0ed108 Comment.
Glenn Morris <rgm@gnu.org>
parents: 93636
diff changeset
211 ;; To be called from diary-list-sexp-entries, where DATE is bound.
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
212 ;;;###diary-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
213 (defun diary-astro-day-number ()
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
214 "Astronomical (Julian) day number diary entry."
17380
ba0844956fde (diary-astro-day-number): Change format string.
Richard M. Stallman <rms@gnu.org>
parents: 15069
diff changeset
215 (format "Astronomical (Julian) day number at noon UTC: %s.0"
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
216 (calendar-astro-date-string date)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
217
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
218 (provide 'cal-julian)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
219
92587
267241a78df9 Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents: 79703
diff changeset
220 ;; arch-tag: 0520acdd-1c60-4188-9aa8-9b8c24d856ae
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
221 ;;; cal-julian.el ends here