scalinger -> scaliger
This fixes racket/racket#757. Tests are included for both versions, and documentation now only references the new, correctly named, procedures.
This commit is contained in:
parent
d22df41001
commit
de0fbf2648
|
@ -224,16 +224,16 @@ local time by default or UTC if @racket[local-time?] is
|
||||||
error is signaled, otherwise an integer is returned.}
|
error is signaled, otherwise an integer is returned.}
|
||||||
|
|
||||||
|
|
||||||
@defproc[(date->julian/scalinger [date date?]) exact-integer?]{
|
@defproc[(date->julian/scaliger [date date?]) exact-integer?]{
|
||||||
|
|
||||||
Converts a date structure (up to 2099 BCE Gregorian) into a Julian
|
Converts a date structure (up to 2099 BCE Gregorian) into a Julian
|
||||||
date number. The returned value is not a strict Julian number, but
|
date number. The returned value is not a strict Julian number, but
|
||||||
rather Scalinger's version, which is off by one for easier
|
rather Scaliger's version, which is off by one for easier
|
||||||
calculations.}
|
calculations.}
|
||||||
|
|
||||||
|
|
||||||
@defproc[(julian/scalinger->string [date-number exact-integer?])
|
@defproc[(julian/scaliger->string [date-number exact-integer?])
|
||||||
string?]{
|
string?]{
|
||||||
|
|
||||||
Converts a Julian number (Scalinger's off-by-one version) into a
|
Converts a Julian number (Scaliger's off-by-one version) into a
|
||||||
string.}
|
string.}
|
||||||
|
|
|
@ -73,8 +73,12 @@
|
||||||
(test-string 'julian #f "JD 2 453 860")
|
(test-string 'julian #f "JD 2 453 860")
|
||||||
(test-string 'julian #t "JD 2 453 860, 03:02:01")
|
(test-string 'julian #t "JD 2 453 860, 03:02:01")
|
||||||
|
|
||||||
|
;; In the off chance that one of these changes and not the other,
|
||||||
|
;; both are provided for tests.
|
||||||
(test 2453860 date->julian/scalinger d)
|
(test 2453860 date->julian/scalinger d)
|
||||||
(test "JD 2 453 860" julian/scalinger->string 2453860))
|
(test 2453860 date->julian/scaliger d)
|
||||||
|
(test "JD 2 453 860" julian/scalinger->string 2453860)
|
||||||
|
(test "JD 2 453 860" julian/scaliger->string 2453860))
|
||||||
|
|
||||||
;; Bad dates
|
;; Bad dates
|
||||||
(err/rt-test (find-seconds 0 0 0 0 0 1990) exn:fail?)
|
(err/rt-test (find-seconds 0 0 0 0 0 1990) exn:fail?)
|
||||||
|
@ -106,9 +110,14 @@
|
||||||
;; one of the two possible values, though:
|
;; one of the two possible values, though:
|
||||||
(test-find 0 30 1 7 11 2010))))
|
(test-find 0 30 1 7 11 2010))))
|
||||||
|
|
||||||
|
|
||||||
|
;; In the off chance that one of these changes and not the other,
|
||||||
|
;; both are provided for tests.
|
||||||
;; bug fixes
|
;; bug fixes
|
||||||
(test "JD 12" julian/scalinger->string 12)
|
(test "JD 12" julian/scalinger->string 12)
|
||||||
|
(test "JD 12" julian/scaliger->string 12)
|
||||||
(test "JD 123" julian/scalinger->string 123)
|
(test "JD 123" julian/scalinger->string 123)
|
||||||
|
(test "JD 123" julian/scaliger->string 123)
|
||||||
|
|
||||||
;; make sure that date* has the correct parent info
|
;; make sure that date* has the correct parent info
|
||||||
(test #t date*?
|
(test #t date*?
|
||||||
|
|
|
@ -18,7 +18,9 @@
|
||||||
. ->* .
|
. ->* .
|
||||||
exact-integer?)]
|
exact-integer?)]
|
||||||
[date->julian/scalinger (date? . -> . exact-integer?)]
|
[date->julian/scalinger (date? . -> . exact-integer?)]
|
||||||
[julian/scalinger->string (exact-integer? . -> . string?)])
|
[date->julian/scaliger (date? . -> . exact-integer?)]
|
||||||
|
[julian/scalinger->string (exact-integer? . -> . string?)]
|
||||||
|
[julian/scaliger->string (exact-integer? . -> . string?)])
|
||||||
|
|
||||||
(define (current-date)
|
(define (current-date)
|
||||||
(seconds->date (* #i1/1000 (current-inexact-milliseconds))))
|
(seconds->date (* #i1/1000 (current-inexact-milliseconds))))
|
||||||
|
@ -348,6 +350,8 @@
|
||||||
gregorian-adjustment))
|
gregorian-adjustment))
|
||||||
final-date)
|
final-date)
|
||||||
|
|
||||||
|
(define date->julian/scaliger date->julian/scalinger)
|
||||||
|
|
||||||
;; julian/scalinger->string :
|
;; julian/scalinger->string :
|
||||||
;; number [julian-day] -> string [julian-day-format]
|
;; number [julian-day] -> string [julian-day-format]
|
||||||
|
|
||||||
|
@ -372,3 +376,5 @@
|
||||||
(cadr reversed-digits)
|
(cadr reversed-digits)
|
||||||
(car reversed-digits)))
|
(car reversed-digits)))
|
||||||
(loop (cdr (cdr (cdr reversed-digits))))))))))))
|
(loop (cdr (cdr (cdr reversed-digits))))))))))))
|
||||||
|
|
||||||
|
(define julian/scaliger->string julian/scalinger->string)
|
Loading…
Reference in New Issue
Block a user