annotate lisp/calendar/cal-julian.el @ 93570:c450cdd35ee3

(latin1-display): Don't use make-char. Fix the argument to set-char-table-range. (latin1-display-identities): Don't use make-char. (latin1-display-reset): Use map-charset-chars instead of directly calling standard-display-default. (latin1-display-check-font): Don't use make-char. (latin1-display-setup): Likewise. (latin1-display-ucs-per-lynx): Likewise.
author Kenichi Handa <handa@m17n.org>
date Thu, 03 Apr 2008 03:51:54 +0000
parents cdfc8242a666
children f5d39ae0db5b
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
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
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
78216
93e11478c954 Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
15 ;; the Free Software Foundation; either version 3, or (at your option)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
16 ;; any later version.
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
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13673
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 61148
diff changeset
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 61148
diff changeset
26 ;; Boston, MA 02110-1301, USA.
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
27
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
28 ;;; Commentary:
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
29
93482
103d07c67833 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93447
diff changeset
30 ;; See calendar.el.
20462
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 17380
diff changeset
31
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
32 ;;; Code:
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
33
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
34 (require 'calendar)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
35
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
36 (defun calendar-absolute-from-julian (date)
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
37 "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
38 The Gregorian date Sunday, December 31, 1 BC is imaginary."
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
39 (let ((month (extract-calendar-month date))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
40 (year (extract-calendar-year date)))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
41 (+ (calendar-day-number date)
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
42 (if (and (zerop (% year 100))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
43 (not (zerop (% year 400)))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
44 (> month 2))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
45 1 0) ; correct for Julian but not Gregorian leap year
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
46 (* 365 (1- year))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
47 (/ (1- year) 4)
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
48 -2)))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
49
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
50 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
51 (defun calendar-julian-from-absolute (date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
52 "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
53 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
54 Gregorian date Sunday, December 31, 1 BC."
92819
8863bb0c2832 Re-format comments.
Glenn Morris <rgm@gnu.org>
parents: 92608
diff changeset
55 (let* ((approx (/ (+ date 2) 366)) ; approximation from below
8863bb0c2832 Re-format comments.
Glenn Morris <rgm@gnu.org>
parents: 92608
diff changeset
56 (year ; search forward from the approximation
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
57 (+ approx
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
58 (calendar-sum y approx
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
59 (>= date (calendar-absolute-from-julian
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
60 (list 1 1 (1+ y))))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
61 1)))
92819
8863bb0c2832 Re-format comments.
Glenn Morris <rgm@gnu.org>
parents: 92608
diff changeset
62 (month ; search forward from January
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
63 (1+ (calendar-sum m 1
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
64 (> date
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
65 (calendar-absolute-from-julian
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
66 (list m
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
67 (if (and (= m 2) (zerop (% year 4)))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
68 29
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
69 (aref [31 28 31 30 31 30 31
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
70 31 30 31 30 31]
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
71 (1- m)))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
72 year)))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
73 1)))
92819
8863bb0c2832 Re-format comments.
Glenn Morris <rgm@gnu.org>
parents: 92608
diff changeset
74 (day ; calculate the day by subtraction
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
75 (- date (1- (calendar-absolute-from-julian (list month 1 year))))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
76 (list month day year)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
77
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
78 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
79 (defun calendar-julian-date-string (&optional date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
80 "String of Julian date of Gregorian DATE.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
81 Defaults to today's date if DATE is not given.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
82 Driven by the variable `calendar-date-display-form'."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
83 (calendar-date-string
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
84 (calendar-julian-from-absolute
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
85 (calendar-absolute-from-gregorian (or date (calendar-current-date))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
86 nil t))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
87
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
88 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
89 (defun calendar-print-julian-date ()
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
90 "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
91 (interactive)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
92 (message "Julian date: %s"
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
93 (calendar-julian-date-string (calendar-cursor-to-date t))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
94
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
95 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
96 (defun calendar-goto-julian-date (date &optional noecho)
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
97 "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
98 (interactive
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
99 (let* ((today (calendar-current-date))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
100 (year (calendar-read
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
101 "Julian calendar year (>0): "
92587
267241a78df9 Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents: 79703
diff changeset
102 (lambda (x) (> x 0))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
103 (int-to-string
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
104 (extract-calendar-year
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
105 (calendar-julian-from-absolute
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
106 (calendar-absolute-from-gregorian
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
107 today))))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
108 (month-array calendar-month-name-array)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
109 (completion-ignore-case t)
54076
9e3e3d184730 (calendar-goto-julian-date): Use assoc-string instead of
Glenn Morris <rgm@gnu.org>
parents: 52401
diff changeset
110 (month (cdr (assoc-string
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
111 (completing-read
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
112 "Julian calendar month name: "
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
113 (mapcar 'list (append month-array nil))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
114 nil t)
54076
9e3e3d184730 (calendar-goto-julian-date): Use assoc-string instead of
Glenn Morris <rgm@gnu.org>
parents: 52401
diff changeset
115 (calendar-make-alist month-array 1) t)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 38422
diff changeset
116 (last
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
117 (if (and (zerop (% year 4)) (= month 2))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
118 29
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
119 (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
120 (day (calendar-read
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
121 (format "Julian calendar day (%d-%d): "
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
122 (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
123 (lambda (x)
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
124 (and (< (if (and (= year 1) (= month 1)) 2 0) x)
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
125 (<= x last))))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
126 (list (list month day year))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
127 (calendar-goto-date (calendar-gregorian-from-absolute
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
128 (calendar-absolute-from-julian date)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
129 (or noecho (calendar-print-julian-date)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
130
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
131 ;;;###holiday-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
132 (defun holiday-julian (month day string)
92819
8863bb0c2832 Re-format comments.
Glenn Morris <rgm@gnu.org>
parents: 92608
diff changeset
133 "Holiday on MONTH, DAY (Julian) called STRING.
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
134 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
135 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
136 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
137 (let ((gdate (calendar-nongregorian-visible-p
cdfc8242a666 (holiday-julian): Use calendar-nongregorian-visible-p.
Glenn Morris <rgm@gnu.org>
parents: 93482
diff changeset
138 month day 'calendar-absolute-from-julian
cdfc8242a666 (holiday-julian): Use calendar-nongregorian-visible-p.
Glenn Morris <rgm@gnu.org>
parents: 93482
diff changeset
139 'calendar-julian-from-absolute
cdfc8242a666 (holiday-julian): Use calendar-nongregorian-visible-p.
Glenn Morris <rgm@gnu.org>
parents: 93482
diff changeset
140 ;; 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
141 ;; 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
142 ;; 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
143 ;; 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
144 (lambda (m) (< m 10)))))
cdfc8242a666 (holiday-julian): Use calendar-nongregorian-visible-p.
Glenn Morris <rgm@gnu.org>
parents: 93482
diff changeset
145 (if gdate (list (list gdate string)))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
146
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
147 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
148 (defun calendar-absolute-from-astro (d)
13673
da11ffac4f8b (calendar-absolute-from-astro): Doc fix.
Paul Eggert <eggert@twinsun.com>
parents: 13053
diff changeset
149 "Absolute date of astronomical (Julian) day number D."
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
150 (- d 1721424.5))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
151
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
152 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
153 (defun calendar-astro-from-absolute (d)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
154 "Astronomical (Julian) day number of absolute date D."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
155 (+ d 1721424.5))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
156
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
157 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
158 (defun calendar-astro-date-string (&optional date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
159 "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
160 Defaults to today's date if DATE is not given."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
161 (int-to-string
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
162 (ceiling
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
163 (calendar-astro-from-absolute
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
164 (calendar-absolute-from-gregorian (or date (calendar-current-date)))))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
165
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
166 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
167 (defun calendar-print-astro-day-number ()
92819
8863bb0c2832 Re-format comments.
Glenn Morris <rgm@gnu.org>
parents: 92608
diff changeset
168 "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
169 (interactive)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
170 (message
15069
6237f2b08205 Spelling error.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 14169
diff changeset
171 "Astronomical (Julian) day number (at noon UTC): %s.0"
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
172 (calendar-astro-date-string (calendar-cursor-to-date t))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
173
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
174 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
175 (defun calendar-goto-astro-day-number (daynumber &optional noecho)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
176 "Move cursor to astronomical (Julian) DAYNUMBER.
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
177 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
178 (interactive (list (calendar-read
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
179 "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
180 (lambda (x) (> x 1721425)))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
181 (calendar-goto-date
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
182 (calendar-gregorian-from-absolute
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
183 (floor
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
184 (calendar-absolute-from-astro daynumber))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
185 (or noecho (calendar-print-astro-day-number)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
186
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
187
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
188 (defvar date)
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
189
92608
18dc9ef91100 (calendar-absolute-from-julian): Use zerop.
Glenn Morris <rgm@gnu.org>
parents: 92587
diff changeset
190 ;; To be called from list-sexp-diary-entries, where DATE is bound.
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
191 ;;;###diary-autoload
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
192 (defun diary-julian-date ()
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
193 "Julian calendar equivalent of date diary entry."
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
194 (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
195
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
196 ;; To be called from list-sexp-diary-entries, where DATE is bound.
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
197 ;;;###diary-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
198 (defun diary-astro-day-number ()
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
199 "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
200 (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
201 (calendar-astro-date-string date)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
202
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
203 (provide 'cal-julian)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
204
92587
267241a78df9 Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents: 79703
diff changeset
205 ;; arch-tag: 0520acdd-1c60-4188-9aa8-9b8c24d856ae
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
206 ;;; cal-julian.el ends here