From: ·······@gmail.com
Subject: convert julian date to universal
Date: 
Message-ID: <c1b7f417-9fd8-4225-9f44-7958d0526ee3@j78g2000hsd.googlegroups.com>
could somebody give some lisp code pointers that does the above..
covert julian date to universal date (UTC).

Many thanks.

George

From: D Herring
Subject: Re: convert julian date to universal
Date: 
Message-ID: <q-qdnRGkwMRgBBDanZ2dnUVZ_uKpnZ2d@comcast.com>
·······@gmail.com wrote:
> could somebody give some lisp code pointers that does the above..
> covert julian date to universal date (UTC).

This isn't what you want, but here's an interesting set of calendar 
converters:
http://emr.cs.uiuc.edu/~reingold/calendars.shtml
(code at the bottom)

That's probably everything *but* UTC.

Sorry,
Daniel
From: ·······@gmail.com
Subject: Re: convert julian date to universal
Date: 
Message-ID: <fb897db6-a3bb-4722-a5bb-09565ce52ea2@s8g2000prg.googlegroups.com>
On Jan 16, 4:45 pm, D Herring <········@at.tentpost.dot.com> wrote:
> ·······@gmail.com wrote:
> > could somebody give some lisp code pointers that does the above..
> > covert julian date to universal date (UTC).
>
> This isn't what you want, but here's an interesting set of calendar
> converters:http://emr.cs.uiuc.edu/~reingold/calendars.shtml
> (code at the bottom)
>
> That's probably everything *but* UTC.
>
> Sorry,
> Daniel

Thanks Daniel i am looking through it. Have identified some function
which i am testing at the repl

thanks.

George Tasso
From: Patrice Lespagnol
Subject: Re: convert julian date to universal
Date: 
Message-ID: <130c1508-61be-4a01-aed8-6342baa21178@c23g2000hsa.googlegroups.com>
·······@gmail.com a écrit :
> could somebody give some lisp code pointers that does the above..
> covert julian date to universal date (UTC).

(defun julian-to-gregorian-calendar (j)
  (let ((i 0)(l 0)(n 0)(x 0)(d 0))
    (setq l (+ (ceiling j) 68569))
    (setq n (truncate (* l 4) 146097))
    (decf l (truncate (+ (* n 146097) 3) 4))
    (setq i (truncate (* (+ 1 l) 4000) 1461001))
    (decf l (- (truncate (* i 1461) 4) 31))
    (setq x (truncate (* l 80) 2447))
    (setq d (- l (truncate (* x 2447) 80)))
    (setq l (truncate x 11))
    (values (+ (* 100 (- n 49)) i l)
	    (- (+ x 2) (* l 12))
	    d)))
From: ·······@gmail.com
Subject: Re: convert julian date to universal
Date: 
Message-ID: <f0fcc1e3-b161-4eda-bafe-7fff69a72c81@i12g2000prf.googlegroups.com>
On Jan 17, 6:24 am, Patrice Lespagnol <·················@obs-
nancay.fr> wrote:
> ·······@gmail.com a écrit :
>
> > could somebody give some lisp code pointers that does the above..
> > covert julian date to universal date (UTC).
>
> (defun julian-to-gregorian-calendar (j)
>   (let ((i 0)(l 0)(n 0)(x 0)(d 0))
>     (setq l (+ (ceiling j) 68569))
>     (setq n (truncate (* l 4) 146097))
>     (decf l (truncate (+ (* n 146097) 3) 4))
>     (setq i (truncate (* (+ 1 l) 4000) 1461001))
>     (decf l (- (truncate (* i 1461) 4) 31))
>     (setq x (truncate (* l 80) 2447))
>     (setq d (- l (truncate (* x 2447) 80)))
>     (setq l (truncate x 11))
>     (values (+ (* 100 (- n 49)) i l)
>             (- (+ x 2) (* l 12))
>             d)))

this what what i am getting at repl
user: (julian-to-gregorian-calendar 733072)
-2706
12
24

which is day month and year ?
From: Patrice Lespagnol
Subject: Re: convert julian date to universal
Date: 
Message-ID: <c385b12d-730b-44d6-a0f2-018c267920fc@l1g2000hsa.googlegroups.com>
On 16 jan, 23:27, ·······@gmail.com wrote:
> On Jan 17, 6:24 am, Patrice Lespagnol <·················@obs-
>
>
>
> nancay.fr> wrote:
> > ··········@gmail.com a écrit :
>
> > > could somebody give some lisp code pointers that does the above..
> > > covert julian date to universal date (UTC).
>
> > (defun julian-to-gregorian-calendar (j)
> >   (let ((i 0)(l 0)(n 0)(x 0)(d 0))
> >     (setq l (+ (ceiling j) 68569))
> >     (setq n (truncate (* l 4) 146097))
> >     (decf l (truncate (+ (* n 146097) 3) 4))
> >     (setq i (truncate (* (+ 1 l) 4000) 1461001))
> >     (decf l (- (truncate (* i 1461) 4) 31))
> >     (setq x (truncate (* l 80) 2447))
> >     (setq d (- l (truncate (* x 2447) 80)))
> >     (setq l (truncate x 11))
> >     (values (+ (* 100 (- n 49)) i l)
> >             (- (+ x 2) (* l 12))
> >             d)))
>
> this what what i am getting at repl
> user: (julian-to-gregorian-calendar 733072)
> -2706
> 12
> 24
>
> which is day month and year ?

That's year month day.
From: Harald Hanche-Olsen
Subject: Re: convert julian date to universal
Date: 
Message-ID: <pcohchcq3qp.fsf@shuttle.math.ntnu.no>
+ ·······@gmail.com:

> On Jan 17, 6:24 am, Patrice Lespagnol <·················@obs-
> nancay.fr> wrote:
>> ·······@gmail.com a �crit :
>>
>> > could somebody give some lisp code pointers that does the above..
>> > covert julian date to universal date (UTC).
>>
>> (defun julian-to-gregorian-calendar (j)
>>   (let ((i 0)(l 0)(n 0)(x 0)(d 0))
>>     (setq l (+ (ceiling j) 68569))
>>     (setq n (truncate (* l 4) 146097))
>>     (decf l (truncate (+ (* n 146097) 3) 4))
>>     (setq i (truncate (* (+ 1 l) 4000) 1461001))
>>     (decf l (- (truncate (* i 1461) 4) 31))
>>     (setq x (truncate (* l 80) 2447))
>>     (setq d (- l (truncate (* x 2447) 80)))
>>     (setq l (truncate x 11))
>>     (values (+ (* 100 (- n 49)) i l)
>>             (- (+ x 2) (* l 12))
>>             d)))
>
> this what what i am getting at repl
> user: (julian-to-gregorian-calendar 733072)
> -2706
> 12
> 24
>
> which is day month and year ?

More likely the other way round (year month day).  The code can't
possibly be correct though, since Julian days start at noon UT.
Replacing (ceiling j) by (round j) should cure that.  At least, then
the example given in the wikipedia entry comes out right.

  http://en.wikipedia.org/wiki/Julian_day

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
  when there is no ground whatsoever for supposing it is true.
  -- Bertrand Russell
From: Patrice Lespagnol
Subject: Re: convert julian date to universal
Date: 
Message-ID: <662680ca-273b-4a07-b272-95e01975f725@d21g2000prf.googlegroups.com>
> More likely the other way round (year month day).  The code can't
> possibly be correct though, since Julian days start at noon UT.
> Replacing (ceiling j) by (round j) should cure that.  At least, then
> the example given in the wikipedia entry comes out right.
Yes, that's right. The function was incorrect in case of a fractional
part  < 0.5.

(defun julian-to-gregorian-calendar (j)
  (let ((i 0)(l 0)(n 0)(x 0)(d 0))
    (setq l (+ (round j) 68569))
    (setq n (truncate (* l 4) 146097))
    (decf l (truncate (+ (* n 146097) 3) 4))
    (setq i (truncate (* (+ 1 l) 4000) 1461001))
    (decf l (- (truncate (* i 1461) 4) 31))
    (setq x (truncate (* l 80) 2447))
    (setq d (- l (truncate (* x 2447) 80)))
    (setq l (truncate x 11))
    (values (+ (* 100 (- n 49)) i l)
            (- (+ x 2) (* l 12))
            d)))
From: Patrice Lespagnol
Subject: Re: convert julian date to universal
Date: 
Message-ID: <c2e4c6de-5eb1-4fdc-8644-665e6b68bc8d@v29g2000hsf.googlegroups.com>
> More likely the other way round (year month day).  The code can't
> possibly be correct though, since Julian days start at noon UT.
> Replacing (ceiling j) by (round j) should cure that.  At least, then
> the example given in the wikipedia entry comes out right.
Yes, that's right. The function was incorrect in case of a fractional
part  < 0.5.

(defun julian-to-gregorian-calendar (j)
  (let ((i 0)(l 0)(n 0)(x 0)(d 0))
    (setq l (+ (round j) 68569))
    (setq n (truncate (* l 4) 146097))
    (decf l (truncate (+ (* n 146097) 3) 4))
    (setq i (truncate (* (+ 1 l) 4000) 1461001))
    (decf l (- (truncate (* i 1461) 4) 31))
    (setq x (truncate (* l 80) 2447))
    (setq d (- l (truncate (* x 2447) 80)))
    (setq l (truncate x 11))
    (values (+ (* 100 (- n 49)) i l)
            (- (+ x 2) (* l 12))
            d)))