home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.pascal.borland      Borland Pascal was actually pretty neat      2,978 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 2,404 of 2,978   
   Heinrich Wolf to All   
   Re: Need a Pascal equivalent to C's diff   
   02 Mar 07 07:25:06   
   
   From: invalid@invalid.invalid   
      
   Hi,   
      
   when I look at the definition   
   double difftime(time_t time2, time_t time1);   
   then it almost reduces to me as   
      
   double difftime(time_t time2, time_t time1)   
   {   
   return time2 - (double) time1;   
   }   
      
   When I compare it to TP5.5 GetTime and GetDate,   
   then you rather need a really complicated stuff called   
   time_t mktime(struct tm *tm_struct);   
   which is available in today's C,   
   but neither in TC 2.0 nor in TP5.5.   
      
   Some time ago I coded a PASCAL function   
   even more mighty than mktime   
   (valid even before christ).   
   Here it is:   
      
   { These functions are created according to  "Astronomical Formulae for   
   Calculators, third edition" by Jean Meeus. }   
      
   { I'm sorry: My identifiers often are german words }   
      
   Type      GenaueZeit    = Record   
                               GrobeZeit : DateTime;   
                               S100      : Word;   
                             End;   
                 JulianTime    = Extended;   
      
   Function JulianischeZeit(Z : GenaueZeit) : JulianTime;   
     begin   
       With Z, Z.GrobeZeit do   
         JulianischeZeit :=   
           JulianischerTag(Year, Month,   
                           Day + ((((S100 / 100) + Sec) / 60   
                                   + Min) / 60   
                                  + Hour) / 24);   
     end;   
      
   Function  JulianischerTag    (Jahr  : Integer; Monat: Word; Tag :   
   JulianTime)   
             : JulianTime;   
             { -4712 <= Jahr = year < 4000   
               Monat = month: 1 = January to 12 = December   
               Tag = day; fraction = time since midnight   
               JulianischerTag begins at noon (!)   
               calculation valid before and after gregorian calendar   
   reformation (!)   
               Oct 4, 1582 + 1 = Oct 15, 1582 !   
             }  var    y, m  : LongInt;   
            a, b  : Integer;   
            jd    : JulianTime;   
            Datum : extended; { Datum YYYY.MMDD }   
     begin   
       Datum := Monat / 100 + Tag / 10000;   
       if Jahr < 0 then   
         Datum := Jahr - Datum   
       else   
         Datum := Jahr + Datum;   
       if Monat > 2 then   
         begin   
           m := Monat;   
           y := Jahr;   
         end   
       else   
         begin   
           m := Monat + 12;   
           y := Jahr  - 1;   
         end;   
       jd := y * 365 + y div 4 + 30 * (m + 1) + (6001 * (m + 1)) div 10000 +   
   Tag   
             + 1720994.5;   
       if Datum >= 1582.1015 then   
         begin   
           a  := y div 100;   
           b  := 2 - a + a div 4;   
           jd := jd + b;   
         end;   
       JulianischerTag := jd;   
     end;   
      
   regards   
   Heiner   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca