aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/calc
diff options
context:
space:
mode:
authorKenichi Handa2012-11-23 23:36:24 +0900
committerKenichi Handa2012-11-23 23:36:24 +0900
commit2aaec2d9be5cec44ea3b59cba476fd3e091f2fc9 (patch)
tree3711b97807201b7eeaa066003b1c3a4ce929e5bb /lisp/calc
parente1d276cbf9e18f13101328f56bed1a1c0a66e63a (diff)
parente7d0e5ee247a155a268ffbf80bedbe25e15b5032 (diff)
downloademacs-2aaec2d9be5cec44ea3b59cba476fd3e091f2fc9.tar.gz
emacs-2aaec2d9be5cec44ea3b59cba476fd3e091f2fc9.zip
Diffstat (limited to 'lisp/calc')
-rw-r--r--lisp/calc/README13
-rw-r--r--lisp/calc/calc-forms.el13
-rw-r--r--lisp/calc/calc.el88
3 files changed, 62 insertions, 52 deletions
diff --git a/lisp/calc/README b/lisp/calc/README
index 25d1a5e9b58..638b482a60a 100644
--- a/lisp/calc/README
+++ b/lisp/calc/README
@@ -70,11 +70,18 @@ opinions.
70Summary of changes to "Calc" 70Summary of changes to "Calc"
71------- -- ------- -- ---- 71------- -- ------- -- ----
72 72
73Emacs 24.4
74
75* The date forms use the Gregorian calendar for all dates.
76 (Previously they were a combination of Julian and Gregorian
77 dates.) This can be configured with the customizable variable
78 `calc-gregorian-switch'.
79
73Emacs 24.3 80Emacs 24.3
74 81
75Algebraic simplification mode is now the default. 82* Algebraic simplification mode is now the default.
76To restrict to the limited simplifications given by the former 83 To restrict to the limited simplifications given by the former
77default simplification mode, use `m I'. 84 default simplification mode, use `m I'.
78 85
79Emacs 24.1 86Emacs 24.1
80 87
diff --git a/lisp/calc/calc-forms.el b/lisp/calc/calc-forms.el
index 709250f9ba9..98b22550f75 100644
--- a/lisp/calc/calc-forms.el
+++ b/lisp/calc/calc-forms.el
@@ -371,9 +371,10 @@
371;;; These versions are rewritten to use arbitrary-size integers. 371;;; These versions are rewritten to use arbitrary-size integers.
372 372
373;;; A numerical date is the number of days since midnight on 373;;; A numerical date is the number of days since midnight on
374;;; the morning of December 31, 1 B.C. Emacs's calendar refers to such 374;;; the morning of December 31, 1 B.C. (Gregorian) or January 2, 1 A.D. (Julian).
375;;; a date as an absolute date, some function names also use that 375;;; Emacs's calendar refers to such a date as an absolute date, some Calc function
376;;; terminology. If the date is a non-integer, it represents a specific date and time. 376;;; names also use that terminology. If the date is a non-integer, it represents
377;;; a specific date and time.
377;;; A "dt" is a list of the form, (year month day), corresponding to 378;;; A "dt" is a list of the form, (year month day), corresponding to
378;;; an integer code, or (year month day hour minute second), corresponding 379;;; an integer code, or (year month day hour minute second), corresponding
379;;; to a non-integer code. 380;;; to a non-integer code.
@@ -408,8 +409,8 @@ DATE is the number of days since December 31, -1 in the Gregorian calendar."
408 (let* ((month 1) 409 (let* ((month 1)
409 day 410 day
410 (year (math-quotient (math-add date (if (Math-lessp date 711859) 411 (year (math-quotient (math-add date (if (Math-lessp date 711859)
411 365 ; for speed, we take 412 367 ; for speed, we take
412 -108)) ; >1950 as a special case 413 -106)) ; >1950 as a special case
413 (if (math-negp date) 366 365))) 414 (if (math-negp date) 366 365)))
414 ; this result may be an overestimate 415 ; this result may be an overestimate
415 temp) 416 temp)
@@ -494,6 +495,8 @@ Gregorian calendar."
494 (if (math-negp year) 495 (if (math-negp year)
495 (= (math-imod (math-neg year) 4) 1) 496 (= (math-imod (math-neg year) 4) 1)
496 (= (math-imod year 4) 0)) 497 (= (math-imod year 4) 0))
498 (if (math-negp year)
499 (setq year (math-sub -1 year)))
497 (setq year (math-imod year 400)) 500 (setq year (math-imod year 400))
498 (or (and (= (% year 4) 0) (/= (% year 100) 0)) 501 (or (and (= (% year 4) 0) (/= (% year 100) 0))
499 (= year 0)))) 502 (= year 0))))
diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el
index aeca45ebf26..58eabf9bcec 100644
--- a/lisp/calc/calc.el
+++ b/lisp/calc/calc.el
@@ -466,50 +466,6 @@ to be identified as that note."
466 466
467(defvar math-format-date-cache) ; calc-forms.el 467(defvar math-format-date-cache) ; calc-forms.el
468 468
469;; Dates that are built-in options for `calc-gregorian-switch' should be
470;; (YEAR MONTH DAY math-date-from-gregorian-dt(YEAR MONTH DAY)) for speed.
471(defcustom calc-gregorian-switch nil
472 "The first day the Gregorian calendar is used by Calc's date forms.
473This is `nil' (the default) if the Gregorian calendar is the only one used.
474Otherwise, it should be a list `(YEAR MONTH DAY)' when Calc begins to use
475the Gregorian calendar; Calc will use the Julian calendar for earlier dates.
476The dates in which different regions of the world began to use the
477Gregorian calendar vary quite a bit, even within a single country.
478If you want Calc's date forms to switch between the Julian and
479Gregorian calendar, you can specify the date or choose from several
480common choices. Some of these choices should be taken with a grain
481of salt; for example different parts of France changed calendars at
482different times, and Sweden's change to the Gregorian calendar was
483complicated. Also, the boundaries of the countries were different at
484the times of the calendar changes than they are now.
485The Vatican decided that the Gregorian calendar should take effect
486on 15 October 1582 (Gregorian), and many Catholic countries made
487the change then. Great Britian and its colonies had the Gregorian
488calendar take effect on 14 September 1752 (Gregorian); this includes
489the United States."
490 :group 'calc
491 :version "24.4"
492 :type '(choice (const :tag "Always use the Gregorian calendar" nil)
493 (const :tag "Great Britian and the US (1752 9 14)" (1752 9 14 639797))
494 (const :tag "Vatican (1582 10 15)" (1582 10 15 577736))
495 (const :tag "Czechoslovakia (1584 1 17)" (1584 1 17 578195))
496 (const :tag "Denmark (1700 3 1)" (1700 3 1 620607))
497 (const :tag "France (1582 12 20)" (1582 12 20 577802))
498 (const :tag "Hungary (1587 11 1)" (1587 11 1 579579))
499 (const :tag "Luxemburg (1582 12 25)" (1582 12 25 577807))
500 (const :tag "Romania (1919 4 14)" (1919 4 14 700638))
501 (const :tag "Russia (1918 2 14)" (1918 2 14 700214))
502 (const :tag "Sweden (1753 3 1)" (1753 3 1 639965))
503 (const :tag "Switzerland (Catholic) (1584 1 22)" (1584 1 22 578200))
504 (const :tag "Switzerland (Protestant) (1701 1 12)" (1701 1 12 620924))
505 (list :tag "(YEAR MONTH DAY)"
506 (integer :tag "Year")
507 (integer :tag "Month (integer)")
508 (integer :tag "Day")))
509 :set (lambda (symbol value)
510 (set-default symbol value)
511 (setq math-format-date-cache nil)))
512
513(defface calc-nonselected-face 469(defface calc-nonselected-face
514 '((t :inherit shadow 470 '((t :inherit shadow
515 :slant italic)) 471 :slant italic))
@@ -2066,6 +2022,50 @@ See calc-keypad for details."
2066 (calc-refresh align))) 2022 (calc-refresh align)))
2067 (setq calc-refresh-count (1+ calc-refresh-count))) 2023 (setq calc-refresh-count (1+ calc-refresh-count)))
2068 2024
2025;; Dates that are built-in options for `calc-gregorian-switch' should be
2026;; (YEAR MONTH DAY math-date-from-gregorian-dt(YEAR MONTH DAY)) for speed.
2027(defcustom calc-gregorian-switch nil
2028 "The first day the Gregorian calendar is used by Calc's date forms.
2029This is `nil' (the default) if the Gregorian calendar is the only one used.
2030Otherwise, it should be a list `(YEAR MONTH DAY)' when Calc begins to use
2031the Gregorian calendar; Calc will use the Julian calendar for earlier dates.
2032The dates in which different regions of the world began to use the
2033Gregorian calendar vary quite a bit, even within a single country.
2034If you want Calc's date forms to switch between the Julian and
2035Gregorian calendar, you can specify the date or choose from several
2036common choices. Some of these choices should be taken with a grain
2037of salt; for example different parts of France changed calendars at
2038different times, and Sweden's change to the Gregorian calendar was
2039complicated. Also, the boundaries of the countries were different at
2040the times of the calendar changes than they are now.
2041The Vatican decided that the Gregorian calendar should take effect
2042on 15 October 1582 (Gregorian), and many Catholic countries made
2043the change then. Great Britain and its colonies had the Gregorian
2044calendar take effect on 14 September 1752 (Gregorian); this includes
2045the United States."
2046 :group 'calc
2047 :version "24.4"
2048 :type '(choice (const :tag "Always use the Gregorian calendar" nil)
2049 (const :tag "1582-10-15 - Italy, Poland, Portugal, Spain" (1582 10 15 577736))
2050 (const :tag "1582-12-20 - France" (1582 12 20 577802))
2051 (const :tag "1582-12-25 - Luxemburg" (1582 12 25 577807))
2052 (const :tag "1584-01-17 - Bohemia and Moravia" (1584 1 17 578195))
2053 (const :tag "1587-11-01 - Hungary" (1587 11 1 579579))
2054 (const :tag "1700-03-01 - Denmark" (1700 3 1 620607))
2055 (const :tag "1701-01-12 - Protestant Switzerland" (1701 1 12 620924))
2056 (const :tag "1752-09-14 - Great Britain and dominions" (1752 9 14 639797))
2057 (const :tag "1753-03-01 - Sweden" (1753 3 1 639965))
2058 (const :tag "1918-02-14 - Russia" (1918 2 14 700214))
2059 (const :tag "1919-04-14 - Romania" (1919 4 14 700638))
2060 (list :tag "(YEAR MONTH DAY)"
2061 (integer :tag "Year")
2062 (integer :tag "Month (integer)")
2063 (integer :tag "Day")))
2064 :set (lambda (symbol value)
2065 (set-default symbol value)
2066 (setq math-format-date-cache nil)
2067 (calc-refresh)))
2068
2069;;;; The Calc Trail buffer. 2069;;;; The Calc Trail buffer.
2070 2070
2071(defun calc-check-trail-aligned () 2071(defun calc-check-trail-aligned ()