comp.lang.ada
 help / color / mirror / Atom feed
* Julian Dates package?
@ 1997-01-05  0:00 Jay Joiner
       [not found] ` <01bbfb55$c9dcbfe0$5e2d5c8b@jerryware>
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Jay Joiner @ 1997-01-05  0:00 UTC (permalink / raw)



I am interested in doing a Biorythm calculator in Ada and I need an Ada
package that can take the difference between two dates (birthdate and
today). I have the August 1996 Walnut Creek Ada CDROM set and would be
grateful if someone can point me to a source on this repository.
--
Jay Joiner
Monument, Colorado




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Julian Dates package?
       [not found] ` <01bbfb55$c9dcbfe0$5e2d5c8b@jerryware>
@ 1997-01-06  0:00   ` Mike Stark
  1997-01-09  0:00   ` Gautier
  1 sibling, 0 replies; 9+ messages in thread
From: Mike Stark @ 1997-01-06  0:00 UTC (permalink / raw)



Jerry van Dijk wrote:
> 
> Jay Joiner <jjoiner@ibm.net> wrote in article
> <32CFFA13.5BF8@ibm.net>...
> 
> > I am interested in doing a Biorythm calculator in Ada and I need an
> Ada
> > package that can take the difference between two dates (birthdate and
> > today).

I suggest using package Calendar, since it provides subtraction operator
for two absolute times, yielding elapsed times.  To compute number of
days, create a birthdate and current date of type calendar.time, with
the seconds of day set to zero.  This will give you a (fixed point) 
number of seconds.  Divide that number by 86,400 and you now have
the number of days.

If you have any more questions, feel free to e-mail me.

> 
> I thought Julian dates were mainly used for astronomy and such ?
> 
> Jerry.

That is correct.  However, in the systems we use at Goddard's Flight
Dynamics Division we model times as seconds from a fixed reference date.
With spacecraft it is important to include leap seconds, because each 
leap second you neglect can translate to 7 or 8 kilometers of along 
track error in your orbit computation.  I don't think leap seconds 
matter much for a biorhythms program, though ;)

Mike




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Julian Dates package?
  1997-01-08  0:00 ` Keith Thompson
@ 1997-01-08  0:00   ` Mike Stark
  1997-01-08  0:00     ` Robert Dewar
  0 siblings, 1 reply; 9+ messages in thread
From: Mike Stark @ 1997-01-08  0:00 UTC (permalink / raw)



Keith Thompson wrote:
> 
> Mike Stark <michael.e.stark@GSFC.NASA.GOV> wrote:
> > I suggest using package Calendar, since it provides subtraction operator
> > for two absolute times, yielding elapsed times.  To compute number of
> > days, create a birthdate and current date of type calendar.time, with
> > the seconds of day set to zero.  This will give you a (fixed point)
> > number of seconds.  Divide that number by 86,400 and you now have
> > the number of days.
> 
> That's not guaranteed to work.  The subtraction operation returns a
> result of type Duration, which is a fixed-point type with a minimum range
> of -86400.0 .. +86400.0 (i.e., +/- 1 day).  Thus, you can't portably
> subtract two Calendar.Time values more than a day apart.
> 
> --
> Keith Thompson (The_Other_Keith) kst@aonix.com <http://www.aonix.com> <*>
> TeleSo^H^H^H^H^H^H Alsy^H^H^H^H Thomson Softw^H^H^H^H^H^H^H^H^H^H^H^H^H Aonix
> 10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2706
> "SPOON!" -- The Tick
OOPS!  You are absolutely right!  We have a time utilities package that
exports a time type that is valid from 1901 through 2099, the same range
as Calendar.TIME, and allows the computation of elapsed time as a
floating point number of seconds.  If anyone is interested in our time
packages feel free to send me an e-mail.

Mike




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Julian Dates package?
  1997-01-05  0:00 Julian Dates package? Jay Joiner
       [not found] ` <01bbfb55$c9dcbfe0$5e2d5c8b@jerryware>
@ 1997-01-08  0:00 ` Keith Thompson
  1997-01-08  0:00   ` Mike Stark
  1997-01-08  0:00 ` Fintan
  1997-01-09  0:00 ` Mats Weber
  3 siblings, 1 reply; 9+ messages in thread
From: Keith Thompson @ 1997-01-08  0:00 UTC (permalink / raw)



Mike Stark <michael.e.stark@GSFC.NASA.GOV> wrote:
> I suggest using package Calendar, since it provides subtraction operator
> for two absolute times, yielding elapsed times.  To compute number of
> days, create a birthdate and current date of type calendar.time, with
> the seconds of day set to zero.  This will give you a (fixed point)
> number of seconds.  Divide that number by 86,400 and you now have
> the number of days.

That's not guaranteed to work.  The subtraction operation returns a
result of type Duration, which is a fixed-point type with a minimum range
of -86400.0 .. +86400.0 (i.e., +/- 1 day).  Thus, you can't portably
subtract two Calendar.Time values more than a day apart.

-- 
Keith Thompson (The_Other_Keith) kst@aonix.com <http://www.aonix.com> <*>
TeleSo^H^H^H^H^H^H Alsy^H^H^H^H Thomson Softw^H^H^H^H^H^H^H^H^H^H^H^H^H Aonix
10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2706
"SPOON!" -- The Tick




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Julian Dates package?
  1997-01-05  0:00 Julian Dates package? Jay Joiner
       [not found] ` <01bbfb55$c9dcbfe0$5e2d5c8b@jerryware>
  1997-01-08  0:00 ` Keith Thompson
@ 1997-01-08  0:00 ` Fintan
  1997-01-09  0:00 ` Mats Weber
  3 siblings, 0 replies; 9+ messages in thread
From: Fintan @ 1997-01-08  0:00 UTC (permalink / raw)



Jay Joiner wrote:
> 
> I am interested in doing a Biorythm calculator in Ada and I need an Ada
> package that can take the difference between two dates (birthdate and
> today). 

You might care to look at:

  http://www.scism.sbu.ac.uk/law/Section2/chap4/s2c4int.html

Where a JulianDates package is provided and explained.

fintan




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Julian Dates package?
  1997-01-08  0:00   ` Mike Stark
@ 1997-01-08  0:00     ` Robert Dewar
  0 siblings, 0 replies; 9+ messages in thread
From: Robert Dewar @ 1997-01-08  0:00 UTC (permalink / raw)



Keith said

"> That's not guaranteed to work.  The subtraction operation returns a
> result of type Duration, which is a fixed-point type with a minimum range
> of -86400.0 .. +86400.0 (i.e., +/- 1 day).  Thus, you can't portably
> subtract two Calendar.Time values more than a day apart."

This is not just theoretical. In all versions of GNAT, we use a 64-bit
value for both time and duration, so any possible period is easily covered,
but other compilers (in particular Object Ada, and maybe others) use a
32-bit representation for Duration, and the range is therefore much closer
to the required minimum (which was chosen precisely so that a 32-bit type
is somewhat usable).

We decided in GNAT to use a 64-bit type, because we don't want to have
to compromise on either the range or precision (in GNAT Duration'Small
is in nanoseconds), and the 32-bit type requires both the range and
precision to be crunched. 

But code that assumes a large range is definitely not necessarily portable,
though it will port from one version of GNAT to another!





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Julian Dates package?
       [not found] ` <01bbfb55$c9dcbfe0$5e2d5c8b@jerryware>
  1997-01-06  0:00   ` Mike Stark
@ 1997-01-09  0:00   ` Gautier
  1997-01-13  0:00     ` Michael & Amy Hartsough
  1 sibling, 1 reply; 9+ messages in thread
From: Gautier @ 1997-01-09  0:00 UTC (permalink / raw)



In article <01bbfb55$c9dcbfe0$5e2d5c8b@jerryware>, "Jerry van Dijk" <jvandyk@ibm.net> writes:
> Jay Joiner <jjoiner@ibm.net> wrote in article
> <32CFFA13.5BF8@ibm.net>...
> 
>> I am interested in doing a Biorythm calculator in Ada and I need an
> Ada
>> package that can take the difference between two dates (birthdate and
>> today).
> 
> I thought Julian dates were mainly used for astronomy and such ?
> 
> Jerry.

Julian dates are used for hydrological data and I guess many
applications of this type, where cyclical phenomena do not
depend of the existence of a 29 february in the year...

Here is a "minimal" package, adapted from one of my toolbox in
another language that works well, but not yet tested in Ada:

-----------------------------------------------------------------------------
with Calendar;

package Julian_Calendar is

type Julian_time is record day,sec: Long_integer; end record;

function Julian_time_of(t:Calendar.Time) return Julian_time;
function Time_of(j:Julian_time) return Calendar.Time;

end Julian_Calendar;

-----------------------------------------------------------------------------
package body Julian_Calendar is

  use Calendar;

  function Time_of(j:Julian_time) return Time is
    IY: Year_Number;
    IM: Month_Number;
    ID: Day_Number;
    jules: Long_integer;
    BEGIN
      jules := j.day-1721119;
      IY:=     Year_Number((4*jules-1)  /  146097);
      jules :=             (4*jules-1) MOD 146097;
      ID    := Day_Number(jules  /  4);
      jules := Long_integer((4*ID+3)  /  1461);
      ID    :=              (4*ID+3) MOD 1461;
      ID    := (ID+4)    /  4;
      IM    := (5*ID-3)  /  153;                                    -- month
      ID    := (5*ID-3) MOD 153;
      ID    :=   (ID+5)  /  5  ;                                    -- day
      IY    := Year_Number(100*Long_integer(IY) + jules);           -- year
      IF IM<10 THEN
        IM:=IM+3;
      ELSE
        IM:=IM-9;
        IY:=IY+1;
      END IF;
      return Calendar.Time_of(IY,IM,ID,Day_Duration(j.sec));
    END;

  function Julian_time_of(t:Time) return Julian_time is
    IY: Year_Number;
    IM: Month_Number;
    ID: Day_Number;
    LY,LM,LD: Long_integer;
    S: Day_Duration;
    BEGIN
      Split(t, IY,IM,ID,S);
      LY:= Long_integer(IY);
      LM:= Long_integer(IM);
      LD:= Long_integer(ID);
      return 
      (day=> (LM*3057)  /  100 + LD +
              ((5-LM  /  3)  /  5) * (2 - (4 - LY MOD 4)  /  4  +
                                     (100 - LY MOD 100)  /  100 -
                                     (400 - LY MOD 400)  /  400) +
              1721028 + LY*365 + LY  /  4 - LY  /  100 + LY  /  400,
       sec=> Long_integer(S));
    END;

end Julian_Calendar;






^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Julian Dates package?
  1997-01-05  0:00 Julian Dates package? Jay Joiner
                   ` (2 preceding siblings ...)
  1997-01-08  0:00 ` Fintan
@ 1997-01-09  0:00 ` Mats Weber
  3 siblings, 0 replies; 9+ messages in thread
From: Mats Weber @ 1997-01-09  0:00 UTC (permalink / raw)



> I am interested in doing a Biorythm calculator in Ada and I need an Ada
> package that can take the difference between two dates (birthdate and
> today). I have the August 1996 Walnut Creek Ada CDROM set and would be
> grateful if someone can point me to a source on this repository.
> --
> Jay Joiner
> Monument, Colorado

Here is what you need:

begin 644 ext-cal.tar.gz
<uuencoded_portion_removed>
+_N^_O+K[2`!X``!?
`
end




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Julian Dates package?
  1997-01-09  0:00   ` Gautier
@ 1997-01-13  0:00     ` Michael & Amy Hartsough
  0 siblings, 0 replies; 9+ messages in thread
From: Michael & Amy Hartsough @ 1997-01-13  0:00 UTC (permalink / raw)



Gautier wrote:
> 
> In article <01bbfb55$c9dcbfe0$5e2d5c8b@jerryware>, "Jerry van Dijk" <jvandyk@ibm.net> writes:
> > Jay Joiner <jjoiner@ibm.net> wrote in article
> > <32CFFA13.5BF8@ibm.net>...
> >
> >> I am interested in doing a Biorythm calculator in Ada and I need an
> > Ada
> >> package that can take the difference between two dates (birthdate and
> >> today).
> >
> > I thought Julian dates were mainly used for astronomy and such ?
> >
> > Jerry.
> 
> Julian dates are used for hydrological data and I guess many
> applications of this type, where cyclical phenomena do not
> depend of the existence of a 29 february in the year...
> 
> Here is a "minimal" package, adapted from one of my toolbox in
> another language that works well, but not yet tested in Ada:

Several years ago I wrote a "full up" Gregorian-To-Julian-To-Gregorian package.
It's based upon the algorithms in Jean Meeus' book "Astronomical Algorithms".
If you're not satisfied with what you receive in the other posts, let me know
and I'll "dust it off" for you.

Later,
	Michael




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~1997-01-13  0:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-01-05  0:00 Julian Dates package? Jay Joiner
     [not found] ` <01bbfb55$c9dcbfe0$5e2d5c8b@jerryware>
1997-01-06  0:00   ` Mike Stark
1997-01-09  0:00   ` Gautier
1997-01-13  0:00     ` Michael & Amy Hartsough
1997-01-08  0:00 ` Keith Thompson
1997-01-08  0:00   ` Mike Stark
1997-01-08  0:00     ` Robert Dewar
1997-01-08  0:00 ` Fintan
1997-01-09  0:00 ` Mats Weber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox