annotate lisp/calendar/cal-julian.el @ 111986:faa4a1c986c6

Merge changes made in Gnus trunk. nnimap.el (nnimap-wait-for-response): Always look (at least) at the previous line. nnimap.el (nnimap-quirk): New function. (nnimap-retrieve-group-data-early): Use it. (nnimap-quirks): New alist. gnus.texi (Foreign Groups): Added clarification of foreign groups. gnus-sum.el (gnus-summary-push-marks-to-backend): Fix the logic for copying read-ness to the backends. gnus-group.el (gnus-group-kill-group): Notify the backend that the group has been killed. (gnus-group-yank-group): Ditto. gnus-start.el (gnus-subscribe-newsgroup): Notify the backend. nnir.el: Improve customizations. gnus.texi (Archived Messages): Removed outdated comment and text. nnfolder.el (nnfolder-save-all-buffers): Refactor out into its own function. (nnfolder-request-expire-articles): Save all the buffers after doing expiry. nnmail.el (nnmail-expiry-target-group): Revert the "all articles are the last article", since that led to serious performance regressions when expiring nnml groups. gnus-html.el (gnus-html-schedule-image-fetching): Make sure the HTML fetching stops when Gnus exits. gnus-srvr.el: Avoid passing nil regexp argument to delete-matching-lines. auth-source.el (auth-source-gpg-encrypt-to): New variable to set the list of recipient keys, or use symmetric encryption if not a list. (auth-source-create): Use it to make `epa-file-encrypt-to' local for an EPA override, replacing the call to `netrc-store-data'.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Thu, 16 Dec 2010 22:22:28 +0000
parents 280c8ae2476d
children 417b1e4d63cd
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,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
4 ;; 2008, 2009, 2010 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
110015
280c8ae2476d Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
10 ;; Package: calendar
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
11
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
12 ;; This file is part of GNU Emacs.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
13
94653
e49abd957e81 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93844
diff changeset
14 ;; 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
15 ;; 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
16 ;; 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
17 ;; (at your option) any later version.
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
18
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
19 ;; 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
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
22 ;; GNU General Public License for more details.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
23
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
24 ;; 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
25 ;; 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
26
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
27 ;;; Commentary:
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
28
93482
103d07c67833 (Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents: 93447
diff changeset
29 ;; See calendar.el.
20462
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 17380
diff changeset
30
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
31 ;;; Code:
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
32
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
33 (require 'calendar)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
34
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
35 (defun calendar-julian-to-absolute (date)
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
36 "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
37 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
38 (let ((month (calendar-extract-month date))
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93783
diff changeset
39 (year (calendar-extract-year date)))
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
40 (+ (calendar-day-number date)
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
41 (if (and (zerop (% year 100))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
42 (not (zerop (% year 400)))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
43 (> month 2))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
44 1 0) ; correct for Julian but not Gregorian leap year
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
45 (* 365 (1- year))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
46 (/ (1- year) 4)
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
47 -2)))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
48
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
49 (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
50 '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
51
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
52 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
53 (defun calendar-julian-from-absolute (date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
54 "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
55 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
56 Gregorian date Sunday, December 31, 1 BC."
92819
8863bb0c2832 Re-format comments.
Glenn Morris <rgm@gnu.org>
parents: 92608
diff changeset
57 (let* ((approx (/ (+ date 2) 366)) ; approximation from below
8863bb0c2832 Re-format comments.
Glenn Morris <rgm@gnu.org>
parents: 92608
diff changeset
58 (year ; search forward from the approximation
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
59 (+ approx
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
60 (calendar-sum y approx
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
61 (>= date (calendar-julian-to-absolute
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
62 (list 1 1 (1+ y))))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
63 1)))
92819
8863bb0c2832 Re-format comments.
Glenn Morris <rgm@gnu.org>
parents: 92608
diff changeset
64 (month ; search forward from January
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
65 (1+ (calendar-sum m 1
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
66 (> date
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
67 (calendar-julian-to-absolute
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
68 (list m
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
69 (if (and (= m 2) (zerop (% year 4)))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
70 29
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
71 (aref [31 28 31 30 31 30 31
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
72 31 30 31 30 31]
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
73 (1- m)))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
74 year)))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
75 1)))
92819
8863bb0c2832 Re-format comments.
Glenn Morris <rgm@gnu.org>
parents: 92608
diff changeset
76 (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
77 (- 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
78 (list month day year)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
79
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
80 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
81 (defun calendar-julian-date-string (&optional date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
82 "String of Julian date of Gregorian DATE.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
83 Defaults to today's date if DATE is not given.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
84 Driven by the variable `calendar-date-display-form'."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
85 (calendar-date-string
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
86 (calendar-julian-from-absolute
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
87 (calendar-absolute-from-gregorian (or date (calendar-current-date))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
88 nil t))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
89
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
90 ;;;###cal-autoload
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
91 (defun calendar-julian-print-date ()
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
92 "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
93 (interactive)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
94 (message "Julian date: %s"
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
95 (calendar-julian-date-string (calendar-cursor-to-date t))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
96
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
97 (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
98 '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
99
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
100 ;;;###cal-autoload
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
101 (defun calendar-julian-goto-date (date &optional noecho)
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
102 "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
103 (interactive
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
104 (let* ((today (calendar-current-date))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
105 (year (calendar-read
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
106 "Julian calendar year (>0): "
92587
267241a78df9 Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents: 79703
diff changeset
107 (lambda (x) (> x 0))
93844
bf9ef749c23e Replace int-to-string with number-to-string.
Glenn Morris <rgm@gnu.org>
parents: 93809
diff changeset
108 (number-to-string
93809
3ff2b47de8f2 Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents: 93783
diff changeset
109 (calendar-extract-year
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
110 (calendar-julian-from-absolute
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
111 (calendar-absolute-from-gregorian
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
112 today))))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
113 (month-array calendar-month-name-array)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
114 (completion-ignore-case t)
54076
9e3e3d184730 (calendar-goto-julian-date): Use assoc-string instead of
Glenn Morris <rgm@gnu.org>
parents: 52401
diff changeset
115 (month (cdr (assoc-string
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
116 (completing-read
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
117 "Julian calendar month name: "
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
118 (mapcar 'list (append month-array nil))
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
119 nil t)
54076
9e3e3d184730 (calendar-goto-julian-date): Use assoc-string instead of
Glenn Morris <rgm@gnu.org>
parents: 52401
diff changeset
120 (calendar-make-alist month-array 1) t)))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 38422
diff changeset
121 (last
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
122 (if (and (zerop (% year 4)) (= month 2))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
123 29
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
124 (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
125 (day (calendar-read
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
126 (format "Julian calendar day (%d-%d): "
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
127 (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
128 (lambda (x)
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
129 (and (< (if (and (= year 1) (= month 1)) 2 0) x)
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
130 (<= x last))))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
131 (list (list month day year))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
132 (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
133 (calendar-julian-to-absolute date)))
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
134 (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
135
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
136 (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
137 'calendar-julian-goto-date "23.1")
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
138
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
139 ;;;###holiday-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
140 (defun holiday-julian (month day string)
92819
8863bb0c2832 Re-format comments.
Glenn Morris <rgm@gnu.org>
parents: 92608
diff changeset
141 "Holiday on MONTH, DAY (Julian) called STRING.
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
142 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
143 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
144 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
145 (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
146 month day 'calendar-julian-to-absolute
93496
cdfc8242a666 (holiday-julian): Use calendar-nongregorian-visible-p.
Glenn Morris <rgm@gnu.org>
parents: 93482
diff changeset
147 'calendar-julian-from-absolute
cdfc8242a666 (holiday-julian): Use calendar-nongregorian-visible-p.
Glenn Morris <rgm@gnu.org>
parents: 93482
diff changeset
148 ;; 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
149 ;; 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
150 ;; 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
151 ;; 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
152 (lambda (m) (< m 10)))))
cdfc8242a666 (holiday-julian): Use calendar-nongregorian-visible-p.
Glenn Morris <rgm@gnu.org>
parents: 93482
diff changeset
153 (if gdate (list (list gdate string)))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
154
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
155 ;;;###cal-autoload
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
156 (defun calendar-astro-to-absolute (d)
13673
da11ffac4f8b (calendar-absolute-from-astro): Doc fix.
Paul Eggert <eggert@twinsun.com>
parents: 13053
diff changeset
157 "Absolute date of astronomical (Julian) day number D."
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
158 (- d 1721424.5))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
159
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
160 (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
161 '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
162
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
163 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
164 (defun calendar-astro-from-absolute (d)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
165 "Astronomical (Julian) day number of absolute date D."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
166 (+ d 1721424.5))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
167
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
168 ;;;###cal-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
169 (defun calendar-astro-date-string (&optional date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
170 "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
171 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
172 (number-to-string
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
173 (ceiling
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
174 (calendar-astro-from-absolute
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
175 (calendar-absolute-from-gregorian (or date (calendar-current-date)))))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
176
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
177 ;;;###cal-autoload
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
178 (defun calendar-astro-print-day-number ()
92819
8863bb0c2832 Re-format comments.
Glenn Morris <rgm@gnu.org>
parents: 92608
diff changeset
179 "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
180 (interactive)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
181 (message
15069
6237f2b08205 Spelling error.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 14169
diff changeset
182 "Astronomical (Julian) day number (at noon UTC): %s.0"
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
183 (calendar-astro-date-string (calendar-cursor-to-date t))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
184
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
185 (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
186 '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
187
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
188 ;;;###cal-autoload
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
189 (defun calendar-astro-goto-day-number (daynumber &optional noecho)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
190 "Move cursor to astronomical (Julian) DAYNUMBER.
92912
bf22321f752b Re-indent.
Glenn Morris <rgm@gnu.org>
parents: 92834
diff changeset
191 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
192 (interactive (list (calendar-read
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
193 "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
194 (lambda (x) (> x 1721425)))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
195 (calendar-goto-date
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
196 (calendar-gregorian-from-absolute
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
197 (floor
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
198 (calendar-astro-to-absolute daynumber))))
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
199 (or noecho (calendar-astro-print-day-number)))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
200
93636
f5d39ae0db5b (calendar-julian-to-absolute): Rename calendar-absolute-from-julian.
Glenn Morris <rgm@gnu.org>
parents: 93496
diff changeset
201 (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
202 'calendar-astro-goto-day-number "23.1")
92834
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
203
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
204 (defvar date)
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
205
93783
2d18de0ed108 Comment.
Glenn Morris <rgm@gnu.org>
parents: 93636
diff changeset
206 ;; 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
207 ;;;###diary-autoload
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
208 (defun diary-julian-date ()
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
209 "Julian calendar equivalent of date diary entry."
3e0b7b9e8f11 (diary-julian-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents: 92819
diff changeset
210 (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
211
93783
2d18de0ed108 Comment.
Glenn Morris <rgm@gnu.org>
parents: 93636
diff changeset
212 ;; 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
213 ;;;###diary-autoload
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
214 (defun diary-astro-day-number ()
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
215 "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
216 (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
217 (calendar-astro-date-string date)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
218
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
219 (provide 'cal-julian)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
220
92587
267241a78df9 Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents: 79703
diff changeset
221 ;; arch-tag: 0520acdd-1c60-4188-9aa8-9b8c24d856ae
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
222 ;;; cal-julian.el ends here