diff options
| author | Jay Belanger | 2012-11-18 23:03:08 -0600 |
|---|---|---|
| committer | Jay Belanger | 2012-11-18 23:03:08 -0600 |
| commit | e8909bdc32f996219fe6875c837c65f891efd726 (patch) | |
| tree | 84c74c1110c117009e29fa02c8755826589dd9f5 | |
| parent | 6e9f7997b36d21004794fa2b8a550729cbabd81a (diff) | |
| download | emacs-e8909bdc32f996219fe6875c837c65f891efd726.tar.gz emacs-e8909bdc32f996219fe6875c837c65f891efd726.zip | |
* calc/calc-forms.el (math-leap-year-p): Fix formula for negative
year numbers.
(math-date-to-julian-dt): Adjust the initial approximation for the
year to deal with the new definition of the DATE.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/calc/calc-forms.el | 13 |
2 files changed, 15 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 26b4e6bb8c7..ab060de5782 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2012-11-19 Jay Belanger <jay.p.belanger@gmail.com> | ||
| 2 | |||
| 3 | * calc/calc-forms.el (math-leap-year-p): Fix formula for negative | ||
| 4 | year numbers. | ||
| 5 | (math-date-to-julian-dt): Adjust the initial approximation for the | ||
| 6 | year to deal with the new definition of the DATE. | ||
| 7 | |||
| 1 | 2012-11-19 Daniel Colascione <dancol@dancol.org> | 8 | 2012-11-19 Daniel Colascione <dancol@dancol.org> |
| 2 | 9 | ||
| 3 | * term/w32-win.el (cygwin-convert-path-from-windows): Accomodate | 10 | * term/w32-win.el (cygwin-convert-path-from-windows): Accomodate |
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)))) |