need help , please !!! 
Author Message
 need help , please !!!


Quote:
>how can i count the difference between two date's
>but in standart Pascal !

>for exam':
>first_date_day:=28; first_date_mounth:=2;  first_date_year:=99;
>sec_date_day:=03; sec_date_mounth:=3;  sec_date_year:=99;

You can convert both to a Julian date and subtract.  Or, if you
know the number of days in each month it is pretty
straightforward to do it w/o Jumian dates.

Jud McCranie



Wed, 18 Jun 1902 08:00:00 GMT  
 need help , please !!!
how can i count the difference between two date's
but in standart pascal !

for exam':
first_date_day:=28; first_date_mounth:=2;  first_date_year:=99;
sec_date_day:=03; sec_date_mounth:=3;  sec_date_year:=99;

so i wanna put on integer var  calls "X" the difference between
28.2.99 and 03.03.99
then the answer is 3 days, X - will gonna get the value - 3 in
this case !!!

how i write it , please help me !!!
thanx thanx thanx :-)




Wed, 18 Jun 1902 08:00:00 GMT  
 need help , please !!!

Quote:

> how can i count the difference between two date's
> but in standart pascal !

> for exam':
> first_date_day:=28; first_date_mounth:=2;  first_date_year:=99;
> sec_date_day:=03; sec_date_mounth:=3;  sec_date_year:=99;

You must convert the date into a linear integer/word/longint, eg.
starting at a particular day like 01.01.1980. It is advisable to
start in a leapyear.

http://www.merlyn.demon.co.uk/
Dr.John Stockton surely has hints for you.

:-)
--
Franz Glaser, Glasau 3, A-4191 Vorderweissenbach Austria +43-7219-7035-0
Muehlviertler Elektronik Glaser.  Industrial control and instrumentation
http://members.eunet.at/meg-glaser/    http://members.xoom.com/f_glaser/
http://www.geocities.com/~franzglaser/            http://start.at/bedarf



Wed, 18 Jun 1902 08:00:00 GMT  
 need help , please !!!

Jud McCranie schrieb in Nachricht ...

Quote:

>>how can i count the difference between two date's
>>but in standart pascal !

>>for exam':
>>first_date_day:=28; first_date_mounth:=2;  first_date_year:=99;
>>sec_date_day:=03; sec_date_mounth:=3;  sec_date_year:=99;

>You can convert both to a Julian date and subtract.  Or, if you
>know the number of days in each month it is pretty
>straightforward to do it w/o Jumian dates.

>Jud McCranie

I transcribed the following code from Algol-60 to Pascal and only
substituted longint for integer as Borland needs. This should be
reversed for a standard Pascal compiler.

-------------------- snip ---------------------------
(*
   ACM COMMUNICATIONS 8 (AUG. 1963), 444
   ALGORITHM 199:
   CONVERSIONS BETWEEN CALENDAR DATE AND JULIAN DAY NUMBER
   Robert G. TANTZEN
   Air Force Missile Development Center.
   Holloman AFB, New Mex.
*)

PROCEDURE JDAY(d, m, y:longint;
      VAR j:longint);
(*
   JDAY converts a calendar date, Gregorian calendar,
   to the corresponding Julian day number j. From the
   given day d, month m, and year y, the Julian day number
   j is computed without using tables. The procedure is
   valid for any valid Gregorian calendar date. When
   transcribing JDAY for other compilers, be sure that
   Integers of size 3 * 10^6 can be handled;
*)

   VAR
     c, ya:longint;

   BEGIN
     IF m > 2 THEN m := m - 3
     ELSE BEGIN
       m := m + 9;
       y := y - 1;
       END;
     c := y DIV 100;
     ya := y - 100 * c;
     j := (146097 * c) DIV 4 + (1461 * ya) DIV
       4 + (153 * m + 2) DIV 5 + d + 1721119;
     END;

PROCEDURE JDATE(j:longint;
      VAR d, m, y:longint);
(*
   JDATE converts a Julian day number j zo the
   corresponding calendar date, Gregorian calendar. Since
   j is an integer for this procedure, it is correct
   astronomically for noon of the day. JDATE computes the
   day d, month m, and year y, without without using tables.
   The procedure is valid for any valid Gregorian calendar
   date. When transcribing JDATE for other compilers, be
   sure that Integers of size 3 * 10^6 can be handled;
*)

   BEGIN
     j := j - 1721119;
     y := (4* j - 1) DIV 146097;
     j := 4 * j - 1 - 146097 * y;
     d := j DIV 4;
     j := (4 * d + 3) DIV 1461;
     d := 4 * d + 3 - 1461 * j;
     d := (d + 4) DIV 4;
     m := (5 * d - 3) DIV 153;
     d := 5 * d -3 - 153 * m;
     d := (d+5) DIV 5;
     y := 100 * y + j;
     IF m < 10 THEN m := m + 3
     ELSE BEGIN
       m := m - 9;
       y := y + 1;
       END;
     END;

-------------------- snip ---------------------------

hope I did no misprint
Andreas.



Wed, 18 Jun 1902 08:00:00 GMT  
 need help , please !!!

Quote:

> You must convert the date into a linear integer/word/longint, eg.
> starting at a particular day like 01.01.1980. It is advisable to
> start in a leapyear.

Just out of curiosity, why start in a leapyear, since unixtime starts in
01.01.1970 which is not a leapyear?

Bas



Wed, 18 Jun 1902 08:00:00 GMT  
 need help , please !!!


Quote:


>> how can i count the difference between two date's
>> but in standart pascal !

>> for exam':
>> first_date_day:=28; first_date_mounth:=2;  first_date_year:=99;
>> sec_date_day:=03; sec_date_mounth:=3;  sec_date_year:=99;

>You must convert the date into a linear integer/word/longint, eg.
>starting at a particular day like 01.01.1980. It is advisable to
>start in a leapyear.

>http://www.merlyn.demon.co.uk/
>Dr.John Stockton surely has hints for you.

See Sig. below; it's all in
unit     <URL: http://www.merlyn.demon.co.uk/programs/dateprox.pas>
tester   <URL: http://www.merlyn.demon.co.uk/programs/mjd_date.pas>
needs    <URL: http://www.merlyn.demon.co.uk/programs/version.pas>

It's best to start on the Wednesday following Feb 29 in a "century"
year, for the Gregorian Calendar; but any recent leapyear will do for a
"Julian" calendar now tangential to Gregorian.  In order to be able to
use standard "mod" simply, all daycounts must be positive; but, with a
"mod" as it ought to have been, that is not necessary : see
         <URL: http://www.merlyn.demon.co.uk/programs/longcalc.pas>
which calculates such things over >+-E65000 astronomical proleptic
Gregorian years from 0000-03-01.

But the best conventional scale is Modified Julian Date : 1858-11-17 Wed
GMT = MJD 0.

However, if the computer is fast and the range of dates small, you can
do it by counting and stepping through the months, as in
         <URL: http://www.merlyn.demon.co.uk/programs/hunt.pas>
which counts back from "today".

Note that others have produced slightly faster algorithms (some of which
are in my programs directory) for date<->day conversion; mine are fairly
directly from first principles and hindsight.

--

  Web <URL: http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
  PAS, EXE in <URL: http://www.merlyn.demon.co.uk/programs/> - see 00index.txt.
  Do not Mail News to me.    Before a reply, quote with ">" or "> " (SoRFC1036)



Wed, 18 Jun 1902 08:00:00 GMT  
 need help , please !!!


Quote:

>I transcribed the following code from Algol-60 to Pascal and only
>substituted longint for integer as Borland needs. This should be
>reversed for a standard Pascal compiler.

>-------------------- snip ---------------------------
>(*
>   ACM COMMUNICATIONS 8 (AUG. 1963), 444
>   ALGORITHM 199:
>   CONVERSIONS BETWEEN CALENDAR DATE AND JULIAN DAY NUMBER

It's amazing that ACM accepted that statement-of-purpose, since the
calendar date changes at midnight local and the Julian Day Number
changes at noon GMT/UTC.

Doesn't stop it working for date differences, of course.  It appears to
contain all the right sorts of bits.

  (*  I'd modify the 1721119 constants by about -2400000 to get MJD, and
      check that MJD 0 is 1858 Nov 17 Wed.  *)

But it seems OK, allowing for rounding the half day.

Your routines, preceding

        var M, J, D, Y : longint ;
        BEGIN
        repeat Write(' ? ') ; Readln(J) ;
          JDATE(J, D, M, Y) ; Write(J:15, Y:12, M:3, D:3) ;
          JDAY(D, M, Y, J) ; Writeln(J:15) ;
          until false ;
        END.

Input lines omitted :

              J    ->     Y  M  D      ->      J
              0       -4712  0 -1              6
        1000000       -1974 -1 -4        1000007
        1500000        -605 -1-22        1500006
        1700000         -57 -6-22        1700005
        1721120           0  3  1        1721120
        1750000          79  3 27        1750000
        2250000        1448  3 10        2250000
        2400000        1858 11 16        2400000
        2450000        1995 10  9        2450000
        2451550        2000  1  6        2451550
        9999999       22666 12 19        9999999

So : OK for Christian years! it seems OK from 0000-03-01,
unsurprisingly.

MJD (sic) 50000 is without doubt 1995-Oct-10; MJD 0 as above.

--

  <URL: http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c. FAQqish topics, links.
  Timo's TurboPascal <A HREF="ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip">FAQ</A>.
  Pedt: <A HREF="http://www.merlyn.demon.co.uk/clpb-faq.txt">c.l.p.b. mFAQ</A>.



Wed, 18 Jun 1902 08:00:00 GMT  
 need help , please !!!



Quote:

> > You must convert the date into a linear integer/word/longint, eg.
> > starting at a particular day like 01.01.1980. It is advisable to
> > start in a leapyear.

> Just out of curiosity, why start in a leapyear, since unixtime starts in
> 01.01.1970 which is not a leapyear?

You can start whenever you like, it's just that some selections lead to
simpler code than others.

I use the Gregorian calendar with day 0 = 1.1.0001 in my programs. It works
out nicely enough even though it is not a leap year. I wanted to use day 0 =
1.1.0000, Paradox allows dates in that year and it would suit most people
better as the first day of the previous millennium (although one might have
to apply {$R-} to your brain to allow 0 CE = 1 BCE). But having a 29th of
February in the 1st year was a little awkward for me.

Frank



Wed, 18 Jun 1902 08:00:00 GMT  
 need help , please !!!



Quote:
>I use the Gregorian calendar with day 0 = 1.1.0001 in my programs. It works
>out nicely enough even though it is not a leap year. I wanted to use day 0 =
>1.1.0000, Paradox allows dates in that year and it would suit most people
>better as the first day of the previous millennium (although one might have
>to apply {$R-} to your brain to allow 0 CE = 1 BCE). But having a 29th of
>February in the 1st year was a little awkward for me.

By starting on Wednesday March 1st of a "century" leap year, February 29th
either comes or does not come at the END of any repeating interval; it
never comes elsewhere.  Therefore, one only needs to handle the intervals
correctly; Feb 29th appears where needed, because, to quote one of my
favourite sources, <URL: http://www.merlyn.demon.co.uk/quotes.htm> ,
"February is merely as long as is needed to pass the time until March.".

For most algorithms, the chosen internal base date should be before or
equal to any valid date, so that MOD does what is wanted.  In program
longcalc.pas, I have a MOD that does what *I* want, and now use a
"central" base date.

--

  Web <URL: http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
  PAS, EXE in <URL: http://www.merlyn.demon.co.uk/programs/> - see 00index.txt.
  Do not Mail News to me.    Before a reply, quote with ">" or "> " (SoRFC1036)



Wed, 18 Jun 1902 08:00:00 GMT  
 need help , please !!!
Hi!

Quote:
> Just out of curiosity, why start in a leapyear, since unixtime starts in
> 01.01.1970 which is not a leapyear?

BTW: How can I check whether a year is a leap year or not? I know that there
are four conditions that must be true if it is a leap year but I do not know
how this conditions are. Any ideas?

CU
Jens

--
Homepage (German and English):
http://home.t-online.de/home/jens.gesing/index.htm
Programming-Do-It-Yourself: http://members.xoom.com/goldman47/index.htm



Wed, 18 Jun 1902 08:00:00 GMT  
 need help , please !!!

Quote:

> By starting on Wednesday March 1st of a "century" leap year ...

  Is the 1st of March of a century year always a Wednesday ?

         - Bob



Wed, 18 Jun 1902 08:00:00 GMT  
 need help , please !!!


Quote:

> > By starting on Wednesday March 1st of a "century" leap year ...

>   Is the 1st of March of a century year always a Wednesday ?

Learn to read!

JRS wrote "century" leap year, ie 1600/2000/2400 etc!
.          =======

The Gregorian calendar repeats every 400 years, at least for the
forseeable future.

Robert
--
Robert AH Prins

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 need help , please !!!

Quote:

> BTW: How can I check whether a year is a leap year or not? I know that there
> are four conditions that must be true if it is a leap year but I do not know
> how this conditions are. Any ideas?

Function LeapYear(year : word) : Boolean;
Begin
  LeapYear := ((Year MOD 4) AND (Year MOD 100 <> 0)) or (Year MOD 400 =
0);
End;

Bas



Wed, 18 Jun 1902 08:00:00 GMT  
 need help , please !!!


Quote:

>> Just out of curiosity, why start in a leapyear, since unixtime starts in
>> 01.01.1970 which is not a leapyear?
>BTW: How can I check whether a year is a leap year or not? I know that there
>are four conditions that must be true if it is a leap year but I do not know
>how this conditions are. Any ideas?

Try reading Timo's FAQ item 91 & references; my <URL: http://www.merlyn.
demon.co.uk/leapyear.htm> & links; and my <URL: http://www.merlyn.demon.
co.uk/programs/leapyear.pas> gives about 20 algorithms in Pascal, and
demonstrates their equivalence and speed over the DOS range.

There are not four conditions; there are two conditions, divisibility by
four and, if divisible by 100, also by 400 - plus you must not be (some)
Greek Orthodox, fUSSR, or French Revolutionary.

See Sig. refs.

--

  Web <URL: http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
  Dates - miscdate.htm  Year 2000 - date2000.htm  Critical Dates - critdate.htm
  Y2k for beginners - year2000.txt  UK mini-FAQ - y2k-mfaq.txt  Don't Mail News



Wed, 18 Jun 1902 08:00:00 GMT  
 need help , please !!!



Quote:

>> By starting on Wednesday March 1st of a "century" leap year ...

>  Is the 1st of March of a century year always a Wednesday ?

No.  In 1900 it was Thursday, in 1800 Saturday.  But the 29th of
February Gregorian in a "00" year is always a Tuesday.

See below, read miscdate.htm and pages linked from it.

--

  Web <URL: http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
  Dates - miscdate.htm  Year 2000 - date2000.htm  Critical Dates - critdate.htm
  Y2k for beginners - year2000.txt  UK mini-FAQ - y2k-mfaq.txt  Don't Mail News



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 16 post ]  Go to page: [1] [2]

 Relevant Pages 

1. New Application, need help please...

2. I NEED HELP PLEASE!!!!

3. Need Help Please

4. New to Pascal, need help please

5. I need help, please

6. Newbie needs help please.

7. Need help Please

8. need help, please

9. Need help Please

10. need help please

11. NEED HELP PLEASE

12. WAVe format needed - help, please - Wavhdr.pas (1/1)

 

 
Powered by phpBB® Forum Software